@snapey @cronix ok, got the routes set (at least no errors right now) thank you there.
//jobs
Route::resource('/jobs', 'JobsController');
//job bid interests
Route::post('/jobs/{job}/bidinterest', 'BidInterestsController@store');
Route::get('jobs/{job}/bidinterested', 'BidInterestsController@show');
BidInterest.php (model)
public static function scopeBidderInterested($query)
{
return $query->where('bidderinterested', 1)->exists();
}
Job.php (model)
public function bidderinterests()
{
return $this->hasMany(BidInterest::class);
}
User.php (model)
public function bidinterests()
{
return $this->hasMany(BidInterest::class);
}
The above models now have names that don't conflict (there were 2 bidinterests()).
public function show(BidInterest $Bidinterest)
{
$hasbidinterest = Auth::user()->bidInterests()->where('job_id', '=', $job->id)->BidderInterested();
return back(compact('job', 'hasbidinterest'));
}
After clicking a checkbox, the counter ups the number of interested bidders, but the checkbox does not return the if statement.
@if ($job->user->hasbidinterest)
Thank you for your interest in bidding this job.
@else
<form action="/jobs/{{ $job->id }}/bidinterest" method="POST">
@csrf
<input type="checkbox" name="bidderinterested" value="1" required>
I will bid this job.<br>
<input type="submit" value="Submit">
</form>
@endif
Any ideas?