| Total Complexity | 10 | 
| Total Lines | 73 | 
| Duplicated Lines | 0 % | 
| Coverage | 100% | 
| Changes | 0 | ||
| 1 | <?php namespace Distilleries\Expendable\Models; | ||
| 3 | class Permission extends BaseModel {
 | ||
| 4 | |||
| 5 | protected $fillable = [ | ||
| 6 | 'id', | ||
| 7 | 'role_id', | ||
| 8 | 'service_id' | ||
| 9 | ]; | ||
| 10 | |||
| 11 | |||
| 12 | 2 | public function role() | |
| 13 |     {
 | ||
| 14 | 2 |         return $this->belongsTo('Distilleries\Expendable\Models\Role');
 | |
| 15 | } | ||
| 16 | |||
| 17 | 6 | public function service() | |
| 20 | } | ||
| 21 | |||
| 22 | 6 | public function getArea() | |
| 23 |     {
 | ||
| 24 | 6 | $roles = Role::all(); | |
| 25 | 6 |         $services = Service::orderBy('action')->get();
 | |
| 26 | 6 | $services = $services->toArray(); | |
| 27 | |||
| 28 | 6 | $groupedServices = []; | |
| 29 | |||
| 30 | 6 | foreach ($services as $service) | |
| 31 |         {
 | ||
| 32 | 6 |             $actions = preg_split('/@/', $service['action']);
 | |
|  | |||
| 33 | |||
| 34 | 6 | if (count($actions) >= 2) | |
| 35 |             {
 | ||
| 36 | 2 | $groupedServices[$actions[0]][] = [ | |
| 37 | 2 | 'id' => $service['id'], | |
| 38 | 2 | 'libelle' => $actions[1] | |
| 39 | ]; | ||
| 40 | } | ||
| 41 | |||
| 42 | } | ||
| 43 | |||
| 44 | 6 | $result = []; | |
| 45 | 6 | foreach ($roles as $role) | |
| 46 |         {
 | ||
| 47 | 6 | $result[] = [ | |
| 48 | 6 | 'libelle' => $role->libelle, | |
| 49 | 6 | 'id' => $role->id, | |
| 50 | 6 | 'choices' => $groupedServices | |
| 51 | ]; | ||
| 52 | } | ||
| 53 | |||
| 54 | 6 | return $result; | |
| 55 | } | ||
| 56 | |||
| 57 | 6 | public function getAreaSelected() | |
| 76 | } | ||
| 77 | } |