Commit de38734c authored by Kittisak Maneewong's avatar Kittisak Maneewong

update

parent b2e43c83
......@@ -84,8 +84,12 @@ class CompanyController extends Controller
*/
public function show($id)
{
$company = Company::where('user_id', $id)->first();
return response()->json(['company' => $company]);
$exists = Company::where('user_id', $id)->exists();
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
*/
public function update(Request $request, $id)
{
$imageCompany = null;
$imageMap = null;
$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') {
$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;
$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')) {
$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;
$company->imageMap = '/uploads/'.$name;;
}
} else {
$imageMap = $request->get('imageMap');
}
$company->company_name = $request->get('company_name');
$company->company_owner = $request->get('company_owner');
......@@ -147,8 +145,6 @@ class CompanyController extends Controller
$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');
......
......@@ -79,7 +79,9 @@ class JobController extends Controller
*/
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
*/
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
*/
public function destroy($id)
{
//
Job::destroy($id);
}
}
This diff is collapsed.
......@@ -17,6 +17,7 @@ import RegisterEmployer from './views/RegisterEmployer';
import ManagejobEmployer from './views/managejob.vue';
import ConfigCompany from './views/ConfigCompany.vue';
import CreateJob from './views/CreateJob.vue';
import EditJob from './views/EditJob.vue';
import ShowJob from './views/ShowJob.vue';
const router = new VueRouter({
......@@ -73,6 +74,11 @@ const router = new VueRouter({
configProfile: true
}
},
{
path: 'editjob/:id',
name: 'editJob',
component: EditJob
},
{
path: 'configcompany',
name: 'configcompany',
......
......@@ -246,8 +246,6 @@ export default {
status: 'ยังไม่ได้เลือกไฟล์',
nameImage: null,
company_data: {
currentImageCompany: null,
currentImageMap: null,
exists: false,
user_id: null,
imageCompany: 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png',
......@@ -519,8 +517,6 @@ export default {
console.log(res)
const data = res.data.company
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.about = data.about
this.company_data.addr = data.addr
......
<template>
<div class="">
<v-layout row wrap justify-center >
<v-form @submit.prevent="createJob()" ref="job">
<v-layout row wrap justify-center >
<v-flex xs12 sm10 offset-sm-1 class="ma-2">
<v-flex class="bg-title pa-2">
<v-layout row wrap align-center>
......@@ -109,7 +109,7 @@
<v-flex class="bg-body pa-4">
<v-layout row wrap>
<v-flex xs12 sm6 class="px-3">
<v-combobox
<v-select
v-model="job_data.gender"
:items="items"
label="เพศ"
......@@ -131,7 +131,7 @@
{{ data.item }}
</v-chip>
</template>
</v-combobox>
</v-select>
<v-select
label="ระดับการศึกษา"
v-model="job_data.degree"
......@@ -176,8 +176,8 @@
</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-form>
</v-layout>
</v-form>
</div>
</template>
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
ยินดีต้อนรับ
</v-flex>
<v-flex xs12 sm12 class="font-weight-bold black--text subheading">
ake8225
{{user}}
</v-flex>
</v-flex>
<v-flex xs12 sm6>
......@@ -121,6 +121,7 @@
export default {
data () {
return {
user: null,
companies: {
about: null,
addr: null,
......@@ -161,9 +162,17 @@ export default {
beforeMount() {
this.$store.dispatch('checkEmployer')
.then(res => {
this.user = res.username
axios.get(`/api/companys/${res.id}`)
.then(res => {
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) {
this.companies.imageCompany = 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png'
}
......
......@@ -6,7 +6,7 @@
<v-text-field
v-model="search"
append-icon="search"
label="Search"
label="ค้นหา"
single-line
hide-details
></v-text-field>
......@@ -17,6 +17,9 @@
:items="items"
class="elevation-1"
:search="search"
rows-per-page-text="จำนวนเเถวต่อหน้า"
no-results-text="ไม่พบข้อมูล"
no-data-text="ไม่มีข้อมูล"
>
<template v-slot:items="props">
<td width="10%" class="text-sm-center">{{ props.item.id }}</td>
......@@ -25,12 +28,15 @@
<td width="15%" class="text-sm-center">{{ props.item.position }}</td>
<td width="10%" class="text-sm-center">{{ props.item.salary }}</td>
<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-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-btn>
</v-layout>
</td>
</template>
</v-data-table>
......@@ -53,12 +59,21 @@ export default {
items: []
}
},
beforeMount () {
methods: {
deleteJob(id) {
axios.delete(`/api/jobs/${id}`)
.then(res => {
this.getData()
})
.catch(err => {console.log(err.response)})
},
getData () {
this.$store.dispatch('checkEmployer')
.then(res => {
axios.get(`/api/jobs/${res.id}`)
.then(res => {
console.log(res)
this.items = []
const jobs = res.data.jobs
for (let i = 0; i < jobs.length; i++) {
this.items.push({
......@@ -77,5 +92,9 @@ export default {
})
.catch(err => {console.log(err.response)})
}
},
beforeMount () {
this.getData()
}
}
</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