man, I'm still tinkering with this thing and have made some progress, but could still use a hand:
class JobsController extends Controller
{
protected $job;
public function __construct()
{
$this->middleware('auth')->except(['index', 'show']);
}
....
public function show(Job $job)
{
// $thumbnail = $job->getFirstMedia('document');
$fullpageimage = $job->getFirstMedia('document');
// $fullpageimage = Arr::first($fullpageimage);
$downloads = $job->getMedia('document');
// $downloads = $job->getMedia('document');
$hasbidinterest = BidInterest::BidderInterested()->where('job_id', '=', $job->id)->get();
// dd($hasbidinterest);
return view('jobs.show', compact('job', 'downloads', 'fullpageimage', 'thumbnail', 'hasbidinterest'));
}
The JobsController has an authentication except on 'show', in this case, and it interferes with displaying the checkbox. How do you test for authenticated user for just $hasbidinterest but not interfere with the overall 'show' method?
The show method is used to display a job for anyone, not just auth()->users
here's new logic in the blade file
@if ($hasbidinterest = true)
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
When dd($hasbidinterests); the array does show all the bidders, and counts them properly. However, because the blade logic does not yield the result desired a single user can hit the button as many times as they like and the array will count the user 3 times if they clicked the checkbox 3 times, etc.
Thank you anyone ~