Merge branch 'master' of github.com:akaunting/akaunting

This commit is contained in:
Cüneyt Şentürk 2020-03-09 11:54:29 +03:00
commit fa266cb3f2
2 changed files with 30 additions and 30 deletions

View File

@ -30,7 +30,7 @@ abstract class Controller extends BaseController
* *
* @return void * @return void
*/ */
protected function setPermissions() public function setPermissions()
{ {
// No need to check for permission in console // No need to check for permission in console
if (app()->runningInConsole()) { if (app()->runningInConsole()) {
@ -90,33 +90,4 @@ abstract class Controller extends BaseController
return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options); 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;
}
} }

View File

@ -31,6 +31,35 @@ trait Jobs
return $result; 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() public function getDispatchFunction()
{ {
$config = config('queue.default'); $config = config('queue.default');