Commit 99d3f00d authored by Kittisak Maneewong's avatar Kittisak Maneewong

add company

parent e50609f8
......@@ -35,14 +35,44 @@ class CompanyController extends Controller
*/
public function store(Request $request)
{
$image = $request->get('image');
$name = time().'.'.explode('/', explode(':', substr($image, 0, strpos($image, ';')))[1])[1];
\Image::make($request->get('image'))->save(storage_path('uploads/').$name);
$imageCompany = null;
$imageMap = null;
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->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();
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({
email: null
},
employer: {
id: null,
username: null,
company_name: null,
email: null
......@@ -203,6 +204,7 @@ export default new Vuex.Store({
})
.then(res => {
commit('setEmployer', {
id: res.data.user.id,
username: res.data.user.username,
company_name: res.data.user.company_name,
email: res.data.user.email_employers
......
......@@ -14,8 +14,8 @@
<v-tooltip right>
<template v-slot:activator="{ on }">
<v-layout column align-center>
<img v-on="on" class="img" @click="$refs.inputFile.click()" :src="srcImage" 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>
<img v-on="on" class="img" @click="$refs.inputFile.click()" :src="company_data.imageCompany" alt="" width="200">
<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>
</template>
<span>{{ status }}</span>
......@@ -28,14 +28,14 @@
outline
label="ชื่อบริษัท"
:rules="[rules.required]"
v-model="company_name"
v-model="company_data.company_name"
class="my-ip"
></v-text-field>
<label class="font-weight-bold">ชื่อผู้ติดต่อ <span class="red--text">&nbsp;*</span></label>
<v-text-field
outline
label="ชื่อผู้ติดต่อ"
v-model="company_owner"
v-model="company_data.company_owner"
:rules="[rules.required]"
class="my-ip"
></v-text-field>
......@@ -43,7 +43,7 @@
<v-text-field
outline
label="เบอร์ผู้ติดต่อ"
v-model="phone_no"
v-model="company_data.phone_no"
:rules="[rules.required]"
class="my-ip"
></v-text-field>
......@@ -53,7 +53,7 @@
<v-text-field
outline
label="อีเมล"
v-model="email"
v-model="company_data.email"
:rules="[rules.required, rules.email]"
class="my-ip"
></v-text-field>
......@@ -62,14 +62,14 @@
outline
label="Fax"
class="my-ip"
v-model="fax"
v-model="company_data.fax"
></v-text-field>
<label class="font-weight-bold">เว็บไซต์ <span class="red--text"></span></label>
<v-text-field
outline
label="เว็บไซต์"
class="my-ip"
v-model="website"
v-model="company_data.website"
></v-text-field>
</v-flex>
</v-layout>
......@@ -85,7 +85,7 @@
outline
label="ที่อยู่"
:rules="[rules.required]"
v-model="addr"
v-model="company_data.addr"
class="my-1"
></v-textarea>
<label class="font-weight-bold">จังหวัด <span class="red--text">&nbsp;*</span></label>
......@@ -116,7 +116,7 @@
outline
label="เกี่ยวกับบริษัท"
class="my-1"
v-model="about"
v-model="company_data.about"
></v-textarea>
</v-flex>
<v-flex sm6 xs12 class="px-3">
......@@ -136,7 +136,7 @@
<v-text-field
:disabled="!openZipCode"
label="รหัสไปรษณีย์"
v-model="zip_code"
v-model="company_data.zip_code"
:rules="[rules.required]"
class="my-ip"
></v-text-field>
......@@ -148,22 +148,29 @@
<v-flex sm12 xs12>
<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="error" v-if="srcImageMap" @click="srcImageMap = null">ลบรูปภาพ</v-btn>
{{ nameImage }}
</v-flex>
<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 sm12 xs12>
<GmapAutocomplete class="form-control form-control-sm my-1" placeholder="ป้อนตำแหน่งใกล้เคียง" @place_changed="setPlace">
</GmapAutocomplete>
</v-flex>
</v-flex>
<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
:position="{lat: lat, lng: long}"
:position="{lat: company_data.lat, lng: company_data.lng}"
:draggable="true"
@dragend="dragMarker"
/>
</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-flex>
......@@ -178,7 +185,7 @@
<v-select
label="เลือก"
:items="bts"
v-model="bts"
v-model="company_data.bts"
></v-select>
</v-flex>
<v-flex sm3 xs12 class="px-3">
......@@ -186,7 +193,7 @@
<v-select
label="เลือก"
:items="mrt"
v-model="mrt"
v-model="company_data.mrt"
></v-select>
</v-flex>
<v-flex sm3 xs12 class="px-3">
......@@ -194,14 +201,14 @@
<v-select
label="เลือก"
:items="arl"
v-model="arl"
v-model="company_data.arl"
></v-select>
</v-flex>
<v-flex sm3 xs12 class="px-3">
<label class="font-weight-bold">สายรถเมล์</label>
<VTextField
label="สายรถเมล์"
v-model="bus"
v-model="company_data.bus"
></VTextField>
</v-flex>
<v-flex sm12 class="px-3">
......@@ -212,7 +219,7 @@
outline
label=""
class="my-2"
v-model="another"
v-model="company_data.another"
></v-textarea>
</v-flex>
<v-flex sm6 xs12 class="px-3 py-3 detail">
......@@ -223,164 +230,6 @@
<v-btn color="red" dark="" type="submit">บันทึกข้อมูล</v-btn>
</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-form>
</v-layout>
......@@ -392,9 +241,31 @@ export default {
data () {
return {
status: 'ยังไม่ได้เลือกไฟล์',
srcImage: 'https://asianinteriorservices.com/wp-content/uploads/2018/04/noImg.png',
srcImageMap: 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: {
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) || 'รูปแบบอีเมลล์ไม่ถูกต้อง'
......@@ -409,7 +280,6 @@ export default {
province: '',
amphoe: '',
tumbon: '',
zip_code: '',
openAmphoe: false,
openTumbon: false,
openZipCode: false,
......@@ -495,30 +365,29 @@ export default {
'ราชปรารภ',
'พญาไท'
],
place: null,
lat: 15.1179961,
long: 104.9016003
place: null
}
},
methods: {
dragMarker (e) {
this.lat = e.latLng.lat()
this.long = e.latLng.lng()
this.company_data.lat = e.latLng.lat()
this.company_data.lng = e.latLng.lng()
},
setPlace(place) {
this.place = place
this.lat = this.place.geometry.location.lat()
this.long = this.place.geometry.location.lng()
this.company_data.lat = this.place.geometry.location.lat()
this.company_data.lng = this.place.geometry.location.lng()
},
selectFile (e) {
const file = e.target.files
this.status = file[0].name
if (!file.length) {
return
}
const fileReader = new FileReader()
fileReader.readAsDataURL(file[0])
fileReader.onload = e => {
this.srcImage = e.target.result
this.company_data.imageCompany = e.target.result
}
},
selectFileMap (e) {
......@@ -530,14 +399,25 @@ export default {
const fileReader = new FileReader()
fileReader.readAsDataURL(file[0])
fileReader.onload = e => {
this.srcImageMap = e.target.result
this.company_data.imageMap = e.target.result
}
},
createJob () {
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.company_data.zip_code === ' ') {this.company_data.zip_code = ''}
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 {
this.$Loading.error()
}
......@@ -558,7 +438,7 @@ export default {
},
showAmphoes () {
this.amphoes = []
this.zip_code = ''
this.company_data.zip_code = ''
this.openAmphoe = true
this.openTumbon = false
this.openZipCode = false
......@@ -577,6 +457,7 @@ export default {
},
showTumbons () {
this.tumbons = []
this.company_data.zip_code = ' '
this.openTumbon = true
this.openZipCode = false
axios.get(`/api/province/${this.province.province_code}/amphoe/${this.amphoe.amphoe_code}/district`)
......@@ -596,7 +477,7 @@ export default {
this.openZipCode = true
axios.get(`/api/province/${this.province.province_code}/amphoe/${this.amphoe.amphoe_code}/district/${this.tumbon.tumbon_code}`)
.then(res => {
this.zip_code = res.data[0].zipcode
this.company_data.zip_code = res.data[0].zipcode
})
.catch(err => {
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