added pointer interfaces for jobs

This commit is contained in:
Denis Duliçi
2021-09-06 11:53:57 +03:00
parent abd55133f1
commit c08a8cfc4e
63 changed files with 635 additions and 1524 deletions

View File

@ -3,31 +3,13 @@
namespace App\Jobs\Setting;
use App\Abstracts\Job;
use App\Interfaces\Job\HasOwner;
use App\Interfaces\Job\ShouldCreate;
use App\Models\Setting\Currency;
class CreateCurrency extends Job
class CreateCurrency extends Job implements HasOwner, ShouldCreate
{
protected $currency;
protected $request;
/**
* Create a new job instance.
*
* @param $request
*/
public function __construct($request)
{
$this->request = $this->getRequestInstance($request);
$this->request->merge(['created_by' => user_id()]);
}
/**
* Execute the job.
*
* @return Currency
*/
public function handle()
public function handle(): Currency
{
// Force the rate to be 1 for default currency
if ($this->request->get('default_currency')) {
@ -35,7 +17,7 @@ class CreateCurrency extends Job
}
\DB::transaction(function () {
$this->currency = Currency::create($this->request->all());
$this->model = Currency::create($this->request->all());
// Update default currency setting
if ($this->request->get('default_currency')) {
@ -44,6 +26,6 @@ class CreateCurrency extends Job
}
});
return $this->currency;
return $this->model;
}
}