Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Nov 21, 2023
1 parent 81fc5fd commit 8e8703c
Show file tree
Hide file tree
Showing 14 changed files with 1,375 additions and 128 deletions.
35 changes: 35 additions & 0 deletions app/Filament/Pages/Auth/Login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace App\Filament\Pages\Auth;

use Filament\Pages\Auth\Login as BaseLogin;

class Login extends BaseLogin
{
public function mount(): void
{
parent::mount();

$this->fillTestCredentials();
}

/**
* When `APP_ENV` is set to `local`, fill the login form with test credentials.
*
* @return void
*/
private function fillTestCredentials(): void
{
if (! app()->isLocal()) {
return;
}

$this->form->fill([
'email' => '[email protected]',
'password' => 'password',
'remember' => true,
]);
}
}
20 changes: 19 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@
namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;

use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasAvatar;
use Filament\Panel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Storage;
use Jeffgreco13\FilamentBreezy\Traits\TwoFactorAuthenticatable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
class User extends Authenticatable implements FilamentUser, HasAvatar
{
use HasApiTokens;
use HasFactory;
use Notifiable;
use TwoFactorAuthenticatable;

/**
* The attributes that are mass assignable.
Expand All @@ -25,6 +32,7 @@ class User extends Authenticatable
'name',
'email',
'password',
'avatar_url',
];

/**
Expand All @@ -46,4 +54,14 @@ class User extends Authenticatable
'email_verified_at' => 'datetime',
'password' => 'hashed',
];

public function canAccessPanel(Panel $panel): bool
{
return $this->hasVerifiedEmail();
}

public function getFilamentAvatarUrl(): ?string
{
return $this->avatar_url ? Storage::url($this->avatar_url) : null;
}
}
13 changes: 11 additions & 2 deletions app/Providers/Filament/AdminPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Providers\Filament;

use App\Filament\Pages\Auth\Login;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
Expand All @@ -19,6 +20,7 @@
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use Jeffgreco13\FilamentBreezy\BreezyCore;

class AdminPanelProvider extends PanelProvider
{
Expand All @@ -27,9 +29,8 @@ public function panel(Panel $panel): Panel
return $panel
->default()
->id('admin')
// ->path('admin')
->sidebarCollapsibleOnDesktop()
->login()
->login(Login::class)
->colors([
'primary' => Color::Purple,
])
Expand All @@ -46,6 +47,14 @@ public function panel(Panel $panel): Panel
Widgets\AccountWidget::class,

])
->plugins([
BreezyCore::make()
->myProfile(
hasAvatars: true,
slug: 'settings'
)
->enableTwoFactorAuthentication(),
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
Expand Down
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
],
"license": "MPL-2.0",
"require": {
"php": "^8.3",
"php": "^8.2",
"blade-ui-kit/blade-icons": "^1.5",
"filament/filament": "^3.0",
"filament/spatie-laravel-media-library-plugin": "^3.0",
"guzzlehttp/guzzle": "^7.2",
"jeffgreco13/filament-breezy": "^2.2",
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.3",
"laravel/tinker": "^2.8",
Expand All @@ -33,6 +34,10 @@
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"pestphp/pest": "^2.24",
"pestphp/pest-plugin-faker": "^2.0",
"pestphp/pest-plugin-laravel": "^2.2",
"pestphp/pest-plugin-livewire": "^2.1",
"phpunit/phpunit": "^10.1",
"spatie/laravel-ignition": "^2.0"
},
Expand Down Expand Up @@ -65,6 +70,9 @@
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"test": [
"@php artisan test"
]
},
"extra": {
Expand Down
Loading

0 comments on commit 8e8703c

Please sign in to comment.