예제 #1
0
 /**
  * Process datatables ajax request.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function search()
 {
     $account = $this->auth_user->account;
     //return all brands when we are in the system account
     //in a normal account only show the current linked one
     if ($account->isSystemAccount()) {
         $brands = Brand::all();
     } else {
         // retrieve it as a collection
         $brands = Brand::where('id', '=', $account->brand->id)->get();
     }
     return Datatables::of($brands)->addColumn('actions', function ($brand) {
         $actions = \Form::open(['route' => ['admin.brands.destroy', $brand->id], 'method' => 'DELETE', 'class' => 'form-inline']);
         $actions .= ' <a href="brands/' . $brand->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-eye-open"></i> ' . trans('misc.button.show') . '</a> ';
         $actions .= ' <a href="brands/' . $brand->id . '/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> ' . trans('misc.button.edit') . '</a> ';
         $actions .= \Form::button('<i class="glyphicon glyphicon-remove"></i> ' . trans('misc.button.delete'), ['type' => 'submit', 'class' => 'btn btn-danger btn-xs']);
         $actions .= \Form::close();
         return $actions;
     })->addColumn('logo', function ($brand) {
         $logo = '<img src="/admin/logo/' . $brand->id . '" height="40px"/>';
         return $logo;
     })->make(true);
 }
예제 #2
0
 /**
  * Process datatables ajax request.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function search()
 {
     $account = $this->auth_user->account;
     //return all brands when we are in the system account
     //in a normal account only show the active and the created
     if ($account->isSystemAccount()) {
         $brands = Brand::all();
     } else {
         // retrieve the active brand as a collection
         $active_brands = Brand::where('id', '=', $account->active_brand->id)->get();
         // retrieve the created accounts
         $created_brands = Brand::whereIn('id', $account->brands->lists('id'))->get();
         $brands = $active_brands->merge($created_brands);
     }
     return Datatables::of($brands)->addColumn('status', function ($brand) use($account) {
         if ($account->brand_id == $brand->id) {
             return trans('misc.active');
         } else {
             return trans('misc.inactive');
         }
     })->addColumn('actions', function ($brand) use($account) {
         $actions = \Form::open(['route' => ['admin.brands.destroy', $brand->id], 'method' => 'DELETE', 'class' => 'form-inline']);
         if (!$brand->isSystemBrand() or $account->isSystemAccount()) {
             if ($account->brand_id != $brand->id) {
                 $actions .= ' <a href="brands/' . $brand->id . '/activate" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-play"></i> ' . trans('misc.button.activate') . '</a> ';
             }
             $actions .= ' <a href="brands/' . $brand->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-eye-open"></i> ' . trans('misc.button.show') . '</a> ';
             $actions .= ' <a href="brands/' . $brand->id . '/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> ' . trans('misc.button.edit') . '</a> ';
             $actions .= \Form::button('<i class="glyphicon glyphicon-remove"></i> ' . trans('misc.button.delete'), ['type' => 'submit', 'class' => 'btn btn-danger btn-xs']);
         }
         $actions .= \Form::close();
         return $actions;
     })->addColumn('logo', function ($brand) {
         $logo = '<img src="/admin/logo/' . $brand->id . '" width="60px"/>';
         return $logo;
     })->make(true);
 }
예제 #3
0
 /**
  * {@inheritdoc}.
  */
 protected function findAll()
 {
     return Brand::all();
 }