get(); return response()->json($matchedTerm); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // //$company = new Company; // if($request->hasFile('avatar')) // { // $avatar = $request->file('avatar'); // $filename = time() . '.' . $avatar->getClientOriginalExtension(); // Image::make($avatar)->resize(300,300)->save(public_path('/uploads/company_profile/'.$filename)); // } // else // { // return response()->json(['message'=>'Document not found']); // } $input = $request->all(); //validating uploaded files // $this->validate(request(),[ // 'company_profile' => 'required|image|mimes:jpg,jpeg,bmp,png', // 'reg_cerf' => 'required|mimes:jpg,jpeg,bmp,png,gif,svg,pdf' // ]); if($file = $request->file('company_profile')) //company profile picture { $company_profile = $request->file('company_profile'); $filename = $company_profile->getClientOriginalName(); //$destinationPath = config('app.fileDestinationPath').'/'.$filename; $file = $request->file('company_profile'); $ext = $file->getClientOriginalExtension(); Storage::putFileAs( 'company_profile',/*folder name*/ $file, $filename. '.' .$ext ); // $name = $file->getClientOriginalName(); // $img_file = $request->file('company_profile'); // Image::make($img_file)->resize(300,300)->save(public_path('\company_profile')); // //return $img_file; // // $file->move('uploads/company_profile/', $img_file); // $input['company_profile'] = $name; } if($request->hasFile('reg_cert')) //Registration Certificate upload { $reg_cert = $request->file('reg_cert'); $filename = $reg_cert->getClientOriginalName(); //$destinationPath = config('app.fileDestinationPath').'/'.$filename; $file = $request->file('reg_cert'); $ext = $file->getClientOriginalExtension(); Storage::putFileAs( 'reg_cert',/*folder name*/ $file, $filename. '.' .$ext ); // $uploaded = Storage::put($destinationPath, file_get_contents($reg_cert->getRealPath())); // $name = $file->getClientOriginalName(); // $img_file = $request->file('reg_cert'); // Image::make($img_file)->save(public_path('uploads\reg_cert')); // $input['company_profile'] = $name; // $request->file('req_cert'); // //$request->image->store('\uploads\reg_cert'); // Storage::putFile('uploads\reg_cert', $request->file('reg_cert')); } // else{ // return "failed"; // } Company::create($input); //Company::create(request()->all()); //dd(request()->all()); return redirect('/'); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $company = Company::find($id); if (!$company) { return response()->json(['message'=>'Document not found'],200); } //updating company profile picture if($file = $request->file('company_profile')) //company profile picture { $company_profile = $request->file('company_profile'); $filename = $company_profile->getClientOriginalName(); //$destinationPath = config('app.fileDestinationPath').'/'.$filename; $file = $request->file('company_profile'); $ext = $file->getClientOriginalExtension(); Storage::putFileAs( 'company_profile',/*folder name*/ $file, $filename. '.' .$ext ); } //updating registration certificate if($request->hasFile('reg_cert')) //Registration Certificate upload { $reg_cert = $request->file('reg_cert'); $filename = $reg_cert->getClientOriginalName(); //$destinationPath = config('app.fileDestinationPath').'/'.$filename; $file = $request->file('reg_cert'); $ext = $file->getClientOriginalExtension(); Storage::putFileAs( 'reg_cert',/*folder name*/ $file, $filename. '.' .$ext ); } $company->company_name=$request->input('company_name'); $company->registration_no=$request->input('registration_no'); $company->tax_no=$request->input('tax_no'); $company->tel_no=$request->input('tel_no'); $company->fax=$request->input('fax'); $company->address=$request->input('address'); $company->city=$request->input('city'); $company->postcode=$request->input('postcode'); $company->state=$request->input('state'); $company->country=$request->input('country'); $company->contact_person=$request->input('contact_person'); $company->save(); return response()->json(['warehouse'=>$company],200); // $product = Company::findOrFail($productId); // $product->update($request->all()); // $product->company_name = 'imagepath'; // $product->save(); //return response()->json($product, 200); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } public function uploadImage($request) { // if($request->hasFile('avatar')) // { // $avatar = $request->file('avatar'); // $filename = time() . '.' . $avatar->getClientOriginalExtension(); // Image::make($avatar)->resize(300,300)->save(public_path('/uploads/company_profile/'.$filename)); // } } }