1 year ago

don't show checkbox if auth()->user has submitted checkbox

Posted 1 year ago by trevorpan

Hi, this form shows how many interested bidders there are for a given job. After a user_id has submitted interest to bid, the blade takes away the possibility of resubmitting the form.

Having a real tough go on getting the auth()->user to be the conditional. Sometimes they'll hide a form. But then when I log in as another user it shows without form, etc. Feels like whack-a-mole.

    //class BidInterestsController extends Controller @ show

    // $userbidinterests = DB::table('bidinterests')
        //     ->where('user_id', '==', auth()->user->id)->get();
        $userbidinterests = DB::table('bidinterests')
                                ->whereExists(function ($query) {
                                          ->whereRaw('bidderinterested.user_id =');

The blade logic

        @if (!$job->userbidinterests)
            <form action="/jobs/{{ $job->id }}/bidinterests" method="POST">
                <input type="checkbox" name="bidderinterested" value="1" required> I will bid this job.<br>
                <input type="submit" value="Submit">
            Thank you for your interest in bidding this job.

Please sign in or create an account to participate in this conversation.