-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
2,594 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\EventResource\Pages; | ||
use App\Filament\Resources\EventResource\RelationManagers; | ||
use App\Models\Event; | ||
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; | ||
|
||
class EventResource extends Resource | ||
{ | ||
protected static ?string $model = Event::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-calendar-date-range'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema(Event::getForm()); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('title'), | ||
Tables\Columns\TextColumn::make('start') | ||
->dateTime("Y-m-d"), | ||
Tables\Columns\TextColumn::make('end') | ||
->dateTime("Y-m-d"), | ||
Tables\Columns\TextColumn::make('location'), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]) | ||
->defaultSort('start_date', "desc"); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListEvents::route('/'), | ||
'create' => Pages\CreateEvent::route('/create'), | ||
'edit' => Pages\EditEvent::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
app/Filament/Resources/EventResource/Pages/CreateEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\EventResource\Pages; | ||
|
||
use App\Filament\Resources\EventResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateEvent extends CreateRecord | ||
{ | ||
protected static string $resource = EventResource::class; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\EventResource\Pages; | ||
|
||
use App\Filament\Resources\EventResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditEvent extends EditRecord | ||
{ | ||
protected static string $resource = EventResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\EventResource\Pages; | ||
|
||
use App\Filament\Resources\EventResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListEvents extends ListRecords | ||
{ | ||
protected static string $resource = EventResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace App\Filament\Widgets; | ||
|
||
use App\Models\Chat; | ||
use App\Models\Document; | ||
use App\Models\Event; | ||
use App\Models\Message; | ||
use Filament\Widgets\StatsOverviewWidget as BaseWidget; | ||
use Filament\Widgets\StatsOverviewWidget\Stat; | ||
use Flowframe\Trend\Trend; | ||
use Flowframe\Trend\TrendValue; | ||
|
||
class StatsOverview extends BaseWidget | ||
{ | ||
protected function getStats(): array | ||
{ | ||
|
||
return [ | ||
$this->getDocuments(), | ||
$this->getChatMessages(), $this->getDocuments(), $this->getEvents(), $this->getMessages()]; | ||
} | ||
|
||
protected function getChatMessages() | ||
{ | ||
$title = "Chats"; | ||
$description = "Chats in the past 7 days"; | ||
|
||
return $this->getTrend($title, $description, Chat::class); | ||
} | ||
|
||
protected function getDocuments() | ||
{ | ||
$title = "Documents"; | ||
$description = "Documents in the past 7 days"; | ||
|
||
return $this->getTrend($title, $description, Document::class); | ||
} | ||
|
||
protected function getEvents() | ||
{ | ||
$title = "Events"; | ||
$description = "Events in the past 7 days"; | ||
|
||
return $this->getTrend($title, $description, Event::class); | ||
} | ||
|
||
protected function getMessages() | ||
{ | ||
$title = "Messages"; | ||
$description = "Messages in the past 7 days"; | ||
|
||
return $this->getTrend($title, $description, Message::class); | ||
} | ||
|
||
protected function getTrend( | ||
string $title, | ||
string $description, | ||
string $model, | ||
) { | ||
|
||
$data = Trend::model($model) | ||
->between( | ||
start: now()->subDays(7), | ||
end: now()->endOfDay(), | ||
) | ||
->perDay() | ||
->count(); | ||
|
||
return Stat::make($title, $data->map(fn (TrendValue $value) => $value->aggregate)->sum()) | ||
->description($description) | ||
->descriptionIcon('heroicon-m-arrow-trending-up') | ||
->chart($data->map(fn (TrendValue $value) => $value->aggregate)->toArray()) | ||
->color('success'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace App\Providers\Filament; | ||
|
||
use Filament\Http\Middleware\Authenticate; | ||
use Filament\Http\Middleware\DisableBladeIconComponents; | ||
use Filament\Http\Middleware\DispatchServingFilamentEvent; | ||
use Filament\Navigation\NavigationItem; | ||
use Filament\Pages; | ||
use Filament\Panel; | ||
use Filament\PanelProvider; | ||
use Filament\Support\Colors\Color; | ||
use Filament\Widgets; | ||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse; | ||
use Illuminate\Cookie\Middleware\EncryptCookies; | ||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken; | ||
use Illuminate\Routing\Middleware\SubstituteBindings; | ||
use Illuminate\Session\Middleware\AuthenticateSession; | ||
use Illuminate\Session\Middleware\StartSession; | ||
use Illuminate\View\Middleware\ShareErrorsFromSession; | ||
|
||
class AdminPanelProvider extends PanelProvider | ||
{ | ||
public function panel(Panel $panel): Panel | ||
{ | ||
return $panel | ||
->default() | ||
->id('admin') | ||
->path('admin') | ||
->login() | ||
->colors([ | ||
'primary' => Color::Amber, | ||
]) | ||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources') | ||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages') | ||
->pages([ | ||
Pages\Dashboard::class, | ||
]) | ||
->navigationItems([ | ||
NavigationItem::make('Collections') | ||
->icon('heroicon-o-code-bracket') | ||
->url("/collections"), | ||
]) | ||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets') | ||
->widgets([]) | ||
->middleware([ | ||
EncryptCookies::class, | ||
AddQueuedCookiesToResponse::class, | ||
StartSession::class, | ||
AuthenticateSession::class, | ||
ShareErrorsFromSession::class, | ||
VerifyCsrfToken::class, | ||
SubstituteBindings::class, | ||
DisableBladeIconComponents::class, | ||
DispatchServingFilamentEvent::class, | ||
]) | ||
->authMiddleware([ | ||
Authenticate::class, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
<?php | ||
|
||
return [ | ||
App\Domains\Sources\WebSearch\WebSearchProvider::class, | ||
App\Providers\AppServiceProvider::class, | ||
App\Providers\Filament\AdminPanelProvider::class, | ||
App\Providers\FortifyServiceProvider::class, | ||
App\Providers\HorizonServiceProvider::class, | ||
App\Providers\JetstreamServiceProvider::class, | ||
\LlmLaraHub\LlmDriver\LlmServiceProvider::class, | ||
App\Domains\Sources\WebSearch\WebSearchProvider::class, | ||
LlmLaraHub\LlmDriver\LlmServiceProvider::class, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.