Commit 16d37ebd authored by Kittisak Maneewong's avatar Kittisak Maneewong

edit

parent eae7ea16
<?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 diff is collapsed.
......@@ -25,7 +25,7 @@
label="อีเมล"
color="deep-orange"
type="text"
v-model="registerJob_data.email"
v-model="email"
required
></v-text-field>
<v-text-field
......@@ -33,7 +33,7 @@
label="ชื่อ"
color="deep-orange"
type="text"
v-model="registerJob_data.name"
v-model="name"
required
></v-text-field>
<v-text-field
......@@ -93,8 +93,6 @@ export default {
data () {
return {
registerJob_data: {
name: '',
email: '',
major: '',
faculty: '',
university: '',
......@@ -103,10 +101,45 @@ export default {
}
}
},
computed: {
name () {
return this.$store.getters.getUser.name
},
email () {
return this.$store.getters.getUser.email
}
},
methods: {
registerJob () {
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 {
this.$Loading.error()
}
......
......@@ -23,6 +23,8 @@ Route::resource('/companys', 'CompanyController');
Route::resource('/jobs', 'JobController');
Route::resource('/applicants', 'ApplicantController');
Route::get('/show', 'AppController@show');
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