Added spot rate transport master resource pages
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Successful in 15s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Laravel Larastan / larastan (pull_request) Failing after 2m42s
Laravel Pint / pint (pull_request) Failing after 2m35s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Successful in 15s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Laravel Larastan / larastan (pull_request) Failing after 2m42s
Laravel Pint / pint (pull_request) Failing after 2m35s
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\SpotRateTransportMasterResource\Pages;
|
||||
|
||||
use App\Filament\Resources\SpotRateTransportMasterResource;
|
||||
use App\Models\SpotRateTransportMaster;
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSpotRateTransportMaster extends EditRecord
|
||||
{
|
||||
protected static string $resource = SpotRateTransportMasterResource::class;
|
||||
|
||||
protected function beforeSave(): void
|
||||
{
|
||||
$groupName = $this->data['group_name'] ?? null;
|
||||
$userNames = $this->data['user_name'] ?? [];
|
||||
$recordId = $this->record->id ?? null;
|
||||
|
||||
foreach ($userNames as $userName) {
|
||||
|
||||
$query = SpotRateTransportMaster::where('group_name', $groupName)
|
||||
->whereJsonContains('user_name', $userName);
|
||||
|
||||
// Exclude current record for update
|
||||
if ($recordId) {
|
||||
$query->where('id', '!=', $recordId);
|
||||
}
|
||||
|
||||
if ($query->exists()) {
|
||||
|
||||
Notification::make()
|
||||
->title('Duplicate User')
|
||||
->body("User {$userName} already exists in this group.")
|
||||
->danger()
|
||||
->persistent()
|
||||
->send();
|
||||
|
||||
// Prevent save/update
|
||||
$this->halt();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user