diff --git a/app/Abstracts/Http/Controller.php b/app/Abstracts/Http/Controller.php index 779868b1b..2a4bf8bef 100644 --- a/app/Abstracts/Http/Controller.php +++ b/app/Abstracts/Http/Controller.php @@ -30,7 +30,7 @@ abstract class Controller extends BaseController * * @return void */ - protected function setPermissions() + public function setPermissions() { // No need to check for permission in console if (app()->runningInConsole()) { @@ -90,33 +90,4 @@ abstract class Controller extends BaseController return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options); } - - /** - * Dispatch a job to its appropriate handler and return a response array for ajax calls. - * - * @param mixed $job - * @return mixed - */ - public function ajaxDispatch($job) - { - try { - $data = $this->dispatch($job); - - $response = [ - 'success' => true, - 'error' => false, - 'data' => $data, - 'message' => '', - ]; - } catch(\Exception $e) { - $response = [ - 'success' => false, - 'error' => true, - 'data' => null, - 'message' => $e->getMessage(), - ]; - } - - return $response; - } } diff --git a/app/Traits/Jobs.php b/app/Traits/Jobs.php index a3482face..c8fcb1a20 100644 --- a/app/Traits/Jobs.php +++ b/app/Traits/Jobs.php @@ -31,6 +31,35 @@ trait Jobs return $result; } + /** + * Dispatch a job to its appropriate handler and return a response array for ajax calls. + * + * @param mixed $job + * @return mixed + */ + public function ajaxDispatch($job) + { + try { + $data = $this->dispatch($job); + + $response = [ + 'success' => true, + 'error' => false, + 'data' => $data, + 'message' => '', + ]; + } catch(\Exception $e) { + $response = [ + 'success' => false, + 'error' => true, + 'data' => null, + 'message' => $e->getMessage(), + ]; + } + + return $response; + } + public function getDispatchFunction() { $config = config('queue.default');