fixed non breaking space error, added more infrastructure for job creations
This commit is contained in:
parent
e7284fbeb0
commit
daaf73ebf6
3 changed files with 16 additions and 7 deletions
Binary file not shown.
|
@ -1 +1,14 @@
|
||||||
|
namespace App\Models;
|
||||||
|
use \Illuminate\Database\Eloquent\Model;
|
||||||
|
use \Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
|
class Job extends Model {
|
||||||
|
use HasFactory;
|
||||||
|
protected $table='job_listings';
|
||||||
|
protected $fillable=['title','salary','employer_id'];
|
||||||
|
|
||||||
|
public function employer()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Employer::class;);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ Route::get('/', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/jobs', function () {
|
Route::get('/jobs', function () {
|
||||||
$jobs = Job::orderBy('salary','desc')->paginate(5);
|
$jobs = Job::orderBy('salary','desc')->latest()->paginate(5);
|
||||||
return view('jobs/index', [
|
return view('jobs/index', [
|
||||||
'jobs' => $jobs
|
'jobs' => $jobs
|
||||||
]);
|
]);
|
||||||
|
@ -31,12 +31,8 @@ Route::get('/jobs/ceate', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::post('/jobs', function () {
|
Route::post('/jobs', function () {
|
||||||
Job::create([
|
Job::create(['title'=>request('title'),'salary'=>request('salary'),'employer_id'=>1]);
|
||||||
'title'=>request('title'),
|
return redirect('/jobs');
|
||||||
'salary'=>request('salary'),
|
|
||||||
'employer_id'=>1
|
|
||||||
]);
|
|
||||||
return redirect('/jobs');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue