mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 04:24:01 +00:00
added file upload for both company profile picture and registration certificate
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Company;
|
||||
use Image;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class CompanyController extends Controller
|
||||
{
|
||||
@@ -50,21 +51,65 @@ class CompanyController extends Controller
|
||||
// return response()->json(['message'=>'Document not found']);
|
||||
// }
|
||||
$input = $request->all();
|
||||
if($file = $request->file('company_profile'))
|
||||
|
||||
//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
|
||||
{
|
||||
$name = $file->getClientOriginalName();
|
||||
$img_file = $request->file('company_profile');
|
||||
$company_profile = $request->file('company_profile');
|
||||
$filename = $company_profile->getClientOriginalName();
|
||||
//$destinationPath = config('app.fileDestinationPath').'/'.$filename;
|
||||
|
||||
Image::make($img_file)->resize(300,300)->save(public_path('uploads\company_profile\hello.jpg'));
|
||||
return $img_file;
|
||||
// $file->move('uploads/company_profile/', $img_file);
|
||||
$file = $request->file('company_profile');
|
||||
$ext = $file->getClientOriginalExtension();
|
||||
|
||||
$input['company_profile'] = $name;
|
||||
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('/');
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,12 +148,34 @@ class CompanyController extends Controller
|
||||
{
|
||||
return response()->json(['message'=>'Document not found'],200);
|
||||
}
|
||||
//$warehouse->address='juhgfd';
|
||||
if($request->hasFile('avatar'))
|
||||
//updating company profile picture
|
||||
if($file = $request->file('company_profile')) //company profile picture
|
||||
{
|
||||
$avatar = $request->file('avatar');
|
||||
$filename = time() . '.' . $avatar->getClientOriginalExtension();
|
||||
Image::make($avatar)->resize(300,300)->save(public_path('/uploads/company_profile/'.$filename));
|
||||
$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');
|
||||
|
||||
Reference in New Issue
Block a user