Commit 99d3f00d authored by Kittisak Maneewong's avatar Kittisak Maneewong

add company

parent e50609f8
...@@ -35,14 +35,44 @@ class CompanyController extends Controller ...@@ -35,14 +35,44 @@ class CompanyController extends Controller
*/ */
public function store(Request $request) public function store(Request $request)
{ {
$image = $request->get('image'); $imageCompany = null;
$name = time().'.'.explode('/', explode(':', substr($image, 0, strpos($image, ';')))[1])[1]; $imageMap = null;
\Image::make($request->get('image'))->save(storage_path('uploads/').$name); if ($request->get('imageCompany') !== 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png') {
$image = $request->get('imageCompany');
$name = 'Company'.time().'.'.explode('/', explode(':', substr($image, 0, strpos($image, ';')))[1])[1];
\Image::make($request->get('imageCompany'))->save(storage_path('uploads/').$name);
$imageCompany = $name;
}
if ($request->get('imageMap')) {
$image = $request->get('imageMap');
$name = 'Map'.time().'.'.explode('/', explode(':', substr($image, 0, strpos($image, ';')))[1])[1];
\Image::make($request->get('imageMap'))->save(storage_path('uploads/').$name);
$imageMap = $name;
}
$company = new Company(); $company = new Company();
$company->imageCompany = 'Company'.$name; $company->imageCompany = $imageCompany;
$company->company_name = $request->get('company_name');
$company->company_owner = $request->get('company_owner');
$company->phone_no = $request->get('phone_no');
$company->email = $request->get('email');
$company->fax = $request->get('fax');
$company->website = $request->get('website');
$company->addr = $request->get('addr');
$company->tambon = $request->get('tumbon');
$company->amphoe = $request->get('amphoe');
$company->province = $request->get('province');
$company->zipcode = $request->get('zip_code');
$company->imageMap = $imageMap;
$company->lat = $request->get('lat');
$company->long = $request->get('lng');
$company->about = $request->get('about');
$company->bts = $request->get('bts');
$company->mrt = $request->get('mrt');
$company->arl = $request->get('arl');
$company->bus = $request->get('bus');
$company->another = $request->get('another');
$company->user_id = $request->get('user_id');
$company->save(); $company->save();
return response()->json(['success' => 'You have successfully uploaded an image'], 200);
} }
/** /**
......
This diff is collapsed.
...@@ -12,6 +12,7 @@ export default new Vuex.Store({ ...@@ -12,6 +12,7 @@ export default new Vuex.Store({
email: null email: null
}, },
employer: { employer: {
id: null,
username: null, username: null,
company_name: null, company_name: null,
email: null email: null
...@@ -203,6 +204,7 @@ export default new Vuex.Store({ ...@@ -203,6 +204,7 @@ export default new Vuex.Store({
}) })
.then(res => { .then(res => {
commit('setEmployer', { commit('setEmployer', {
id: res.data.user.id,
username: res.data.user.username, username: res.data.user.username,
company_name: res.data.user.company_name, company_name: res.data.user.company_name,
email: res.data.user.email_employers email: res.data.user.email_employers
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment