Skip to content

Commit 0d9ecc0

Browse files
committed
feat: introduce Filament Home panel system
- Replace Livewire components with Filament Home panel - Add PanelCommonConfig middleware for shared configuration - Remove deprecated RouteResource from Operator panel - Update provider configuration and panel structure - Add new view components for route duration and layouts
1 parent 0322319 commit 0d9ecc0

File tree

25 files changed

+1098
-227
lines changed

25 files changed

+1098
-227
lines changed

README.md

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1 @@
1-
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
2-
3-
<p align="center">
4-
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
5-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
6-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
7-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
8-
</p>
9-
10-
## About Laravel
11-
12-
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
13-
14-
- [Simple, fast routing engine](https://laravel.com/docs/routing).
15-
- [Powerful dependency injection container](https://laravel.com/docs/container).
16-
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
17-
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
18-
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
19-
- [Robust background job processing](https://laravel.com/docs/queues).
20-
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
21-
22-
Laravel is accessible, powerful, and provides tools required for large, robust applications.
23-
24-
## Learning Laravel
25-
26-
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
27-
28-
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
29-
30-
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
31-
32-
## Laravel Sponsors
33-
34-
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
35-
36-
### Premium Partners
37-
38-
- **[Vehikl](https://vehikl.com)**
39-
- **[Tighten Co.](https://tighten.co)**
40-
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
41-
- **[64 Robots](https://64robots.com)**
42-
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
43-
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
44-
- **[Redberry](https://redberry.international/laravel-development)**
45-
- **[Active Logic](https://activelogic.com)**
46-
47-
## Contributing
48-
49-
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
50-
51-
## Code of Conduct
52-
53-
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
54-
55-
## Security Vulnerabilities
56-
57-
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
58-
59-
## License
60-
61-
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
1+
# Booked
Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
<?php
22

3-
namespace App\Livewire;
3+
namespace App\Filament\Home\Pages;
44

55
use Filament\Forms\Components\DatePicker;
66
use Filament\Forms\Components\Select;
77
use Filament\Forms\Components\TextInput;
8-
use Filament\Schemas\Components\Section;
8+
use Filament\Pages\Page;
99
use Filament\Schemas\Components\Tabs;
1010
use Filament\Schemas\Components\Tabs\Tab;
11-
use Filament\Schemas\Concerns\InteractsWithSchemas;
12-
use Filament\Schemas\Contracts\HasSchemas;
1311
use Filament\Schemas\Schema;
14-
use Livewire\Component;
1512

16-
class HomePageSearch extends Component implements HasSchemas
13+
class Home extends Page
1714
{
18-
use InteractsWithSchemas;
15+
protected string $view = 'filament.home.pages.home';
16+
17+
protected static ?string $slug = '/';
18+
19+
protected ?string $heading = '';
20+
21+
protected static bool $shouldRegisterNavigation = false;
1922

2023
public ?array $data = [];
2124

@@ -68,11 +71,6 @@ public function submit()
6871
{
6972
$this->validate();
7073

71-
return redirect()->route('search.results', $this->data);
72-
}
73-
74-
public function render()
75-
{
76-
return view('livewire.home-page-search');
74+
return redirect()->route('filament.home.pages.search', $this->data);
7775
}
7876
}

app/Filament/Home/Pages/Search.php

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
<?php
2+
3+
namespace App\Filament\Home\Pages;
4+
5+
use App\Models\Route;
6+
use CodeWithDennis\FilamentLucideIcons\Enums\LucideIcon;
7+
use Filament\Actions\Action;
8+
use Filament\Forms\Components\DatePicker;
9+
use Filament\Forms\Components\Select;
10+
use Filament\Forms\Components\TextInput;
11+
use Filament\Infolists\Components\RepeatableEntry;
12+
use Filament\Infolists\Components\TextEntry;
13+
use Filament\Pages\Page;
14+
use Filament\Schemas\Components\Fieldset;
15+
use Filament\Schemas\Components\Flex;
16+
use Filament\Schemas\Components\Section;
17+
use Filament\Schemas\Components\View;
18+
use Filament\Schemas\Schema;
19+
use Livewire\Attributes\Url;
20+
21+
class Search extends Page
22+
{
23+
protected string $view = 'filament.home.pages.search';
24+
25+
protected ?string $heading = '';
26+
27+
protected static bool $shouldRegisterNavigation = false;
28+
29+
#[Url]
30+
public string $from = '';
31+
#[Url]
32+
public string $to = '';
33+
#[Url]
34+
public string $date = '';
35+
#[Url]
36+
public string $passengers = '';
37+
38+
public function mount()
39+
{
40+
$this->form->fill([
41+
'from' => $this->from,
42+
'to' => $this->to,
43+
'date' => $this->date,
44+
'passengers' => $this->passengers,
45+
]);
46+
}
47+
48+
public function content(Schema $schema): Schema
49+
{
50+
$schema = parent::content($schema);
51+
52+
return $schema
53+
->record(Route::query()
54+
->where('origin_city', $this->from)
55+
->where('destination_city', $this->to)
56+
->orderBy('departure_time')
57+
->get()->all())
58+
->columns(12)
59+
->components([
60+
Section::make('filters')
61+
->heading('Filters')
62+
->columnSpan(3)
63+
->description('Use the filters below to refine your search results.')
64+
->schema([
65+
// Add filter components here, e.g., TextInput, Select, etc.
66+
]),
67+
Section::make()
68+
->contained(false)
69+
->columnSpan(9)
70+
->schema([
71+
RepeatableEntry::make('*')
72+
->hiddenLabel()
73+
->contained(false)
74+
->extraAttributes(['class' => 'gap-4'])
75+
->schema([
76+
Section::make()
77+
->collapsible()
78+
->icon(fn (Route $record) => 'logo-' . $record->operator->logo)
79+
->iconSize('lg')
80+
->heading(fn (Route $record) => $record->operator->name)
81+
->description(fn (Route $record) => $record->departure_time->format('h:i A') . ' - ' . $record->arrival_time->format('h:i A'))
82+
->afterHeader([
83+
TextEntry::make('bus.category')
84+
->hiddenLabel()
85+
->badge()
86+
->color(fn (Route $record) => $record->bus->category?->getColor() ?? 'gray'),
87+
TextEntry::make('bus.type')
88+
->hiddenLabel()
89+
->badge()
90+
->color(fn (Route $record) => $record->bus->type?->getColor() ?? 'gray'),
91+
])
92+
->schema([
93+
TextEntry::make('bus.bus_number')
94+
->hiddenLabel()
95+
->label('Bus Number')
96+
->size('lg')
97+
->weight('bold'),
98+
Flex::make([
99+
TextEntry::make('origin_city')
100+
->hiddenLabel()
101+
->icon(LucideIcon::MapPin)
102+
->size('lg')
103+
->grow(false),
104+
View::make('filament.schemas.components.route-duration'),
105+
TextEntry::make('destination_city')
106+
->hiddenLabel()
107+
->icon(LucideIcon::MapPin)
108+
->size('lg')
109+
->grow(false),
110+
])->columnSpanFull(),
111+
Flex::make([
112+
TextEntry::make('departure_time')
113+
->hiddenLabel()
114+
->dateTime('h:i A, d M'),
115+
TextEntry::make('arrival_time')
116+
->hiddenLabel()
117+
->dateTime('h:i A, d M')
118+
->grow(false),
119+
])->columnSpanFull(),
120+
TextEntry::make('bus.seats_available')
121+
->hiddenLabel()
122+
->label('Seats Available')
123+
->color('success'),
124+
])
125+
->footer([
126+
Flex::make([
127+
TextEntry::make('bus.min_price')
128+
->hiddenLabel()
129+
->money('USD', 100)
130+
->color('primary')
131+
->size('lg')
132+
->weight('bold'),
133+
Action::make('book')
134+
->label('Book Now')
135+
->icon(LucideIcon::Ticket)
136+
->outlined()
137+
->url(fn (Route $record) => $record)
138+
->openUrlInNewTab()
139+
->button(),
140+
])->columnSpanFull()->extraAttributes([
141+
'class' => 'search-result-footer items-center',
142+
]),
143+
]),
144+
])
145+
]),
146+
]);
147+
}
148+
149+
public function form(Schema $schema): Schema
150+
{
151+
return $schema
152+
->columns(8)
153+
->schema([
154+
TextInput::make('from')
155+
->columnSpan(2)
156+
->required()
157+
->placeholder('Enter departure location'),
158+
TextInput::make('to')
159+
->columnSpan(2)
160+
->required()
161+
->placeholder('Enter destination location'),
162+
DatePicker::make('date')
163+
->columnSpan(2)
164+
->required()
165+
->placeholder('Select travel date'),
166+
Select::make('passengers')
167+
->columnSpan(2)
168+
->required()
169+
->options([
170+
'1' => '1 Passenger',
171+
'2' => '2 Passengers',
172+
'3' => '3 Passengers',
173+
'4' => '4 Passengers',
174+
'5' => '5 Passengers',
175+
])
176+
->placeholder('Select number of passengers'),
177+
]);
178+
}
179+
180+
public function search()
181+
{
182+
$this->validate([
183+
'from' => 'required|string|max:255',
184+
'to' => 'required|string|max:255',
185+
'date' => 'required|date',
186+
'passengers' => 'required|in:1,2,3,4,5',
187+
]);
188+
189+
dd($this->from, $this->to, $this->date, $this->passengers);
190+
// You can replace this with actual search logic, such as querying a database or an API.
191+
// For example, you might want to redirect to a results page:
192+
// return redirect()->route('search.results', [
193+
// 'from' => $this->from,
194+
// 'to' => $this->to,
195+
// 'date' => $this->date,
196+
// 'passengers' => $this->passengers,
197+
// ]);
198+
199+
// For now, we will just dump the search parameters for demonstration purposes.
200+
// In a real application, you would replace this with actual search logic.
201+
return redirect()->route('filament.home.pages.search', [
202+
'from' => $this->from,
203+
'to' => $this->to,
204+
'date' => $this->date,
205+
'passengers' => $this->passengers,
206+
]);
207+
}
208+
}

app/Filament/Operator/Resources/RouteResource.php

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)