install
This commit is contained in:
68
app/Filament/Clusters/Loans/Loans/LoanResource.php
Normal file
68
app/Filament/Clusters/Loans/Loans/LoanResource.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Loans\Loans;
|
||||
|
||||
use App\Filament\Clusters\Loans\Loans\Pages\ListLoans;
|
||||
use App\Filament\Clusters\Loans\Loans\Schemas\LoanForm;
|
||||
use App\Filament\Clusters\Loans\Loans\Tables\LoansTable;
|
||||
use App\Filament\Clusters\Loans\LoansCluster;
|
||||
use App\Modules\Loan\Models\Loan;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class LoanResource extends Resource
|
||||
{
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static ?string $model = Loan::class;
|
||||
|
||||
protected static ?string $cluster = LoansCluster::class;
|
||||
|
||||
public static function getNavigationIcon(): string|BackedEnum|Htmlable|null
|
||||
{
|
||||
return Heroicon::OutlinedBanknotes;
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('My loans');
|
||||
}
|
||||
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return __('Karz');
|
||||
}
|
||||
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return __('Karzlar');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return LoanForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return LoansTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListLoans::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Clusters/Loans/Loans/Pages/ListLoans.php
Normal file
19
app/Filament/Clusters/Loans/Loans/Pages/ListLoans.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Loans\Loans\Pages;
|
||||
|
||||
use App\Filament\Clusters\Loans\Loans\LoanResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListLoans extends ListRecords
|
||||
{
|
||||
protected static string $resource = LoanResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Filament/Clusters/Loans/Loans/Schemas/LoanForm.php
Normal file
30
app/Filament/Clusters/Loans/Loans/Schemas/LoanForm.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Loans\Loans\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class LoanForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Hidden::make('user_id')
|
||||
->default(user()->id),
|
||||
|
||||
Hidden::make('passport_serie')
|
||||
->default(user()->getOption('passport_serie')),
|
||||
|
||||
Hidden::make('passport_id')
|
||||
->default(user()->getOption('passport_id')),
|
||||
|
||||
TextInput::make('account_number')
|
||||
->required()
|
||||
->string()
|
||||
->maxLength(23),
|
||||
]);
|
||||
}
|
||||
}
|
||||
42
app/Filament/Clusters/Loans/Loans/Tables/LoansTable.php
Normal file
42
app/Filament/Clusters/Loans/Loans/Tables/LoansTable.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Loans\Loans\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class LoansTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('account_number')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user