vendredi 10 février 2017

Pass data into controller from view

I'm trying to filter some data in laravel within my view, to only bring back users belonging to a certain location. This doesn't seem to work when attempting to pass data back into the controller. Is there a better way to achieve this functionality for nested loops in views? Or what am I missing? Note, $checklist->userByLocation 'property call' without a parameter works but obviously doesn't filter.

public function userByLocation( $locationId )
{
    return $this->users()->where(function ($query) use($locationId){
        return $query->where('checkist.location_id', $locationId );
    });
}

view:

@foreach($recipient->locations as $location)
   @foreach( $recipient->checklists as $checklist )
     @foreach( $checklist->userByLocation( $location->id ) as $user )
           test 
     @endforeach
  @endforeach
@endforeach



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

Aucun commentaire:

Enregistrer un commentaire