4 Commits

Author SHA1 Message Date
dhanabalan
d61c61879f Added module list policy file 2025-07-11 12:27:33 +05:30
dhanabalan
4b597629aa Added module list resource page 2025-07-11 12:26:44 +05:30
dhanabalan
9173dcb50a Added module list model file 2025-07-11 12:26:17 +05:30
dhanabalan
4a17892865 Added module list migration file 2025-07-11 12:25:49 +05:30
8 changed files with 366 additions and 0 deletions

View File

@@ -0,0 +1,125 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\ModuleListResource\Pages;
use App\Filament\Resources\ModuleListResource\RelationManagers;
use App\Models\ModuleList;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
class ModuleListResource extends Resource
{
protected static ?string $model = ModuleList::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Modules';
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('')
->schema([
Forms\Components\TextInput::make('module_name')
->label('Module Name')
->required(),
Forms\Components\TextInput::make('dashboard_name')
->label('DashBoard Name')
->required(),
Forms\Components\TextInput::make('filter_name')
->label('Filter Name')
->required(),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->label('Updated By')
->default(Filament::auth()->user()?->name),
])
->columns(3),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('module_name')
->label('Module Name')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('dashboard_name')
->label('DashBoard Name')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('filter_name')
->label('Filter Name')
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListModuleLists::route('/'),
'create' => Pages\CreateModuleList::route('/create'),
'view' => Pages\ViewModuleList::route('/{record}'),
'edit' => Pages\EditModuleList::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Filament\Resources\ModuleListResource\Pages;
use App\Filament\Resources\ModuleListResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateModuleList extends CreateRecord
{
protected static string $resource = ModuleListResource::class;
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Resources\ModuleListResource\Pages;
use App\Filament\Resources\ModuleListResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditModuleList extends EditRecord
{
protected static string $resource = ModuleListResource::class;
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\ModuleListResource\Pages;
use App\Filament\Resources\ModuleListResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListModuleLists extends ListRecords
{
protected static string $resource = ModuleListResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\ModuleListResource\Pages;
use App\Filament\Resources\ModuleListResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewModuleList extends ViewRecord
{
protected static string $resource = ModuleListResource::class;
protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}

19
app/Models/ModuleList.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class ModuleList extends Model
{
use SoftDeletes;
protected $fillable = [
'module_name',
'dashboard_name',
'filter_name',
'created_by',
'updated_by',
];
}

View File

@@ -0,0 +1,106 @@
<?php
namespace App\Policies;
use Illuminate\Auth\Access\Response;
use App\Models\ModuleList;
use App\Models\User;
class ModuleListPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->checkPermissionTo('view-any ModuleList');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, ModuleList $modulelist): bool
{
return $user->checkPermissionTo('view ModuleList');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->checkPermissionTo('create ModuleList');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, ModuleList $modulelist): bool
{
return $user->checkPermissionTo('update ModuleList');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, ModuleList $modulelist): bool
{
return $user->checkPermissionTo('delete ModuleList');
}
/**
* Determine whether the user can delete any models.
*/
public function deleteAny(User $user): bool
{
return $user->checkPermissionTo('delete-any ModuleList');
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, ModuleList $modulelist): bool
{
return $user->checkPermissionTo('restore ModuleList');
}
/**
* Determine whether the user can restore any models.
*/
public function restoreAny(User $user): bool
{
return $user->checkPermissionTo('restore-any ModuleList');
}
/**
* Determine whether the user can replicate the model.
*/
public function replicate(User $user, ModuleList $modulelist): bool
{
return $user->checkPermissionTo('replicate ModuleList');
}
/**
* Determine whether the user can reorder the models.
*/
public function reorder(User $user): bool
{
return $user->checkPermissionTo('reorder ModuleList');
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, ModuleList $modulelist): bool
{
return $user->checkPermissionTo('force-delete ModuleList');
}
/**
* Determine whether the user can permanently delete any models.
*/
public function forceDeleteAny(User $user): bool
{
return $user->checkPermissionTo('force-delete-any ModuleList');
}
}

View File

@@ -0,0 +1,44 @@
<?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
{
$sql = <<<'SQL'
CREATE TABLE module_lists (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
module_name TEXT NOT NULL,
dashboard_name TEXT NOT NULL,
filter_name TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMP,
created_by TEXT NULL,
updated_by TEXT NULL,
UNIQUE (module_name, dashboard_name, filter_name)
);
SQL;
DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('module_lists');
}
};