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 source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -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
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
<v-tooltip right> <v-tooltip right>
<template v-slot:activator="{ on }"> <template v-slot:activator="{ on }">
<v-layout column align-center> <v-layout column align-center>
<img v-on="on" class="img" @click="$refs.inputFile.click()" :src="srcImage" alt="" width="200"> <img v-on="on" class="img" @click="$refs.inputFile.click()" :src="company_data.imageCompany" alt="" width="200">
<v-btn color="error" v-if="srcImage !== 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png'" @click="srcImage = 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png'">ลบรูปภาพ</v-btn> <v-btn color="error" v-if="company_data.imageCompany !== 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png'" @click="company_data.imageCompany = 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png';status = 'ยังไม่ได้เลือกไฟล์'">ลบรูปภาพ</v-btn>
</v-layout> </v-layout>
</template> </template>
<span>{{ status }}</span> <span>{{ status }}</span>
...@@ -28,14 +28,14 @@ ...@@ -28,14 +28,14 @@
outline outline
label="ชื่อบริษัท" label="ชื่อบริษัท"
:rules="[rules.required]" :rules="[rules.required]"
v-model="company_name" v-model="company_data.company_name"
class="my-ip" class="my-ip"
></v-text-field> ></v-text-field>
<label class="font-weight-bold">ชื่อผู้ติดต่อ <span class="red--text">&nbsp;*</span></label> <label class="font-weight-bold">ชื่อผู้ติดต่อ <span class="red--text">&nbsp;*</span></label>
<v-text-field <v-text-field
outline outline
label="ชื่อผู้ติดต่อ" label="ชื่อผู้ติดต่อ"
v-model="company_owner" v-model="company_data.company_owner"
:rules="[rules.required]" :rules="[rules.required]"
class="my-ip" class="my-ip"
></v-text-field> ></v-text-field>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<v-text-field <v-text-field
outline outline
label="เบอร์ผู้ติดต่อ" label="เบอร์ผู้ติดต่อ"
v-model="phone_no" v-model="company_data.phone_no"
:rules="[rules.required]" :rules="[rules.required]"
class="my-ip" class="my-ip"
></v-text-field> ></v-text-field>
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<v-text-field <v-text-field
outline outline
label="อีเมล" label="อีเมล"
v-model="email" v-model="company_data.email"
:rules="[rules.required, rules.email]" :rules="[rules.required, rules.email]"
class="my-ip" class="my-ip"
></v-text-field> ></v-text-field>
...@@ -62,14 +62,14 @@ ...@@ -62,14 +62,14 @@
outline outline
label="Fax" label="Fax"
class="my-ip" class="my-ip"
v-model="fax" v-model="company_data.fax"
></v-text-field> ></v-text-field>
<label class="font-weight-bold">เว็บไซต์ <span class="red--text"></span></label> <label class="font-weight-bold">เว็บไซต์ <span class="red--text"></span></label>
<v-text-field <v-text-field
outline outline
label="เว็บไซต์" label="เว็บไซต์"
class="my-ip" class="my-ip"
v-model="website" v-model="company_data.website"
></v-text-field> ></v-text-field>
</v-flex> </v-flex>
</v-layout> </v-layout>
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
outline outline
label="ที่อยู่" label="ที่อยู่"
:rules="[rules.required]" :rules="[rules.required]"
v-model="addr" v-model="company_data.addr"
class="my-1" class="my-1"
></v-textarea> ></v-textarea>
<label class="font-weight-bold">จังหวัด <span class="red--text">&nbsp;*</span></label> <label class="font-weight-bold">จังหวัด <span class="red--text">&nbsp;*</span></label>
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
outline outline
label="เกี่ยวกับบริษัท" label="เกี่ยวกับบริษัท"
class="my-1" class="my-1"
v-model="about" v-model="company_data.about"
></v-textarea> ></v-textarea>
</v-flex> </v-flex>
<v-flex sm6 xs12 class="px-3"> <v-flex sm6 xs12 class="px-3">
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
<v-text-field <v-text-field
:disabled="!openZipCode" :disabled="!openZipCode"
label="รหัสไปรษณีย์" label="รหัสไปรษณีย์"
v-model="zip_code" v-model="company_data.zip_code"
:rules="[rules.required]" :rules="[rules.required]"
class="my-ip" class="my-ip"
></v-text-field> ></v-text-field>
...@@ -148,22 +148,29 @@ ...@@ -148,22 +148,29 @@
<v-flex sm12 xs12> <v-flex sm12 xs12>
<input type="file" accept="image/*" class="input-file" ref="inputFileMap" @change="selectFileMap"> <input type="file" accept="image/*" class="input-file" ref="inputFileMap" @change="selectFileMap">
<v-btn color="deep-orange darken-4" class="px-2" small outline @click="$refs.inputFileMap.click()"><v-icon>file_copy</v-icon>&nbsp;เลือกไฟล์</v-btn> <v-btn color="deep-orange darken-4" class="px-2" small outline @click="$refs.inputFileMap.click()"><v-icon>file_copy</v-icon>&nbsp;เลือกไฟล์</v-btn>
<v-btn color="error" v-if="srcImageMap" @click="srcImageMap = null">ลบรูปภาพ</v-btn>
{{ nameImage }} {{ nameImage }}
<v-btn v-if="nameImage" flat icon color="error" @click="nameImage = null; company_data.imageMap = null">
<v-icon>close</v-icon>
</v-btn>
</v-flex> </v-flex>
<v-flex sm12 xs12> <v-flex sm12 xs12>
<GmapAutocomplete class="form-control form-control-sm my-1" placeholder="ป้อนตำแหน่งใกล้เคียง" @place_changed="setPlace"> <GmapAutocomplete class="form-control form-control-sm my-1" placeholder="ป้อนตำแหน่งใกล้เคียง" @place_changed="setPlace">
</GmapAutocomplete> </GmapAutocomplete>
</v-flex> </v-flex>
<v-flex sm12 xs12> <v-flex sm12 xs12>
<GmapMap v-if="this.place" style="width: 400px; height: 200px;" :zoom="15" :center="{lat: lat, lng: long}"> <GmapMap v-if="this.place" style="width: 100%; height: 200px;" :zoom="15" :center="{lat: company_data.lat, lng: company_data.lng}">
<GmapMarker <GmapMarker
:position="{lat: lat, lng: long}" :position="{lat: company_data.lat, lng: company_data.lng}"
:draggable="true" :draggable="true"
@dragend="dragMarker" @dragend="dragMarker"
/> />
</GmapMap> </GmapMap>
</v-flex> </v-flex>
<v-flex sm12 xs12>
<p class="text-xs-center" v-if="this.place"><v-btn color="error" @click="place = null;company_data.lat = null;company_data.lng = null">
ลบเเผนที่
</v-btn></p>
</v-flex>
</v-layout> </v-layout>
</v-flex> </v-flex>
...@@ -178,7 +185,7 @@ ...@@ -178,7 +185,7 @@
<v-select <v-select
label="เลือก" label="เลือก"
:items="bts" :items="bts"
v-model="bts" v-model="company_data.bts"
></v-select> ></v-select>
</v-flex> </v-flex>
<v-flex sm3 xs12 class="px-3"> <v-flex sm3 xs12 class="px-3">
...@@ -186,7 +193,7 @@ ...@@ -186,7 +193,7 @@
<v-select <v-select
label="เลือก" label="เลือก"
:items="mrt" :items="mrt"
v-model="mrt" v-model="company_data.mrt"
></v-select> ></v-select>
</v-flex> </v-flex>
<v-flex sm3 xs12 class="px-3"> <v-flex sm3 xs12 class="px-3">
...@@ -194,14 +201,14 @@ ...@@ -194,14 +201,14 @@
<v-select <v-select
label="เลือก" label="เลือก"
:items="arl" :items="arl"
v-model="arl" v-model="company_data.arl"
></v-select> ></v-select>
</v-flex> </v-flex>
<v-flex sm3 xs12 class="px-3"> <v-flex sm3 xs12 class="px-3">
<label class="font-weight-bold">สายรถเมล์</label> <label class="font-weight-bold">สายรถเมล์</label>
<VTextField <VTextField
label="สายรถเมล์" label="สายรถเมล์"
v-model="bus" v-model="company_data.bus"
></VTextField> ></VTextField>
</v-flex> </v-flex>
<v-flex sm12 class="px-3"> <v-flex sm12 class="px-3">
...@@ -212,7 +219,7 @@ ...@@ -212,7 +219,7 @@
outline outline
label="" label=""
class="my-2" class="my-2"
v-model="another" v-model="company_data.another"
></v-textarea> ></v-textarea>
</v-flex> </v-flex>
<v-flex sm6 xs12 class="px-3 py-3 detail"> <v-flex sm6 xs12 class="px-3 py-3 detail">
...@@ -223,164 +230,6 @@ ...@@ -223,164 +230,6 @@
<v-btn color="red" dark="" type="submit">บันทึกข้อมูล</v-btn> <v-btn color="red" dark="" type="submit">บันทึกข้อมูล</v-btn>
</v-layout> </v-layout>
</v-layout> </v-layout>
<!-- <v-layout row wrap class="borderbottom">
<v-flex sm6 xs12 class="pa-3">
<h2 class="font-weight-bold my-2"><span class="red--text">&nbsp;รายละเอียดงาน</span></h2>
<v-flex sm12 xs12 class="pa-3">
<label class="font-weight-bold">หัวข้องาน <span class="red--text">&nbsp;*</span></label>
<v-text-field
outline
label="หัวข้องาน"
:rules="[rules.required]"
class="my-job"
></v-text-field>
<label class="font-weight-bold my-2">ประเภทธุรกิจ <span class="red--text">&nbsp;*</span></label>
<VSelect
outline
:items="items"
:rules="[rules.required]"
label="เลือก"
class="my-job"
></VSelect>
<label class="font-weight-bold my-2">ตำแหน่งงาน <span class="red--text">&nbsp;*</span></label>
<VSelect
outline
:items="items"
:rules="[rules.required]"
label="เลือก"
class="my-job"
></VSelect>
<label class="font-weight-bold my-2">ค่าตอบแทน/เงินเดือน</label>
<v-text-field
outline
label="ค่าตอบแทน/เงินเดือน"
class="my-job"
></v-text-field>
<label class="font-weight-bold my-2">จำนวน(อัตรา) <span class="red--text">&nbsp;*</span></label>
<v-text-field
outline
label="จำนวน(อัตรา)"
class="my-job"
:rules="[rules.required]"
min="0"
type="number"
></v-text-field>
<label class="font-weight-bold my-2">วันทำงาน <span class="red--text">&nbsp;*</span></label>
<v-layout align-center justify-center row fill-height wrap>
<v-flex sm6 xs12 class="px-2">
<v-text-field
outline
label="จาก"
:rules="[rules.required]"
class="my-job"
></v-text-field>
</v-flex>
<v-flex xs12 sm6 class="px-2">
<v-text-field
outline
:rules="[rules.required]"
label="ถึง"
class="my-job"
></v-text-field>
</v-flex>
</v-layout>
<label class="font-weight-bold my-2">เวลาทำงาน <span class="red--text">&nbsp;*</span></label>
<v-layout align-center justify-center row fill-height wrap>
<v-flex sm6 xs12 class="px-2">
<v-menu
ref="time1"
v-model="showTimeFrom"
:close-on-content-click="false"
:nudge-right="40"
lazy
transition="scale-transition"
offset-y
full-width
max-width="290px"
min-width="290px"
>
<template v-slot:activator="{ on }">
<v-text-field
outline
v-model="timeFrom"
label="จาก"
:rules="[rules.required]"
readonly
v-on="on"
></v-text-field>
</template>
<v-time-picker
v-if="showTimeFrom"
v-model="timeFrom"
full-width
@click:minute="$refs.time1.save(time)"
></v-time-picker>
</v-menu>
</v-flex>
<v-flex xs12 sm6 class="px-2">
<v-menu
ref="time2"
v-model="showTimeTo"
:close-on-content-click="false"
:nudge-right="40"
lazy
transition="scale-transition"
offset-y
full-width
max-width="290px"
min-width="290px"
>
<template v-slot:activator="{ on }">
<v-text-field
outline
v-model="timeTo"
label="ถึง"
:rules="[rules.required]"
readonly
v-on="on"
></v-text-field>
</template>
<v-time-picker
v-if="showTimeTo"
v-model="timeTo"
full-width
@click:minute="$refs.time2.save(time)"
></v-time-picker>
</v-menu>
</v-flex>
</v-layout>
</v-flex>
</v-flex>
<v-flex sm6 xs12 class="pa-3">
<h2 class="font-weight-bold mt-2"><span class="red--text">&nbsp;หน้าที่รับผิดชอบ</span> <span class="red--text">&nbsp;*</span></h2>
<v-flex sm12 xs12 class="pa-3">
<v-textarea
outline
:rules="[rules.required]"
label="หน้าที่รับผิดชอบ"
></v-textarea>
</v-flex>
<h2 class="font-weight-bold"><span class="red--text">&nbsp;คุณสมบัติ</span> <span class="red--text">&nbsp;*</span></h2>
<v-flex sm12 xs12 class="pa-3">
<v-textarea
outline
:rules="[rules.required]"
label="คุณสมบัติ"
></v-textarea>
</v-flex>
<h2 class="font-weight-bold"><span class="red--text">&nbsp;สวัสดิการ</span></h2>
<v-flex sm12 xs12 class="pa-3">
<v-textarea
outline
label="สวัสดิการ"
></v-textarea>
</v-flex>
</v-flex>
<v-layout justify-center>
<v-btn color="success" type="submit">บันทึกข้อมูล</v-btn>
</v-layout>
</v-layout> -->
</v-flex> </v-flex>
</v-form> </v-form>
</v-layout> </v-layout>
...@@ -392,9 +241,31 @@ export default { ...@@ -392,9 +241,31 @@ export default {
data () { data () {
return { return {
status: 'ยังไม่ได้เลือกไฟล์', status: 'ยังไม่ได้เลือกไฟล์',
srcImage: 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png',
srcImageMap: null,
nameImage: null, nameImage: null,
company_data: {
user_id: null,
imageCompany: 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png',
company_name: '',
company_owner: '',
phone_no: '',
email: '',
fax: '',
website: '',
addr: '',
province: '',
amphoe: '',
tumbon: '',
zip_code: '',
about: '',
imageMap: null,
lat: null,
lng: null,
bts: '',
mrt: '',
arl: '',
bus: '',
another: ''
},
rules: { rules: {
required: v => !!v || 'จำเป็นต้องกรอก', required: v => !!v || 'จำเป็นต้องกรอก',
email: v => /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(v) || 'รูปแบบอีเมลล์ไม่ถูกต้อง' email: v => /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(v) || 'รูปแบบอีเมลล์ไม่ถูกต้อง'
...@@ -409,7 +280,6 @@ export default { ...@@ -409,7 +280,6 @@ export default {
province: '', province: '',
amphoe: '', amphoe: '',
tumbon: '', tumbon: '',
zip_code: '',
openAmphoe: false, openAmphoe: false,
openTumbon: false, openTumbon: false,
openZipCode: false, openZipCode: false,
...@@ -495,30 +365,29 @@ export default { ...@@ -495,30 +365,29 @@ export default {
'ราชปรารภ', 'ราชปรารภ',
'พญาไท' 'พญาไท'
], ],
place: null, place: null
lat: 15.1179961,
long: 104.9016003
} }
}, },
methods: { methods: {
dragMarker (e) { dragMarker (e) {
this.lat = e.latLng.lat() this.company_data.lat = e.latLng.lat()
this.long = e.latLng.lng() this.company_data.lng = e.latLng.lng()
}, },
setPlace(place) { setPlace(place) {
this.place = place this.place = place
this.lat = this.place.geometry.location.lat() this.company_data.lat = this.place.geometry.location.lat()
this.long = this.place.geometry.location.lng() this.company_data.lng = this.place.geometry.location.lng()
}, },
selectFile (e) { selectFile (e) {
const file = e.target.files const file = e.target.files
this.status = file[0].name
if (!file.length) { if (!file.length) {
return return
} }
const fileReader = new FileReader() const fileReader = new FileReader()
fileReader.readAsDataURL(file[0]) fileReader.readAsDataURL(file[0])
fileReader.onload = e => { fileReader.onload = e => {
this.srcImage = e.target.result this.company_data.imageCompany = e.target.result
} }
}, },
selectFileMap (e) { selectFileMap (e) {
...@@ -530,14 +399,25 @@ export default { ...@@ -530,14 +399,25 @@ export default {
const fileReader = new FileReader() const fileReader = new FileReader()
fileReader.readAsDataURL(file[0]) fileReader.readAsDataURL(file[0])
fileReader.onload = e => { fileReader.onload = e => {
this.srcImageMap = e.target.result this.company_data.imageMap = e.target.result
} }
}, },
createJob () { createJob () {
if (this.amphoes.findIndex(x => x.amphoe_code === this.amphoe.amphoe_code) === -1) {this.amphoe = ''} if (this.amphoes.findIndex(x => x.amphoe_code === this.amphoe.amphoe_code) === -1) {this.amphoe = ''}
if (this.tumbons.findIndex(x => x.tumbon_code === this.tumbon.tumbon_code) === -1) {this.tumbon = ''} if (this.tumbons.findIndex(x => x.tumbon_code === this.tumbon.tumbon_code) === -1) {this.tumbon = ''}
if (this.company_data.zip_code === ' ') {this.company_data.zip_code = ''}
if (this.$refs.create.validate()) { if (this.$refs.create.validate()) {
console.log('create job') this.company_data.user_id = this.$store.getters.getEmployer.id
this.company_data.province = this.province.province
this.company_data.amphoe = this.amphoe.amphoe
this.company_data.tumbon = this.tumbon.tumbon
axios.post('/companys', this.company_data)
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err.response)
})
} else { } else {
this.$Loading.error() this.$Loading.error()
} }
...@@ -558,7 +438,7 @@ export default { ...@@ -558,7 +438,7 @@ export default {
}, },
showAmphoes () { showAmphoes () {
this.amphoes = [] this.amphoes = []
this.zip_code = '' this.company_data.zip_code = ''
this.openAmphoe = true this.openAmphoe = true
this.openTumbon = false this.openTumbon = false
this.openZipCode = false this.openZipCode = false
...@@ -577,6 +457,7 @@ export default { ...@@ -577,6 +457,7 @@ export default {
}, },
showTumbons () { showTumbons () {
this.tumbons = [] this.tumbons = []
this.company_data.zip_code = ' '
this.openTumbon = true this.openTumbon = true
this.openZipCode = false this.openZipCode = false
axios.get(`/api/province/${this.province.province_code}/amphoe/${this.amphoe.amphoe_code}/district`) axios.get(`/api/province/${this.province.province_code}/amphoe/${this.amphoe.amphoe_code}/district`)
...@@ -596,7 +477,7 @@ export default { ...@@ -596,7 +477,7 @@ export default {
this.openZipCode = true this.openZipCode = true
axios.get(`/api/province/${this.province.province_code}/amphoe/${this.amphoe.amphoe_code}/district/${this.tumbon.tumbon_code}`) axios.get(`/api/province/${this.province.province_code}/amphoe/${this.amphoe.amphoe_code}/district/${this.tumbon.tumbon_code}`)
.then(res => { .then(res => {
this.zip_code = res.data[0].zipcode this.company_data.zip_code = res.data[0].zipcode
}) })
.catch(err => { .catch(err => {
console.log(err.resonse) console.log(err.resonse)
......
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