feat: initial commit
This commit is contained in:
23
app/Commands/Transmittal/GenerateTransmittalSeries.php
Normal file
23
app/Commands/Transmittal/GenerateTransmittalSeries.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands\Transmittal;
|
||||
|
||||
use App\Commands\Command;
|
||||
use App\Models\Transmittal;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class GenerateTransmittalSeries implements Command
|
||||
{
|
||||
|
||||
public function execute(array $data): string
|
||||
{
|
||||
$lastSeries = Transmittal::query()->orderBy('id', 'desc')->first();
|
||||
|
||||
if ($lastSeries) {
|
||||
$series = explode('-', $lastSeries->series)[1];
|
||||
return 'TR-'.str_pad((int)$series + 1, 10, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
return $series = 'TR-'.str_pad(1, 10, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
19
app/Commands/Transmittal/StoreCommentCommand.php
Normal file
19
app/Commands/Transmittal/StoreCommentCommand.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands\Transmittal;
|
||||
|
||||
use App\Commands\Command;
|
||||
use App\Models\Comment;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class StoreCommentCommand implements Command
|
||||
{
|
||||
|
||||
public function execute(array $data): mixed
|
||||
{
|
||||
return DB::transaction(
|
||||
callback: fn () => Comment::query()->create($data),
|
||||
attempts: 2
|
||||
);
|
||||
}
|
||||
}
|
||||
20
app/Commands/Transmittal/StoreFileCommand.php
Normal file
20
app/Commands/Transmittal/StoreFileCommand.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands\Transmittal;
|
||||
|
||||
use App\Commands\Command;
|
||||
use App\Models\File;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use function PHPUnit\Framework\callback;
|
||||
|
||||
class StoreFileCommand implements Command
|
||||
{
|
||||
|
||||
public function execute(array $data): mixed
|
||||
{
|
||||
return DB::transaction(
|
||||
callback: fn () => File::query()->create($data),
|
||||
attempts: 2
|
||||
);
|
||||
}
|
||||
}
|
||||
19
app/Commands/Transmittal/StoreRemarkCommand.php
Normal file
19
app/Commands/Transmittal/StoreRemarkCommand.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands\Transmittal;
|
||||
|
||||
use App\Commands\Command;
|
||||
use App\Models\Remark;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class StoreRemarkCommand implements Command
|
||||
{
|
||||
|
||||
public function execute(array $data): mixed
|
||||
{
|
||||
return DB::transaction(
|
||||
callback: fn () => Remark::query()->create($data),
|
||||
attempts: 2
|
||||
);
|
||||
}
|
||||
}
|
||||
20
app/Commands/Transmittal/StoreTransmittalCommand.php
Normal file
20
app/Commands/Transmittal/StoreTransmittalCommand.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands\Transmittal;
|
||||
|
||||
use App\Commands\Command;
|
||||
use App\Models\Transmittal;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class StoreTransmittalCommand implements Command
|
||||
{
|
||||
|
||||
public function execute(array $data): Model
|
||||
{
|
||||
return DB::transaction(
|
||||
callback: fn () => Transmittal::query()->updateOrCreate(['id' => $data['id'] ?? null], $data),
|
||||
attempts: 2
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user