Skip to content

Commit

Permalink
Upgrade to filament 3 (#16)
Browse files Browse the repository at this point in the history
* Upgrade packages

* Update octo
  • Loading branch information
a21ns1g4ts authored Oct 11, 2023
1 parent e62b945 commit acf4439
Show file tree
Hide file tree
Showing 34 changed files with 2,437 additions and 2,383 deletions.
11 changes: 11 additions & 0 deletions .bladeformatterrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"indentSize": 4,
"wrapAttributes": "multiline",
"wrapLineLength": 2,
"endWithNewLine": true,
"noMultipleEmptyLines": false,
"useTabs": false,
"sortTailwindcssClasses": true,
"sortHtmlAttributes": "none",
"noPhpSyntaxCheck": false
}
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_DATABASE=octo
DB_USERNAME=sail
DB_PASSWORD=password

Expand Down Expand Up @@ -56,3 +56,5 @@ VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

FILAMENT_FILESYSTEM_DISK=public
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/.phpunit.cache
/node_modules
/public/build
/public/js
/public/css
/public/css
/public/vendor
/public/hot
/public/storage
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

## Introduction

**Project currently in development, do not use in production.**

The purpose of this project is provide a simple way to create web aplications of kind SaaS. We use [Laravel](https://laravel.com/) framework with [Filament Admin](https://filamentphp.com/).

## Getting started
Expand Down Expand Up @@ -67,17 +65,17 @@ You can now access the server at <http://127.0.0.1:8000>

You can now access the server at <http://localhost>

### Dev app
### Install app

To generate data for development purposes, run the following command:
To install, run the following command:

php artisan app:dev
php artisan octo:install

This command will generate data that can be used for testing and development. You can find the implementation details of this command [here](https://github.com/a2insights/octo-core/blob/main/src/Console/SetupDevCommand.php).
This command will install the octo app. You can find the implementation details of this command [here](https://github.com/a2insights/octo-core/blob/main/src/Console/OctoInstallCommand.php).

got to <http://127.0.0.1:8000/dashboard/login> and login with the following credentials:

email: super-admin@octo.dev
email: super_admin@octo.dev
password: 123456

or
Expand All @@ -101,7 +99,7 @@ If you discover any security related issues, please email atila.danvi@outlook.co

## Credits

- [Atila Silva](https://github.com/Atiladanvi)
- [Atila Silva](https://github.com/a21ns1g4ts)
- [All Contributors](../../contributors)

## License
Expand Down
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Octo\Middleware\Http\Middleware\LogViewer::class,
],

'api' => [
Expand Down
23 changes: 19 additions & 4 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
use Cog\Contracts\Ban\Bannable as BannableContract;
use Cog\Laravel\Ban\Traits\Bannable;
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasAvatar;
use Filament\Panel;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use JeffGreco13\FilamentBreezy\Traits\TwoFactorAuthenticatable;
use Illuminate\Support\Facades\Storage;
use Jeffgreco13\FilamentBreezy\Traits\TwoFactorAuthenticatable;
use Laravel\Sanctum\HasApiTokens;
use Octo\Concerns\CanAccessFilament;
use Octo\User\Settings;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable implements FilamentUser, BannableContract, MustVerifyEmail
class User extends Authenticatable implements BannableContract, FilamentUser, HasAvatar, MustVerifyEmail
{
use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable, CanAccessFilament, HasRoles, SoftDeletes, Bannable;
use Bannable, HasApiTokens, HasFactory, HasRoles, Notifiable, SoftDeletes, TwoFactorAuthenticatable;

/**
* The attributes that are mass assignable.
Expand All @@ -28,6 +30,7 @@ class User extends Authenticatable implements FilamentUser, BannableContract, Mu
protected $fillable = [
'name',
'email',
'avatar_url',
'password',
];

Expand All @@ -49,4 +52,16 @@ class User extends Authenticatable implements FilamentUser, BannableContract, Mu
protected $casts = [
'email_verified_at' => 'datetime', 'settings' => Settings::class,
];

public function canAccessPanel(Panel $panel): bool
{
$settings = app(\Octo\Settings\Settings::class);

return ! in_array($this->id, $settings->restrict_users) && $this->hasVerifiedEmail();
}

public function getFilamentAvatarUrl(): ?string
{
return $this->avatar_url ? Storage::url($this->avatar_url) : null;
}
}
48 changes: 24 additions & 24 deletions app/Policies/RolePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class RolePolicy
* Determine whether the user can view any models.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function viewAny(User $user)
public function viewAny(User $user): bool
{
return $user->can('view_any_role');
}
Expand All @@ -26,9 +26,9 @@ public function viewAny(User $user)
*
* @param \App\Models\User $user
* @param \Spatie\Permission\Models\Role $role
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function view(User $user, Role $role)
public function view(User $user, Role $role): bool
{
return $user->can('view_role');
}
Expand All @@ -37,9 +37,9 @@ public function view(User $user, Role $role)
* Determine whether the user can create models.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function create(User $user)
public function create(User $user): bool
{
return $user->can('create_role');
}
Expand All @@ -49,9 +49,9 @@ public function create(User $user)
*
* @param \App\Models\User $user
* @param \Spatie\Permission\Models\Role $role
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function update(User $user, Role $role)
public function update(User $user, Role $role): bool
{
return $user->can('update_role');
}
Expand All @@ -61,9 +61,9 @@ public function update(User $user, Role $role)
*
* @param \App\Models\User $user
* @param \Spatie\Permission\Models\Role $role
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function delete(User $user, Role $role)
public function delete(User $user, Role $role): bool
{
return $user->can('delete_role');
}
Expand All @@ -72,9 +72,9 @@ public function delete(User $user, Role $role)
* Determine whether the user can bulk delete.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function deleteAny(User $user)
public function deleteAny(User $user): bool
{
return $user->can('delete_any_role');
}
Expand All @@ -84,9 +84,9 @@ public function deleteAny(User $user)
*
* @param \App\Models\User $user
* @param \Spatie\Permission\Models\Role $role
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function forceDelete(User $user, Role $role)
public function forceDelete(User $user, Role $role): bool
{
return $user->can('{{ ForceDelete }}');
}
Expand All @@ -95,9 +95,9 @@ public function forceDelete(User $user, Role $role)
* Determine whether the user can permanently bulk delete.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function forceDeleteAny(User $user)
public function forceDeleteAny(User $user): bool
{
return $user->can('{{ ForceDeleteAny }}');
}
Expand All @@ -107,9 +107,9 @@ public function forceDeleteAny(User $user)
*
* @param \App\Models\User $user
* @param \Spatie\Permission\Models\Role $role
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function restore(User $user, Role $role)
public function restore(User $user, Role $role): bool
{
return $user->can('{{ Restore }}');
}
Expand All @@ -118,9 +118,9 @@ public function restore(User $user, Role $role)
* Determine whether the user can bulk restore.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function restoreAny(User $user)
public function restoreAny(User $user): bool
{
return $user->can('{{ RestoreAny }}');
}
Expand All @@ -130,9 +130,9 @@ public function restoreAny(User $user)
*
* @param \App\Models\User $user
* @param \Spatie\Permission\Models\Role $role
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function replicate(User $user, Role $role)
public function replicate(User $user, Role $role): bool
{
return $user->can('{{ Replicate }}');
}
Expand All @@ -141,9 +141,9 @@ public function replicate(User $user, Role $role)
* Determine whether the user can reorder.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
* @return bool
*/
public function reorder(User $user)
public function reorder(User $user): bool
{
return $user->can('{{ Reorder }}');
}
Expand Down
Loading

0 comments on commit acf4439

Please sign in to comment.