Refactor navigation icon declarations in various resources for consistency; enhance Group model with new relationships and fillable properties; update Hotel and Pilgrim models with fillable attributes; improve table configurations across resources.
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Filament\Resources\Groups\Pages\CreateGroup;
|
||||
use App\Filament\Resources\Groups\Pages\EditGroup;
|
||||
use App\Filament\Resources\Groups\Pages\ListGroups;
|
||||
use App\Filament\Resources\Groups\RelationManagers\PilgrimsRelationManager;
|
||||
use App\Filament\Resources\Groups\RelationManagers\ProgramRelationManager;
|
||||
use App\Filament\Resources\Groups\Schemas\GroupForm;
|
||||
use App\Filament\Resources\Groups\Tables\GroupsTable;
|
||||
use App\Models\Group;
|
||||
@@ -42,6 +43,7 @@ class GroupResource extends Resource
|
||||
{
|
||||
return [
|
||||
PilgrimsRelationManager::class,
|
||||
ProgramRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Groups\RelationManagers;
|
||||
|
||||
use Filament\Actions\AssociateAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\DissociateAction;
|
||||
use Filament\Actions\DissociateBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProgramRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'program';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('title')
|
||||
->columns([
|
||||
TextColumn::make('title')
|
||||
->searchable(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make(),
|
||||
AssociateAction::make(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DissociateAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DissociateBulkAction::make(),
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,15 @@ class GroupForm
|
||||
->components([
|
||||
DatePicker::make('start_date')
|
||||
->label('Başlanýan senesi')
|
||||
->native(false)
|
||||
->required()
|
||||
->live()
|
||||
->afterStateUpdated(fn(Set $set, ?string $state) => $set('end_date', $state ? Carbon::parse($state)->addDays(14)->format('Y-m-d') : null)),
|
||||
->afterStateUpdated(fn (Set $set, ?string $state) => $set('end_date', $state ? Carbon::parse($state)->addDays(14)->format('Y-m-d') : null))
|
||||
->rules('unique:groups,start_date'),
|
||||
|
||||
DatePicker::make('end_date')
|
||||
->label('Gutarýan senesi')
|
||||
->native(false)
|
||||
->required(),
|
||||
|
||||
Select::make('leader_teacher_id')
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Groups\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
@@ -43,7 +44,11 @@ class GroupsTable
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
EditAction::make()
|
||||
->iconButton(),
|
||||
|
||||
DeleteAction::make()
|
||||
->iconButton(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Filament\Resources\Hotels;
|
||||
use App\Filament\Resources\Hotels\Pages\CreateHotel;
|
||||
use App\Filament\Resources\Hotels\Pages\EditHotel;
|
||||
use App\Filament\Resources\Hotels\Pages\ListHotels;
|
||||
use App\Filament\Resources\Hotels\Pages\ViewHotel;
|
||||
use App\Filament\Resources\Hotels\RelationManagers\RoomsRelationManager;
|
||||
use App\Filament\Resources\Hotels\Schemas\HotelForm;
|
||||
use App\Filament\Resources\Hotels\Tables\HotelsTable;
|
||||
@@ -12,7 +13,6 @@ use App\Models\Hotel;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class HotelResource extends Resource
|
||||
@@ -22,6 +22,7 @@ class HotelResource extends Resource
|
||||
protected static ?string $navigationLabel = 'Otellar';
|
||||
|
||||
protected static ?string $pluralLabel = 'Otellar';
|
||||
|
||||
protected static ?string $modelLabel = 'Otel';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
@@ -37,7 +38,9 @@ class HotelResource extends Resource
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table->columns(HotelsTable::schema());
|
||||
return $table
|
||||
->columns(HotelsTable::schema())
|
||||
->actions(HotelsTable::actions());
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
@@ -52,6 +55,7 @@ class HotelResource extends Resource
|
||||
return [
|
||||
'index' => ListHotels::route('/'),
|
||||
'create' => CreateHotel::route('/create'),
|
||||
'view' => ViewHotel::route('/{record}'),
|
||||
'edit' => EditHotel::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
26
app/Filament/Resources/Hotels/Pages/ViewHotel.php
Normal file
26
app/Filament/Resources/Hotels/Pages/ViewHotel.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotels\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotels\HotelResource;
|
||||
use App\Filament\Resources\Hotels\Schemas\HotelInfolist;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ViewHotel extends ViewRecord
|
||||
{
|
||||
protected static string $resource = HotelResource::class;
|
||||
|
||||
public function infolist(Schema $schema): Schema
|
||||
{
|
||||
return HotelInfolist::configure($schema);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Filament/Resources/Hotels/Schemas/HotelInfolist.php
Normal file
24
app/Filament/Resources/Hotels/Schemas/HotelInfolist.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotels\Schemas;
|
||||
|
||||
use Filament\Infolists;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class HotelInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Infolists\Components\TextEntry::make('name'),
|
||||
Infolists\Components\TextEntry::make('city'),
|
||||
Infolists\Components\ImageEntry::make('image')
|
||||
->columnSpanFull(),
|
||||
Infolists\Components\ImageEntry::make('images')
|
||||
->columnSpanFull(),
|
||||
Infolists\Components\TextEntry::make('geo_location'),
|
||||
Infolists\Components\TextEntry::make('haram_distance'),
|
||||
Infolists\Components\TextEntry::make('star'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\Hotels\Tables;
|
||||
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables;
|
||||
|
||||
class HotelsTable
|
||||
@@ -35,4 +37,12 @@ class HotelsTable
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
];
|
||||
}
|
||||
|
||||
public static function actions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ use App\Models\Pilgrim;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class PilgrimResource extends Resource
|
||||
@@ -21,10 +19,13 @@ class PilgrimResource extends Resource
|
||||
protected static ?string $model = Pilgrim::class;
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $navigationLabel = 'Zyýaratçylar';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'icon-pilgrim-man';
|
||||
|
||||
protected static ?string $modelLabel = 'Zyýaratçy';
|
||||
|
||||
protected static ?string $pluralLabel = 'Zyýaratçylar';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
|
||||
11
app/Filament/Resources/Programs/Pages/CreateProgram.php
Normal file
11
app/Filament/Resources/Programs/Pages/CreateProgram.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Pages;
|
||||
|
||||
use App\Filament\Resources\Programs\ProgramResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProgram extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProgramResource::class;
|
||||
}
|
||||
21
app/Filament/Resources/Programs/Pages/EditProgram.php
Normal file
21
app/Filament/Resources/Programs/Pages/EditProgram.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Pages;
|
||||
|
||||
use App\Filament\Resources\Programs\ProgramResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProgram extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProgramResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Programs/Pages/ListPrograms.php
Normal file
19
app/Filament/Resources/Programs/Pages/ListPrograms.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Pages;
|
||||
|
||||
use App\Filament\Resources\Programs\ProgramResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListPrograms extends ListRecords
|
||||
{
|
||||
protected static string $resource = ProgramResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Programs/Pages/ViewProgram.php
Normal file
19
app/Filament/Resources/Programs/Pages/ViewProgram.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Pages;
|
||||
|
||||
use App\Filament\Resources\Programs\ProgramResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewProgram extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ProgramResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
46
app/Filament/Resources/Programs/ProgramResource.php
Normal file
46
app/Filament/Resources/Programs/ProgramResource.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs;
|
||||
|
||||
use App\Filament\Resources\Programs\Schemas\ProgramForm;
|
||||
use App\Filament\Resources\Programs\Tables\ProgramsTable;
|
||||
use App\Models\Program;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProgramResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Program::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'Programmalar';
|
||||
|
||||
protected static ?string $pluralLabel = 'Programmalar';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 7;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-calendar-days';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ProgramForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ProgramsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListPrograms::route('/'),
|
||||
'create' => Pages\CreateProgram::route('/create'),
|
||||
'edit' => Pages\EditProgram::route('/{record}/edit'),
|
||||
'view' => Pages\ViewProgram::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
51
app/Filament/Resources/Programs/Schemas/ProgramForm.php
Normal file
51
app/Filament/Resources/Programs/Schemas/ProgramForm.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\TimePicker;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ProgramForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('group_id')
|
||||
->relationship('group', 'name')
|
||||
->label('Topar')
|
||||
->required(),
|
||||
Repeater::make('days')
|
||||
->label('Günler')
|
||||
->itemLabel(fn (array $state): ?string => ($state['day_number'] ?? '').'-nji gün')
|
||||
->schema([
|
||||
TextInput::make('day_number')
|
||||
->numeric()
|
||||
->required()
|
||||
->label('Günüň belgisi'),
|
||||
Repeater::make('actions')
|
||||
->label('Actionlar')
|
||||
->schema([
|
||||
TextInput::make('title')
|
||||
->label('Ady')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Textarea::make('description')
|
||||
->label('Düşündirişi')
|
||||
->columnSpanFull(),
|
||||
TimePicker::make('time')
|
||||
->label('Wagty'),
|
||||
TextInput::make('icon')
|
||||
->label('Ikony')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
])
|
||||
->columns(2),
|
||||
])->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
21
app/Filament/Resources/Programs/Schemas/ProgramInfolist.php
Normal file
21
app/Filament/Resources/Programs/Schemas/ProgramInfolist.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ProgramInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('group.id'),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime(),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
47
app/Filament/Resources/Programs/Tables/ProgramsTable.php
Normal file
47
app/Filament/Resources/Programs/Tables/ProgramsTable.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Tables;
|
||||
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProgramsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('group.name')
|
||||
->label('Topar')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('days')
|
||||
->label('Gün sany')
|
||||
->getStateUsing(fn ($record) => count($record->days).' gün')
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Döredilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Üýtgedilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->actions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ use App\Models\Room;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class RoomResource extends Resource
|
||||
@@ -21,13 +20,14 @@ class RoomResource extends Resource
|
||||
protected static ?string $navigationLabel = 'Otaglar';
|
||||
|
||||
protected static ?string $pluralLabel = 'Otaglar';
|
||||
|
||||
protected static ?string $modelLabel = 'Otag';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
protected static string | BackedEnum | null $navigationIcon = 'icon-door-open';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'icon-door-open';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@@ -36,7 +36,8 @@ class RoomResource extends Resource
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table->columns(RoomsTable::schema());
|
||||
return $table
|
||||
->columns(RoomsTable::schema());
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
|
||||
@@ -9,17 +9,22 @@ class RoomsTable
|
||||
public static function schema(): array
|
||||
{
|
||||
return [
|
||||
Tables\Columns\TextColumn::make('hotel.name')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->searchable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('hotel.name')
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('floor')
|
||||
->searchable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('bed_count')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\IconColumn::make('wide')
|
||||
->boolean(),
|
||||
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
|
||||
@@ -11,8 +11,8 @@ use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction as ActionsEditAction;
|
||||
use Filament\Forms;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
22
app/Http/Controllers/CurrencyRatesController.php
Normal file
22
app/Http/Controllers/CurrencyRatesController.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
* Currency rates controller
|
||||
*/
|
||||
class CurrencyRatesController extends Controller
|
||||
{
|
||||
/**
|
||||
* USD to sar
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'USD_TO_SAR' => '3.70',
|
||||
'USD_TO_TMT' => '19.5',
|
||||
]);
|
||||
}
|
||||
}
|
||||
11
app/Http/Controllers/TestController.php
Normal file
11
app/Http/Controllers/TestController.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return 'Plain test';
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* @property date $start_date
|
||||
@@ -20,6 +21,11 @@ class Group extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'leader_teacher_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
@@ -31,7 +37,6 @@ class Group extends Model
|
||||
/**
|
||||
* Get the name of the group
|
||||
*
|
||||
* @return Attribute
|
||||
* */
|
||||
public function name(): Attribute
|
||||
{
|
||||
@@ -40,11 +45,6 @@ class Group extends Model
|
||||
);
|
||||
}
|
||||
|
||||
public function pilgrims(): HasMany
|
||||
{
|
||||
return $this->hasMany(Pilgrim::class);
|
||||
}
|
||||
|
||||
public function leaderTeacher(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Teacher::class, 'leader_teacher_id');
|
||||
@@ -54,4 +54,19 @@ class Group extends Model
|
||||
{
|
||||
return $this->belongsToMany(Teacher::class, 'group_teacher');
|
||||
}
|
||||
|
||||
public function teachers(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Teacher::class, 'group_teacher');
|
||||
}
|
||||
|
||||
public function pilgrims(): HasMany
|
||||
{
|
||||
return $this->hasMany(Pilgrim::class, 'group_id');
|
||||
}
|
||||
|
||||
public function program(): HasOne
|
||||
{
|
||||
return $this->hasOne(Program::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,16 @@ class Pilgrim extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'group_id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'birthdate',
|
||||
'image',
|
||||
'local_passport',
|
||||
'international_passport',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'birthdate' => 'date',
|
||||
];
|
||||
|
||||
30
app/Models/Program.php
Normal file
30
app/Models/Program.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Program extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\ProgramFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'group_id',
|
||||
'days',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'days' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function group(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Group::class);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Widgets\AccountWidget;
|
||||
use Filament\Widgets\FilamentInfoWidget;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Foundation\Configuration\Middleware;
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
|
||||
24
database/factories/GroupFactory.php
Normal file
24
database/factories/GroupFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Group>
|
||||
*/
|
||||
class GroupFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'start_date' => $this->faker->dateTimeBetween('+1 week', '+2 week'),
|
||||
'end_date' => $this->faker->dateTimeBetween('+3 week', '+4 week'),
|
||||
];
|
||||
}
|
||||
}
|
||||
54
database/factories/ProgramFactory.php
Normal file
54
database/factories/ProgramFactory.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Group;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Program>
|
||||
*/
|
||||
class ProgramFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'group_id' => Group::factory(),
|
||||
'days' => [
|
||||
[
|
||||
'day_number' => 1,
|
||||
'actions' => [
|
||||
[
|
||||
'title' => 'Mekkä şäherine ugramak',
|
||||
'description' => $this->faker->paragraph,
|
||||
'time' => '09:00',
|
||||
'icon' => 'heroicon-o-paper-airplane',
|
||||
],
|
||||
[
|
||||
'title' => 'Mekgedäki myhmanhana ýerleşmek',
|
||||
'description' => $this->faker->paragraph,
|
||||
'time' => '14:00',
|
||||
'icon' => 'heroicon-o-building-office-2',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'day_number' => 2,
|
||||
'actions' => [
|
||||
[
|
||||
'title' => 'Umra ybadaty',
|
||||
'description' => $this->faker->paragraph,
|
||||
'time' => '09:00',
|
||||
'icon' => 'heroicon-o-moon',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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::create('programs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('group_id')->constrained()->cascadeOnDelete();
|
||||
$table->json('days');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('programs');
|
||||
}
|
||||
};
|
||||
@@ -2,9 +2,8 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Teacher;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class TeacherTableSeeder extends Seeder
|
||||
{
|
||||
|
||||
11
routes/api.php
Normal file
11
routes/api.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\CurrencyRatesController;
|
||||
use App\Http\Controllers\TestController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('test', [TestController::class, 'index']);
|
||||
|
||||
Route::prefix('v1')->group(function () {
|
||||
Route::get('currency-rates', [CurrencyRatesController::class, 'index']);
|
||||
});
|
||||
Reference in New Issue
Block a user