Merge pull request 'ranjith-dev' (#78) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Reviewed-on: #78
This commit was merged in pull request #78.
This commit is contained in:
@@ -5,21 +5,19 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\WorkGroupMasterExporter;
|
use App\Filament\Exports\WorkGroupMasterExporter;
|
||||||
use App\Filament\Imports\WorkGroupMasterImporter;
|
use App\Filament\Imports\WorkGroupMasterImporter;
|
||||||
use App\Filament\Resources\WorkGroupMasterResource\Pages;
|
use App\Filament\Resources\WorkGroupMasterResource\Pages;
|
||||||
use App\Filament\Resources\WorkGroupMasterResource\RelationManagers;
|
|
||||||
use App\Models\Line;
|
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\WorkGroupMaster;
|
use App\Models\WorkGroupMaster;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Forms\Components\Section;
|
|
||||||
use Filament\Facades\Filament;
|
|
||||||
use Filament\Tables\Actions\ImportAction;
|
|
||||||
use Filament\Tables\Actions\ExportAction;
|
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class WorkGroupMasterResource extends Resource
|
class WorkGroupMasterResource extends Resource
|
||||||
@@ -46,16 +44,18 @@ class WorkGroupMasterResource extends Resource
|
|||||||
->required()
|
->required()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
$set('pqPlantError', 'Please select a plant first.');
|
$set('pqPlantError', 'Please select a plant first.');
|
||||||
$set('name', null);
|
$set('name', null);
|
||||||
$set('description', null);
|
$set('description', null);
|
||||||
$set('operation_number', null);
|
$set('operation_number', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,12 +83,12 @@ class WorkGroupMasterResource extends Resource
|
|||||||
->numeric()
|
->numeric()
|
||||||
->columnSpan(1)
|
->columnSpan(1)
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required(),
|
||||||
->rule(function (callable $get) {
|
// ->rule(function (callable $get) {
|
||||||
return Rule::unique('work_group_masters', 'operation_number')
|
// return Rule::unique('work_group_masters', 'operation_number')
|
||||||
->where('plant_id', $get('plant_id'))
|
// ->where('plant_id', $get('plant_id'))
|
||||||
->ignore($get('id'));
|
// ->ignore($get('id'));
|
||||||
}),
|
// }),
|
||||||
Forms\Components\TextInput::make('description')
|
Forms\Components\TextInput::make('description')
|
||||||
->label('Description')
|
->label('Description')
|
||||||
->required()
|
->required()
|
||||||
@@ -112,6 +112,7 @@ class WorkGroupMasterResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -177,14 +178,14 @@ class WorkGroupMasterResource extends Resource
|
|||||||
->label('Import Work Group Masters')
|
->label('Import Work Group Masters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(WorkGroupMasterImporter::class)
|
->importer(WorkGroupMasterImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import work group master');
|
return Filament::auth()->user()->can('view import work group master');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export Work Group Masters')
|
->label('Export Work Group Masters')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(WorkGroupMasterExporter::class)
|
->exporter(WorkGroupMasterExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export work group master');
|
return Filament::auth()->user()->can('view export work group master');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('work_group_masters', function (Blueprint $table) {
|
||||||
|
$table->dropUnique('work_group_masters_plant_id_operation_number_key');
|
||||||
|
});
|
||||||
|
|
||||||
|
// $sql = <<<'SQL'
|
||||||
|
// ALTER TABLE work_group_masters
|
||||||
|
// DROP INDEX work_group_masters_plant_id_operation_number_key;
|
||||||
|
// SQL;
|
||||||
|
|
||||||
|
// DB::statement($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('work_group_masters', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user