repository = $transaction; parent::__construct(); } /** * Show transaction's list. * * @param string $slug * * @return response */ protected function index() { $transactions = $this->repository ->setPresenter('\\Sma\\Transaction\\Repositories\\Presenter\\TransactionListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $transactions['code'] = 2000; return response()->json($transactions) ->setStatusCode(200, 'INDEX_SUCCESS'); } /** * Show transaction. * * @param string $slug * * @return response */ protected function show($slug) { $transaction = $this->repository ->scopeQuery(function($query) use ($slug) { return $query->orderBy('id','DESC') ->where('slug', $slug); })->first(['*']); if (!is_null($transaction)) { $transaction = $this->itemPresenter($module, new TransactionItemTransformer); $transaction['code'] = 2001; return response()->json($transaction) ->setStatusCode(200, 'SHOW_SUCCESS'); } else { return response()->json([]) ->setStatusCode(400, 'SHOW_ERROR'); } } }