예제 #1
0
 public function getList(Request $request)
 {
     $table = Categories::select('name_category', 'picture', 'id');
     $datatable = Datatables::of($table)->editColumn('picture', '<img src="{{$picture}}" heigth=64" width="64" />')->addColumn('action', function ($table) {
         return '<a href="/admpanel/' . self::NAMEC . '/form/' . $table->id . '" class="btn-actions icon icon-pen"></a>
                         <a href="javascript:;" data-url="/admpanel/' . self::NAMEC . '/delete/' . $table->id . '" class="btn-actions icon icon-trash js-delete-confirm"  data-id="' . $table->id . '" ></a>';
     });
     return $datatable->make(true);
 }
예제 #2
0
 function show($id)
 {
     try {
         $category = Categories::select('pu_categories.*', DB::raw('CONCAT("' . asset('') . '", picture) AS picture'))->whereId($id)->first();
         if (isset($category)) {
             $this->_responseWS->setDataResponse(Response::HTTP_OK, [$category->toArray()], array(), 'ok');
         } else {
             $this->_responseWS->setDataResponse(Response::HTTP_OK, [], array(), '');
         }
     } catch (\Exception $exc) {
         $this->_responseWS->setDataResponse(Response::HTTP_INTERNAL_SERVER_ERROR, array(), array(), '');
     }
     $this->_responseWS->response();
 }
 public function show($id)
 {
     $cacheTag = ['categories'];
     $cacheKey = $id;
     $response = Cache::tags($cacheTag)->remember($cacheKey, 60 * 24 * 7, function () use($id) {
         $_model = Categories::select(['description', 'image', 'active', 'created_at', 'updated_at'])->where('company_id', config('global.companies.current.id'))->where('id', $id);
         if (!config('global.managers.current.id')) {
             $_db->where('active', 1);
         }
         if ($_model->count() > 0) {
             return $_model->first()->toArray();
         } else {
             return false;
         }
     });
     if (!$response) {
         Cache::tags($cacheTag)->forget($cacheKey);
         return new \Exception("Houve um erro ao localizar registro (id not found)");
     }
     return $response;
 }
예제 #4
0
 public function categories()
 {
     $count = Categories::select(\DB::raw('count(id) as total'))->where('company_id', config('global.companies.current.id'))->count();
     return $this->jsonResponse(['data' => $count]);
 }