Akaunting/app/Jobs/Setting/CreateTax.php

28 lines
641 B
PHP
Raw Normal View History

2019-11-16 07:21:14 +00:00
<?php
namespace App\Jobs\Setting;
use App\Abstracts\Job;
2023-10-31 14:40:57 +00:00
use App\Events\Setting\TaxCreated;
use App\Events\Setting\TaxCreating;
2021-09-06 08:53:57 +00:00
use App\Interfaces\Job\HasOwner;
2021-09-07 07:33:34 +00:00
use App\Interfaces\Job\HasSource;
2021-09-06 08:53:57 +00:00
use App\Interfaces\Job\ShouldCreate;
2019-11-16 07:21:14 +00:00
use App\Models\Setting\Tax;
2021-09-07 07:33:34 +00:00
class CreateTax extends Job implements HasOwner, HasSource, ShouldCreate
2019-11-16 07:21:14 +00:00
{
2021-09-06 08:53:57 +00:00
public function handle(): Tax
2019-11-16 07:21:14 +00:00
{
2023-10-31 14:40:57 +00:00
event(new TaxCreating($this->request));
2020-06-26 10:40:19 +00:00
\DB::transaction(function () {
2021-09-06 08:53:57 +00:00
$this->model = Tax::create($this->request->all());
2020-06-26 10:40:19 +00:00
});
2019-11-16 07:21:14 +00:00
2023-10-31 14:40:57 +00:00
event(new TaxCreated($this->model, $this->request));
2021-09-06 08:53:57 +00:00
return $this->model;
2019-11-16 07:21:14 +00:00
}
}