Commit 9526419d authored by Kittisak Maneewong's avatar Kittisak Maneewong

update company

parent 3ee5840a
......@@ -14,12 +14,6 @@ class CompanyController extends Controller
* @return \Illuminate\Http\Response
*/
public function check($id)
{
$exists = Company::where('user_id', $id)->exists();
return response()->json(['exists' => $exists]);
}
public function index()
{
}
......@@ -119,7 +113,51 @@ class CompanyController extends Controller
*/
public function update(Request $request, $id)
{
return response()->json(['data' => $request->all()]);
$imageCompany = null;
$imageMap = null;
$company = Company::find($id);
if ($request->get('imageCompany') !== $request->get('currentImageCompany')) {
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(public_path('uploads/').$name);
$imageCompany = '/uploads/'.$name;
}
} else {
$imageCompany = $request->get('imageCompany');
}
if ($request->get('imageMap') !== $request->get('currentImageMap')) {
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(public_path('uploads/').$name);
$imageMap = '/uploads/'.$name;
}
} else {
$imageMap = $request->get('imageMap');
}
$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->imageCompany = $imageCompany;
$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->save();
}
/**
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -418,7 +418,16 @@ export default {
this.company_data.amphoe = this.amphoe.amphoe
this.company_data.tumbon = this.tumbon.tumbon
if (this.company_data.exists) {
console.log('true')
axios.put(`/api/companys/${this.company_data.user_id}`, this.company_data)
.then(res => {
this.$router.push('/employer')
this.loading = false
console.log(res)
})
.catch(err => {
this.loading = false
console.log(err.response)
})
} else {
console.log(false)
axios.post('/api/companys', this.company_data)
......@@ -510,8 +519,8 @@ export default {
console.log(res)
const data = res.data.company
if (res.data.exists) {
this.company_data.currentImageCompany = res.data.imageCompany
this.company_data.currentImageMap = res.data.imageMap
this.company_data.currentImageCompany = data.imageCompany
this.company_data.currentImageMap = data.imageMap
this.company_data.exists = res.data.exists
this.company_data.about = data.about
this.company_data.addr = data.addr
......@@ -530,7 +539,7 @@ export default {
this.company_data.mrt = data.mrt
this.company_data.phone_no = data.phone_no
this.company_data.website = data.website
this.company_data.user_id = data.user_id
this.company_data.user_id = data.id
if (this.company_data.lat) {
this.place = '_';
}
......
......@@ -106,7 +106,7 @@
<label class="caption"><v-icon small>print</v-icon> แฟกซ์. : {{ companies.fax ? companies.fax : ' - ' }}</label>
</v-flex>
<v-flex xs12 sm12>
<v-btn small depressed dark color="red" @click="$router.push('/employer/editcompany')">
<v-btn small depressed dark color="red" @click="$router.push('/employer/configcompany')">
<v-icon dark >settings</v-icon> แก้ไขข้อมูล
</v-btn>
</v-flex>
......
......@@ -20,7 +20,6 @@ Route::group(['prefix' => 'auth'], function ($router) {
});
Route::resource('/companys', 'CompanyController');
Route::get('/companys/{company}/check', 'CompanyController@check')->name('companys.check');
Route::get('/province','DistrictController@provinces');
Route::get('/province/{province_code}/amphoe','DistrictController@amphoes');
......
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