1 year ago

Help With This Code

Posted 1 year ago by artisticre

This code was working. It checks to see if a record exists. If it doesn't, it displays a button that says start application. If there is, it displays view/print button. As of now it does display the start application if no record but when there is a record, it displays the view/print button but the start application button is still there. Not sure why.

My Controller

public function viewprint()
           $userID = Auth::user()->id;
          $viewlist = DB::table('employmentapplication')
        ->select('id', 'userID')
        ->where('employmentapplication.userID', '=', $userID)
       $exists =  DB::table('employmentapplication')
             ->where('', '=', $userID)->exists();
     return view('home')->with(compact('viewlist','exists'));

My Blade View

 @if ( ! $exists)

                                                      <a class="btn btn-warning m-l-10 m-t-30 m-r-10" href="{{url('application/employment-application')}}">Start Application</a>
                                                  @foreach($viewlist as $pair)

                                            <a class="btn btn-primary btn-md m-t-30 m-l-10 m-r-10" href="/application/applicationreport?id={{$pair->id}}" target="_blank">View</a>

                                            <a class="btn btn-success m-t-30 m-r-10" href="/application/applicationreportprint?id={{$pair->id}}" taget="_blank">Print</a>


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