samedi 28 septembre 2019

I always have the same student which appears after each recording

When I add a recording, I always have the same student which appears ???

I think the problem is perhaps in my function index() ?

public function index(Request $request)
  {   
     $user = $request->user();
     $payments = Payment::query()
     ->when($user->hasRole('admin') !== true, function (Builder $query) use ($user) {
     $query->where('email', $user->email);
     })
     ->when($request->has('search'), function (Builder $query) use ($request) {
    $query->where('name', 'like', '%' . $request->input('search') . '%');
         })->with('students:id,name') 
    ->paginate(5);

    return view('admin.payments.index', compact('payments'))
    ->with('display_search', $user->hasRole('admin'));
    }


For information my table students has 2 fields (id, name) and the table payments has 6 fields (id, date_payment, number_seance, price, total, fk_student).

Thank you for your help.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2o9ZfKz
via IFTTT

Aucun commentaire:

Enregistrer un commentaire