Job creation implemented
This commit is contained in:
parent
daaf73ebf6
commit
7ed3d2acaa
5 changed files with 13 additions and 9 deletions
|
@ -1,4 +1,6 @@
|
|||
namespace App\Models;
|
||||
<?php
|
||||
|
||||
namespace app\Models;
|
||||
use \Illuminate\Database\Eloquent\Model;
|
||||
use \Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
|
@ -9,6 +11,6 @@ class Job extends Model {
|
|||
|
||||
public function employer()
|
||||
{
|
||||
return $this->belongsTo(Employer::class;);
|
||||
return $this->belongsTo(Employer::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@
|
|||
<header class="bg-white shadow-sm">
|
||||
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
|
||||
{{$heading}}
|
||||
<a href="/jobs/create">Create Jon</a>
|
||||
</div>
|
||||
</header>
|
||||
<main>
|
||||
|
|
|
@ -17,7 +17,7 @@ Create Job
|
|||
<div class="mt-2">
|
||||
<div class="flex items-center rounded-md bg-white pl-3 outline-1 -outline-offset-1 outline-gray-300 focus-within:outline-2 focus-within:-outline-offset-2 focus-within:outline-indigo-600">
|
||||
<div class="shrink-0 text-base text-gray-500 select-none sm:text-sm/6">workcation.com/</div>
|
||||
<input type="text" name="title" id="title" class="block min-w-0 grow py-1.5 pr-3 pl-1 text-base text-gray-900 placeholder:text-gray-400 focus:outline-none sm:text-sm/6" placeholder="Shift Leader">
|
||||
<input type="text" name="title" id="title" class="block min-w-0 grow py-1.5 pr-3 pl-1 text-base text-gray-900 placeholder:text-gray-400 focus:outline-none sm:text-sm/6" placeholder="Shift Leader" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<x-slot:heading>
|
||||
Job
|
||||
</x-slot:heading>
|
||||
<h2 class="font-bold txt-lg">{{$job['title']}}</h2>
|
||||
<h2 class="font-bold txt-lg">{{ $job['title'] ?? 'No title available' }}</h2>
|
||||
<p>
|
||||
This job pays {{$job['salary']}} per year
|
||||
This job pays {{ $job['salary'] ?? 'N/A' }} per year
|
||||
</p>
|
||||
</x-layout>
|
||||
|
|
|
@ -20,16 +20,17 @@ Route::get('/jobs', function () {
|
|||
Route::get('/contact', function () {
|
||||
return view('contact');
|
||||
});
|
||||
|
||||
Route::get('/jobs/create', function () {
|
||||
return view('jobs/create');
|
||||
});
|
||||
|
||||
Route::get('/jobs/{id}', function ($id) {
|
||||
$job = Job::find($id);
|
||||
|
||||
return view('jobs/show', ['job' => $job]);
|
||||
});
|
||||
|
||||
Route::get('/jobs/ceate', function () {
|
||||
return view('jobs/create');
|
||||
});
|
||||
|
||||
Route::post('/jobs', function () {
|
||||
Job::create(['title'=>request('title'),'salary'=>request('salary'),'employer_id'=>1]);
|
||||
return redirect('/jobs');
|
||||
|
|
Loading…
Add table
Reference in a new issue