Commit de38734c authored by Kittisak Maneewong's avatar Kittisak Maneewong

update

parent b2e43c83
...@@ -84,8 +84,12 @@ class CompanyController extends Controller ...@@ -84,8 +84,12 @@ class CompanyController extends Controller
*/ */
public function show($id) public function show($id)
{ {
$company = Company::where('user_id', $id)->first(); $exists = Company::where('user_id', $id)->exists();
return response()->json(['company' => $company]); if ($exists) {
return response()->json(['exists' => true, 'company' => Company::where('user_id', $id)->first()]);
} else {
return response()->json(['exists' => false, 'company' => User::where('id', $id)->first()]);
}
} }
/** /**
...@@ -113,28 +117,22 @@ class CompanyController extends Controller ...@@ -113,28 +117,22 @@ class CompanyController extends Controller
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
$imageCompany = null;
$imageMap = null;
$company = Company::find($id); $company = Company::find($id);
if ($request->get('imageCompany') !== $request->get('currentImageCompany')) { if ($request->get('imageCompany') !== $company->imageCompany) {
if ($request->get('imageCompany') !== 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png') { if ($request->get('imageCompany') !== 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png') {
$image = $request->get('imageCompany'); $image = $request->get('imageCompany');
$name = 'Company'.time().'.'.explode('/', explode(':', substr($image, 0, strpos($image, ';')))[1])[1]; $name = 'Company'.time().'.'.explode('/', explode(':', substr($image, 0, strpos($image, ';')))[1])[1];
\Image::make($request->get('imageCompany'))->save(public_path('uploads/').$name); \Image::make($request->get('imageCompany'))->save(public_path('uploads/').$name);
$imageCompany = '/uploads/'.$name; $company->imageCompany = '/uploads/'.$name;
} }
} else {
$imageCompany = $request->get('imageCompany');
} }
if ($request->get('imageMap') !== $request->get('currentImageMap')) { if ($request->get('imageMap') !== $company->imageMap) {
if ($request->get('imageMap')) { if ($request->get('imageMap')) {
$image = $request->get('imageMap'); $image = $request->get('imageMap');
$name = 'Map'.time().'.'.explode('/', explode(':', substr($image, 0, strpos($image, ';')))[1])[1]; $name = 'Map'.time().'.'.explode('/', explode(':', substr($image, 0, strpos($image, ';')))[1])[1];
\Image::make($request->get('imageMap'))->save(public_path('uploads/').$name); \Image::make($request->get('imageMap'))->save(public_path('uploads/').$name);
$imageMap = '/uploads/'.$name; $company->imageMap = '/uploads/'.$name;;
} }
} else {
$imageMap = $request->get('imageMap');
} }
$company->company_name = $request->get('company_name'); $company->company_name = $request->get('company_name');
$company->company_owner = $request->get('company_owner'); $company->company_owner = $request->get('company_owner');
...@@ -147,8 +145,6 @@ class CompanyController extends Controller ...@@ -147,8 +145,6 @@ class CompanyController extends Controller
$company->amphoe = $request->get('amphoe'); $company->amphoe = $request->get('amphoe');
$company->province = $request->get('province'); $company->province = $request->get('province');
$company->zipcode = $request->get('zip_code'); $company->zipcode = $request->get('zip_code');
$company->imageCompany = $imageCompany;
$company->imageMap = $imageMap;
$company->lat = $request->get('lat'); $company->lat = $request->get('lat');
$company->long = $request->get('lng'); $company->long = $request->get('lng');
$company->about = $request->get('about'); $company->about = $request->get('about');
......
...@@ -79,7 +79,9 @@ class JobController extends Controller ...@@ -79,7 +79,9 @@ class JobController extends Controller
*/ */
public function edit($id) public function edit($id)
{ {
// $job = Job::find($id);
$job->gender = explode(', ', $job->gender);
return response()->json(['job' => $job]);
} }
/** /**
...@@ -91,7 +93,27 @@ class JobController extends Controller ...@@ -91,7 +93,27 @@ class JobController extends Controller
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
// $gender = null;
if($request->get('gender')) {
$gender = implode(', ', $request->get('gender'));
}
$job = Job::find($id);
$job->job_title = $request->get('job_title');
$job->job_type = $request->get('job_type');
$job->department = $request->get('department');
$job->salary = $request->get('salary');
$job->branch = $request->get('branch');
$job->day = $request->get('day');
$job->time = $request->get('time');
$job->gender = $gender;
$job->num = $request->get('num');
$job->degree = $request->get('degree');
$job->gpax = $request->get('gpax');
$job->phase = $request->get('phase');
$job->feature = $request->get('feature');
$job->role = $request->get('role');
$job->welfare = $request->get('welfare');
$job->save();
} }
/** /**
...@@ -102,6 +124,7 @@ class JobController extends Controller ...@@ -102,6 +124,7 @@ class JobController extends Controller
*/ */
public function destroy($id) public function destroy($id)
{ {
// Job::destroy($id);
} }
} }
This diff is collapsed.
...@@ -17,6 +17,7 @@ import RegisterEmployer from './views/RegisterEmployer'; ...@@ -17,6 +17,7 @@ import RegisterEmployer from './views/RegisterEmployer';
import ManagejobEmployer from './views/managejob.vue'; import ManagejobEmployer from './views/managejob.vue';
import ConfigCompany from './views/ConfigCompany.vue'; import ConfigCompany from './views/ConfigCompany.vue';
import CreateJob from './views/CreateJob.vue'; import CreateJob from './views/CreateJob.vue';
import EditJob from './views/EditJob.vue';
import ShowJob from './views/ShowJob.vue'; import ShowJob from './views/ShowJob.vue';
const router = new VueRouter({ const router = new VueRouter({
...@@ -73,6 +74,11 @@ const router = new VueRouter({ ...@@ -73,6 +74,11 @@ const router = new VueRouter({
configProfile: true configProfile: true
} }
}, },
{
path: 'editjob/:id',
name: 'editJob',
component: EditJob
},
{ {
path: 'configcompany', path: 'configcompany',
name: 'configcompany', name: 'configcompany',
......
...@@ -246,8 +246,6 @@ export default { ...@@ -246,8 +246,6 @@ export default {
status: 'ยังไม่ได้เลือกไฟล์', status: 'ยังไม่ได้เลือกไฟล์',
nameImage: null, nameImage: null,
company_data: { company_data: {
currentImageCompany: null,
currentImageMap: null,
exists: false, exists: false,
user_id: null, user_id: null,
imageCompany: 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png', imageCompany: 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png',
...@@ -519,8 +517,6 @@ export default { ...@@ -519,8 +517,6 @@ export default {
console.log(res) console.log(res)
const data = res.data.company const data = res.data.company
if (res.data.exists) { if (res.data.exists) {
this.company_data.currentImageCompany = data.imageCompany
this.company_data.currentImageMap = data.imageMap
this.company_data.exists = res.data.exists this.company_data.exists = res.data.exists
this.company_data.about = data.about this.company_data.about = data.about
this.company_data.addr = data.addr this.company_data.addr = data.addr
......
<template> <template>
<div class=""> <div class="">
<v-form @submit.prevent="createJob()" ref="job">
<v-layout row wrap justify-center > <v-layout row wrap justify-center >
<v-form @submit.prevent="createJob()" ref="job">
<v-flex xs12 sm10 offset-sm-1 class="ma-2"> <v-flex xs12 sm10 offset-sm-1 class="ma-2">
<v-flex class="bg-title pa-2"> <v-flex class="bg-title pa-2">
<v-layout row wrap align-center> <v-layout row wrap align-center>
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
<v-flex class="bg-body pa-4"> <v-flex class="bg-body pa-4">
<v-layout row wrap> <v-layout row wrap>
<v-flex xs12 sm6 class="px-3"> <v-flex xs12 sm6 class="px-3">
<v-combobox <v-select
v-model="job_data.gender" v-model="job_data.gender"
:items="items" :items="items"
label="เพศ" label="เพศ"
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
{{ data.item }} {{ data.item }}
</v-chip> </v-chip>
</template> </template>
</v-combobox> </v-select>
<v-select <v-select
label="ระดับการศึกษา" label="ระดับการศึกษา"
v-model="job_data.degree" v-model="job_data.degree"
...@@ -176,8 +176,8 @@ ...@@ -176,8 +176,8 @@
</v-flex> </v-flex>
</v-flex> </v-flex>
<v-flex xs12 sm10 offset-sm-1 class="my-1 text-xs-center text-sm-center."><v-btn type="submit" round dark color="blue accent-3" class="px-3 white--text">เพิ่มข้อมูลงาน</v-btn></v-flex> <v-flex xs12 sm10 offset-sm-1 class="my-1 text-xs-center text-sm-center."><v-btn type="submit" round dark color="blue accent-3" class="px-3 white--text">เพิ่มข้อมูลงาน</v-btn></v-flex>
</v-form>
</v-layout> </v-layout>
</v-form>
</div> </div>
</template> </template>
......
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
ยินดีต้อนรับ ยินดีต้อนรับ
</v-flex> </v-flex>
<v-flex xs12 sm12 class="font-weight-bold black--text subheading"> <v-flex xs12 sm12 class="font-weight-bold black--text subheading">
ake8225 {{user}}
</v-flex> </v-flex>
</v-flex> </v-flex>
<v-flex xs12 sm6> <v-flex xs12 sm6>
...@@ -121,6 +121,7 @@ ...@@ -121,6 +121,7 @@
export default { export default {
data () { data () {
return { return {
user: null,
companies: { companies: {
about: null, about: null,
addr: null, addr: null,
...@@ -161,9 +162,17 @@ export default { ...@@ -161,9 +162,17 @@ export default {
beforeMount() { beforeMount() {
this.$store.dispatch('checkEmployer') this.$store.dispatch('checkEmployer')
.then(res => { .then(res => {
this.user = res.username
axios.get(`/api/companys/${res.id}`) axios.get(`/api/companys/${res.id}`)
.then(res => { .then(res => {
this.companies = res.data.company console.log(res)
if (res.data.exists) {
this.companies = res.data.company
} else {
this.companies.phone_no = res.data.company.tel
this.companies.email = res.data.company.email_employers
this.companies.company_name = res.data.company.company_name
}
if (!this.companies.imageCompany) { if (!this.companies.imageCompany) {
this.companies.imageCompany = 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png' this.companies.imageCompany = 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png'
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<v-text-field <v-text-field
v-model="search" v-model="search"
append-icon="search" append-icon="search"
label="Search" label="ค้นหา"
single-line single-line
hide-details hide-details
></v-text-field> ></v-text-field>
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
:items="items" :items="items"
class="elevation-1" class="elevation-1"
:search="search" :search="search"
rows-per-page-text="จำนวนเเถวต่อหน้า"
no-results-text="ไม่พบข้อมูล"
no-data-text="ไม่มีข้อมูล"
> >
<template v-slot:items="props"> <template v-slot:items="props">
<td width="10%" class="text-sm-center">{{ props.item.id }}</td> <td width="10%" class="text-sm-center">{{ props.item.id }}</td>
...@@ -25,12 +28,15 @@ ...@@ -25,12 +28,15 @@
<td width="15%" class="text-sm-center">{{ props.item.position }}</td> <td width="15%" class="text-sm-center">{{ props.item.position }}</td>
<td width="10%" class="text-sm-center">{{ props.item.salary }}</td> <td width="10%" class="text-sm-center">{{ props.item.salary }}</td>
<td width="20%" class="text-sm-center"> <td width="20%" class="text-sm-center">
<v-btn depressed class="mx-1" fab outline small color="cyan"> <v-layout row wrap justify-center>
<v-btn depressed class="mx-1" fab outline small color="cyan" @click="$router.push(`/employer/editjob/${props.item.job_id}`)">
<v-icon>edit</v-icon> <v-icon>edit</v-icon>
</v-btn> </v-btn>
<v-btn depressed class="mx-1" fab outline small color="red"> <v-btn depressed class="mx-1" fab outline small color="red" @click="deleteJob(props.item.job_id)">
<v-icon>delete</v-icon> <v-icon>delete</v-icon>
</v-btn> </v-btn>
</v-layout>
</td> </td>
</template> </template>
</v-data-table> </v-data-table>
...@@ -53,12 +59,21 @@ export default { ...@@ -53,12 +59,21 @@ export default {
items: [] items: []
} }
}, },
beforeMount () { methods: {
this.$store.dispatch('checkEmployer') deleteJob(id) {
axios.delete(`/api/jobs/${id}`)
.then(res => {
this.getData()
})
.catch(err => {console.log(err.response)})
},
getData () {
this.$store.dispatch('checkEmployer')
.then(res => { .then(res => {
axios.get(`/api/jobs/${res.id}`) axios.get(`/api/jobs/${res.id}`)
.then(res => { .then(res => {
console.log(res) console.log(res)
this.items = []
const jobs = res.data.jobs const jobs = res.data.jobs
for (let i = 0; i < jobs.length; i++) { for (let i = 0; i < jobs.length; i++) {
this.items.push({ this.items.push({
...@@ -76,6 +91,10 @@ export default { ...@@ -76,6 +91,10 @@ export default {
}) })
}) })
.catch(err => {console.log(err.response)}) .catch(err => {console.log(err.response)})
}
},
beforeMount () {
this.getData()
} }
} }
</script> </script>
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