implemented functionality for required fields, also implemented error messages when fields are empty
This commit is contained in:
parent
ce87ec863b
commit
32c43f9b53
2 changed files with 11 additions and 0 deletions
|
@ -19,6 +19,9 @@ Create Job
|
||||||
<div class="shrink-0 text-base text-gray-500 select-none sm:text-sm/6">workcation.com/</div>
|
<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" required>
|
<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>
|
||||||
|
@error('title')
|
||||||
|
<p class="text-xs text-red-500 font-semibold mt-1">{{$message}}</p>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -38,6 +41,9 @@ Create Job
|
||||||
<div class="shrink-0 text-base text-gray-500 select-none sm:text-sm/6">workcation.com/</div>
|
<div class="shrink-0 text-base text-gray-500 select-none sm:text-sm/6">workcation.com/</div>
|
||||||
<input type="text" name="salary" id="salary" 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="$50000">
|
<input type="text" name="salary" id="salary" 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="$50000">
|
||||||
</div>
|
</div>
|
||||||
|
@error('salary')
|
||||||
|
<p class="text-xs text-red-500 font-semibold mt-1">{{$message}}</p>
|
||||||
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,10 @@ Route::get('/jobs/{id}', function ($id) {
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::post('/jobs', function () {
|
Route::post('/jobs', function () {
|
||||||
|
request()->validate([
|
||||||
|
'title'=>['required','min:3'],
|
||||||
|
'salary'=>['required']
|
||||||
|
]);
|
||||||
Job::create(['title'=>request('title'),'salary'=>request('salary'),'employer_id'=>1]);
|
Job::create(['title'=>request('title'),'salary'=>request('salary'),'employer_id'=>1]);
|
||||||
return redirect('/jobs');
|
return redirect('/jobs');
|
||||||
});
|
});
|
||||||
|
@ -58,5 +62,6 @@ Route::post('/jobs', function () {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue