fixed non breaking space error, added more infrastructure for job creations

This commit is contained in:
Xander 2025-03-26 15:52:11 +00:00
parent e7284fbeb0
commit daaf73ebf6
3 changed files with 16 additions and 7 deletions

Binary file not shown.

View file

@ -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;);
}
}

View file

@ -8,7 +8,7 @@ Route::get('/', function () {
});
Route::get('/jobs', function () {
$jobs = Job::orderBy('salary','desc')->paginate(5);
$jobs = Job::orderBy('salary','desc')->latest()->paginate(5);
return view('jobs/index', [
'jobs' => $jobs
]);
@ -31,12 +31,8 @@ Route::get('/jobs/ceate', function () {
});
Route::post('/jobs', function () {
    Job::create([
        'title'=>request('title'),
        'salary'=>request('salary'),
        'employer_id'=>1
    ]);
    return redirect('/jobs');
Job::create(['title'=>request('title'),'salary'=>request('salary'),'employer_id'=>1]);
return redirect('/jobs');
});