vendredi 1 janvier 2016

Unique collection in Laravel

I need to find out unique value. So I tried bellow code. It is through undefined variable error.

Controller:

$employee = Employee::all();
Return view ('page', compact('employee'));

Page view:

$uniqueEmpLoc = $employee->unique('location')->values()->list('location')->toArray();
@Foreach($uniqueEmpLoc as $empLoc)
  {{ $empLoc }}
@endforeach

But I got an uniqueEmpLoc is undefined error. I'm using LARAVEL 5.1. Please help me to solve this problem.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire