Example #1
0
 public function includeAbilities(User $user)
 {
     $abilities = $user->getAbilities();
     $tes = $abilities->filter(function ($ability) {
         return $ability->name === 'edit-product' || $ability->name === 'report-order' || $ability->name === 'read-report' || $ability->name === 'billing' || $ability->name === 'void-order';
     });
     $result = [];
     foreach ($tes as $abl) {
         switch ($abl->name) {
             case 'edit-product':
                 $result[] = 1;
                 break;
             case 'report-order':
                 $result[] = 2;
                 break;
             case 'read-report':
                 $result[] = 3;
                 break;
             case 'billing':
                 $result[] = 4;
                 break;
             case 'void-order':
                 $result[] = 5;
                 break;
         }
     }
     return $this->collection($result, new AbilityTransformer());
 }
Example #2
0
 public function execute()
 {
     \DB::transaction(function () {
         $outlet = $this->factory->create($this->data);
         $owner = User::whereTitle('owner')->whereCompanyId($this->auth->getCompanyId())->first();
         $owner->outlets()->attach($outlet->id);
     });
 }
Example #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     foreach ($this->employeeAbilities() as $doThis) {
         \Bouncer::allow('employee')->to($doThis);
     }
     foreach ($this->OwnerAbilities() as $doThis) {
         \Bouncer::allow('owner')->to($doThis);
     }
     foreach ($this->adminAbilities() as $doThis) {
         \Bouncer::allow('admin')->to($doThis);
     }
     $owners = User::whereTitle('owner')->get();
     foreach ($owners as $owner) {
         $owner->assign('owner');
     }
     User::all()->each(function ($employee) {
         $employee->assign('employee');
     });
 }
Example #4
0
 public function getOwner()
 {
     return Sikasir\V1\User\User::whereEmail('*****@*****.**')->firstOrFail()->userable;
 }
Example #5
0
 public function admin()
 {
     $admin = User::whereName('admin')->get();
     return $admin[0];
 }