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 source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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-form @submit.prevent="createJob()" ref="job">
<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 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>
......
<template>
<div class="">
<v-form @submit.prevent="editJob()" 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>
<div class="mx-3">
<v-icon x-large dark>fas fa-briefcase</v-icon>
</div>
<div class="pa-0">
<v-flex xs12 sm12>
<span class="font-title font-weight-bold">ข้อมูลรายละเอียดของงาน</span>
</v-flex>
<v-flex xs12 sm12>
<span class="font-subtitle ">(Job description information)</span>
</v-flex>
</div>
</v-layout>
</v-flex>
<v-flex class="bg-body pa-4">
<v-layout row wrap>
<v-flex xs12 sm6 class="px-3">
<v-text-field
label="หัวข้องาน"
v-model="job_data.job_title"
:rules="[v => !!v || 'จำเป็นต้องกรอก']"
placeholder=" "
></v-text-field>
<v-combobox
v-model="job_data.job_type"
:items="items"
:rules="[v => !!v || 'จำเป็นต้องกรอก']"
label="ประเภทงาน"
placeholder=" "
>
<template v-slot:selection="data">
<v-chip
:key="JSON.stringify(data.item)"
:selected="data.selected"
:disabled="data.disabled"
class="v-chip--select-multi"
@click.stop="data.parent.selectedIndex = data.index"
@input="data.parent.selectItem(data.item)"
>
<v-avatar class="accent white--text">
{{ data.item.slice(0, 1).toUpperCase() }}
</v-avatar>
{{ data.item }}
</v-chip>
</template>
</v-combobox>
<v-text-field
label="ตำแหน่งงาน "
v-model="job_data.department"
:rules="[v => !!v || 'จำเป็นต้องกรอก']"
placeholder=" "
></v-text-field>
<v-text-field
label="ค่าตอบแทน/เงินเดือน "
v-model="job_data.salary"
placeholder=" "
></v-text-field>
</v-flex>
<v-flex xs12 sm6 class="px-3">
<v-text-field
label="สาขาวิชาที่เปิดรับ "
v-model="job_data.branch"
placeholder=" "
></v-text-field>
<v-text-field
label="วันทำงาน "
v-model="job_data.day"
placeholder=" "
></v-text-field>
<v-text-field
label="เวลาทำงาน "
v-model="job_data.time"
placeholder=" "
></v-text-field>
<v-text-field
label="จำนวนที่รับ "
v-model="job_data.num"
placeholder=" "
type="number"
></v-text-field>
</v-flex>
</v-layout>
</v-flex>
</v-flex>
<v-flex xs12 sm10 offset-sm-1 class="ma-2">
<v-flex class="bg-title-1 pa-2">
<v-layout row wrap align-center>
<div class="mx-3">
<v-icon x-large dark>fas fa-user-circle</v-icon>
</div>
<div class="pa-0">
<v-flex xs12 sm12>
<span class="font-title font-weight-bold">คุณสมบัติของผู้สมัครงาน</span>
</v-flex>
<v-flex xs12 sm12>
<span class="font-subtitle ">(Job applicant qualifications)</span>
</v-flex>
</div>
</v-layout>
</v-flex>
<v-flex class="bg-body pa-4">
<v-layout row wrap>
<v-flex xs12 sm6 class="px-3">
<v-select
v-model="job_data.gender"
:items="items"
label="เพศ"
placeholder=" "
multiple
>
<template v-slot:selection="data">
<v-chip
:key="JSON.stringify(data.item)"
:selected="data.selected"
:disabled="data.disabled"
class="v-chip--select-multi"
@input="data.parent.selectItem(data.item)"
>
<v-avatar
class="accent white--text"
v-text="data.item.slice(0, 1).toUpperCase()"
></v-avatar>
{{ data.item }}
</v-chip>
</template>
</v-select>
<v-select
label="ระดับการศึกษา"
v-model="job_data.degree"
placeholder=" "
item-value="text"
></v-select>
<v-text-field
label="เกรดเฉลี่ย "
v-model="job_data.gpax"
placeholder=" "
></v-text-field>
<v-text-field
label="ระยะเวลาในการทำงาน "
v-model="job_data.phase"
placeholder=" "
></v-text-field>
<v-textarea
label="คุณสมบัติเพิ่มเติม"
v-model="job_data.feature"
rows="3"
outline
placeholder=" "
></v-textarea>
</v-flex>
<v-flex xs12 sm6 class="px-3">
<v-textarea
outline
label="หน้าที่รับผิดชอบ"
v-model="job_data.role"
placeholder=" "
rows="7"
></v-textarea>
<v-textarea
outline
label="สวัสดิการ"
v-model="job_data.welfare"
placeholder=" "
rows="7"
></v-textarea>
</v-flex>
</v-layout>
</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-layout>
</v-form>
</div>
</template>
<script>
export default {
data () {
return {
gender: [],
items: [
'ชาย',
'หญิง'
],
job_data: {
id: null,
job_title: '',
job_type: '',
department: '',
salary: '',
branch: '',
day: '',
time: '',
num: '',
gender: '',
degree: '',
gpax: '',
phase: '',
feature: '',
role: '',
welfare: ''
}
}
},
methods: {
editJob () {
if (this.$refs.job.validate()) {
axios.put(`/api/jobs/${this.job_data.id}`, this.job_data)
.then(res => {
this.$router.push('/employer/managejob');
})
.catch(err => {console.log(err.response)})
} else {
this.$Loading.error()
}
}
},
beforeMount () {
this.job_data.id = this.$route.params.id
axios.get(`/api/jobs/${this.job_data.id}/edit`)
.then(res => {
this.job_data.job_title = res.data.job.job_title
this.job_data.job_type = res.data.job.job_type
this.job_data.department = res.data.job.department
this.job_data.salary = res.data.job.salary
this.job_data.branch = res.data.job.branch
this.job_data.day = res.data.job.day
this.job_data.time = res.data.job.time
this.job_data.num = res.data.job.num
this.job_data.gender = res.data.job.gender
this.job_data.degree = res.data.job.degree
this.job_data.gpax = res.data.job.gpax
this.job_data.phase = res.data.job.phase
this.job_data.feature = res.data.job.feature
this.job_data.role = res.data.job.role
this.job_data.welfare = res.data.job.welfare
console.log(res)
})
.catch(err => {console.log(err.response)})
}
}
</script>
<style lang="scss" scoped>
.bg-title{
background-color: #00AAFF;
border-radius: 8px 8px 0 0;
display: block;
}
.bg-body{
background-color: #fff;
border-radius:0 0 8px 8px;
border-bottom:1px solid #dcdcdc ;
border-left:1px solid #dcdcdc ;
border-right:1px solid #dcdcdc ;
}
.bg-title-1{
background-color: #89969f;
border-radius: 8px 8px 0 0;
}
.font-title {
font-size: 20px;
color: #fff;
display: block;
font-family: "Prompt", sans-serif;
}
.font-subtitle {
font-size: 16px;
color: #2d3f4b;
display: block;
font-family: "Prompt", sans-serif;
}
</style>
......@@ -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 => {
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) {
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 () {
this.$store.dispatch('checkEmployer')
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({
......@@ -76,6 +91,10 @@ 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