Commit d1f99aab authored by Kittisak Maneewong's avatar Kittisak Maneewong
parents 6e9e9e2f 239424b7
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Applicant extends Model
{
//
}
<?php
namespace App\Http\Controllers;
use App\Applicant;
use Illuminate\Http\Request;
class ApplicantController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$applicant = new Applicant();
$applicant->email = $request->get('email');
$applicant->name = $request->get('name');
$applicant->degree = $request->get('degree');
$applicant->major = $request->get('major');
$applicant->faculty = $request->get('faculty');
$applicant->university = $request->get('university');
$applicant->gpax = $request->get('gpax');
$applicant->job_id = $request->get('job_id');
$applicant->save();
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateApplicantsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('applicants', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('email');
$table->string('name');
$table->string('degree')->nullable();
$table->string('major')->nullable();
$table->string('faculty')->nullable();
$table->string('university')->nullable();
$table->string('gpax')->nullable();
$table->unsignedBigInteger('job_id');
$table->foreign('job_id')->references('id')->on('jobs');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('applicants');
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
<span class="headline font-weight-bold indigo--text">{{ detail_data.job_title }}</span> <span class="headline font-weight-bold indigo--text">{{ detail_data.job_title }}</span>
</v-flex> </v-flex>
<v-flex xs12 sm2> <v-flex xs12 sm2>
<v-btn color="deep-orange " v-if="!!localStorage.getItem('access_token')" @click="$store.commit('setDialogJob', !$store.getters.getDialogJob);" dark small depressed class="body-2">สมัครงานนี้</v-btn> <v-btn color="deep-orange " v-if="chk" @click="$store.commit('setDialogJob', !$store.getters.getDialogJob);" dark small depressed class="body-2">สมัครงานนี้</v-btn>
<v-btn color="deep-orange " v-if="!localStorage.getItem('access_token')" @click="$store.commit('setSnackbar', {show: true, color: 'error', text: 'จำเป็นต้องเข้าสู่ระบบสมาชิกก่อน!'})" dark small depressed class="body-2">สมัครงานนี้</v-btn> <v-btn color="deep-orange " v-if="!chk" @click="$store.commit('setSnackbar', {show: true, color: 'error', text: 'จำเป็นต้องเข้าสู่ระบบสมาชิกก่อน!'})" dark small depressed class="body-2">สมัครงานนี้</v-btn>
</v-flex> </v-flex>
</v-layout> </v-layout>
<v-flex xs12 sm8> <v-flex xs12 sm8>
...@@ -177,6 +177,11 @@ export default { ...@@ -177,6 +177,11 @@ export default {
detail_data: {} detail_data: {}
} }
}, },
computed: {
chk () {
return this.$store.getters.getUser.email
}
},
beforeMount () { beforeMount () {
axios.get(`/api/detail/${this.$route.params.id}`) axios.get(`/api/detail/${this.$route.params.id}`)
.then(res => { .then(res => {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
label="อีเมล" label="อีเมล"
color="deep-orange" color="deep-orange"
type="text" type="text"
v-model="registerJob_data.email" v-model="email"
required required
></v-text-field> ></v-text-field>
<v-text-field <v-text-field
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
label="ชื่อ" label="ชื่อ"
color="deep-orange" color="deep-orange"
type="text" type="text"
v-model="registerJob_data.name" v-model="name"
required required
></v-text-field> ></v-text-field>
<v-text-field <v-text-field
...@@ -93,8 +93,6 @@ export default { ...@@ -93,8 +93,6 @@ export default {
data () { data () {
return { return {
registerJob_data: { registerJob_data: {
name: '',
email: '',
major: '', major: '',
faculty: '', faculty: '',
university: '', university: '',
...@@ -103,10 +101,45 @@ export default { ...@@ -103,10 +101,45 @@ export default {
} }
} }
}, },
computed: {
name () {
return this.$store.getters.getUser.name
},
email () {
return this.$store.getters.getUser.email
}
},
methods: { methods: {
registerJob () { registerJob () {
if(this.$refs.registerJob.validate()) { if(this.$refs.registerJob.validate()) {
axios.post('/api/applicants', {
job_id: this.id,
email: this.email,
name: this.name,
degree: this.registerJob_data.degree,
major: this.registerJob_data.major,
faculty: this.registerJob_data.faculty,
university: this.registerJob_data.university,
gpax: this.registerJob_data.gpax
})
.then(res => {
this.$store.commit('setSnackbar', {
show: true,
color: 'success',
text: 'สมัครงานสำเร็จ'
})
this.$store.commit('setDialogJob', false)
this.registerJob_data = {
major: '',
faculty: '',
university: '',
gpax: '',
degree: ''
}
})
.catch(err => {
console.log(err.response)
})
} else { } else {
this.$Loading.error() this.$Loading.error()
} }
......
...@@ -122,7 +122,8 @@ ...@@ -122,7 +122,8 @@
</v-flex> </v-flex>
<v-flex xs12 sm2> <v-flex xs12 sm2>
<v-layout row wrap justify-end> <v-layout row wrap justify-end>
<v-btn color="deep-orange " dark small depressed class="body-2" @click="$store.commit('setDialogJob', !$store.getters.getDialogJob);id=job.id">สมัครงานนี้</v-btn> <v-btn color="deep-orange " v-if="chk" dark small depressed class="body-2" @click="$store.commit('setDialogJob', !$store.getters.getDialogJob);id=job.id">สมัครงานนี้</v-btn>
<v-btn color="deep-orange " v-if="!chk" dark small depressed class="body-2" @click="$store.commit('setSnackbar', {show: true, color: 'error', text: 'จำเป็นต้องเข้าสู่ระบบสมาชิกก่อน!'})">สมัครงานนี้</v-btn>
</v-layout> </v-layout>
<v-layout row wrap justify-end class="px-2"> <v-layout row wrap justify-end class="px-2">
<label class="font-weight-bold">{{ job.num ? job.num + ' อัตรา' : '' }}</label> <label class="font-weight-bold">{{ job.num ? job.num + ' อัตรา' : '' }}</label>
...@@ -274,6 +275,9 @@ export default { ...@@ -274,6 +275,9 @@ export default {
} }
}, },
computed: { computed: {
chk () {
return this.$store.getters.getUser.email
},
chkChip() { chkChip() {
return Object.values(this.chips).includes(true); return Object.values(this.chips).includes(true);
}, },
......
...@@ -23,6 +23,8 @@ Route::resource('/companys', 'CompanyController'); ...@@ -23,6 +23,8 @@ Route::resource('/companys', 'CompanyController');
Route::resource('/jobs', 'JobController'); Route::resource('/jobs', 'JobController');
Route::resource('/applicants', 'ApplicantController');
Route::get('/show', 'AppController@show'); Route::get('/show', 'AppController@show');
Route::get('/detail/{id}', 'AppController@detail'); Route::get('/detail/{id}', 'AppController@detail');
......
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