Good Morning Currently I am working on a job portal by the use of Laravel 8.
The idea: I want to show the applicants the status of each job (they applied on). so for example: Engineer (as position) when applicant applied in it. The application reach to admin can who can reject him or waiting listing listing him or accept him .
what I did : I created a new attribute in jobapplicaton table in (db) where all applied jobs_ids and user_id are linked and stored once they applied. this attribute is "status" and has a default value of "applied". The user can see first "applied" only. and admin have a chance to update "applied" to "reject" /waiting list or accept .
My code:Schema:
Schema::create('job_applications', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('cv_id');
$table->unsignedBigInteger('job_id');
$table->string('status')->default('applied')->change();
$table->timestamps();
controller: update methods:
public function update( Request $request, $id){
$job = job::with('applications.applicant')->find($id);
$status->status = $request->input('status');
$job->save();
return view('overview.showcandi',compact( 'job'));
}
admin view:(only the form)
$job])}}" method="post" enctype="multipart/form-data"> {{ csrf_field() }} {!! Form::select('status', array('1' => 'rejected', '0' => 'applied'), '0'); !!}
<input type="submit" value="submit" />
Uservview:(showing zero value, but the default value is "applied" I dont know why ) that why i wrote like that
<td>
@if ($job->status==0)
{{ __('applied')}}
@else
{{ __('$job->status')}}
@endif
</td>
the error: when the admin wants to change the status and click on submit the code gives me the following error
Creating default object from empty value I think the code is readin status as null although it is value in db is applied so how can I update the status now.
what I did : I created a new attribute in jobapplicaton table in (db) where all applied jobs_ids and user_id are linked and stored once they applied. this attribute is "status" and has a default value of "applied". The user can see first "applied" only. and admin have a chance to update "applied" to "reject" /waiting list or accept .