add usercompany
This commit is contained in:
@@ -24,9 +24,17 @@ class BankResource extends Resource
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
TextInput::make('name'),
|
||||
TextInput::make('bab'),
|
||||
TextInput::make('hb'),
|
||||
TextInput::make('name')
|
||||
->required()
|
||||
->unique(),
|
||||
|
||||
TextInput::make('bab')
|
||||
->required()
|
||||
->unique(),
|
||||
|
||||
TextInput::make('hb')
|
||||
->required()
|
||||
->unique(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -61,6 +69,7 @@ class BankResource extends Resource
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
|
||||
91
app/Filament/Resources/Company/UserCompanyResource.php
Normal file
91
app/Filament/Resources/Company/UserCompanyResource.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Company;
|
||||
|
||||
use App\Filament\Resources\Company\UserCompanyResource\Pages;
|
||||
use App\Modules\UserCompany\Models\UserCompany;
|
||||
use App\Modules\UserCompany\Types\CompanyType;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class UserCompanyResource extends Resource
|
||||
{
|
||||
protected static ?string $model = UserCompany::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-briefcase';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Select::make('company_type')
|
||||
->label('Kompaniýa görnüşi')
|
||||
->native(false)
|
||||
->options(CompanyType::options())
|
||||
->default(CompanyType::default())
|
||||
->required(),
|
||||
|
||||
TextInput::make('ssb')
|
||||
->label('Şahsy salgyt belgisi')
|
||||
->unique(ignoreRecord: true)
|
||||
->required(),
|
||||
|
||||
TextInput::make('hb')
|
||||
->label('HB')
|
||||
->unique(ignoreRecord: true)
|
||||
->required(),
|
||||
|
||||
Select::make('bank_id')
|
||||
->relationship(name: 'bank', titleAttribute: 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('company_type')
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state): string => CompanyType::options()[$state])
|
||||
->color(fn (string $state): string => CompanyType::statusClass($state)),
|
||||
// 'ssb'
|
||||
// 'hb'
|
||||
// 'bank_id'
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListUserCompanies::route('/'),
|
||||
'create' => Pages\CreateUserCompany::route('/create'),
|
||||
'edit' => Pages\EditUserCompany::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Company\UserCompanyResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Company\UserCompanyResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUserCompany extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserCompanyResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
$data['user_id'] = auth('web')->id();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Company\UserCompanyResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Company\UserCompanyResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditUserCompany extends EditRecord
|
||||
{
|
||||
protected static string $resource = UserCompanyResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Company\UserCompanyResource\Pages;
|
||||
|
||||
use App\Filament\Resources\Company\UserCompanyResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUserCompanies extends ListRecords
|
||||
{
|
||||
protected static string $resource = UserCompanyResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user