Skip to content

Commit

Permalink
Merge pull request #8 from lara-zeus/v3
Browse files Browse the repository at this point in the history
support Filament V3
  • Loading branch information
atmonshi authored Sep 26, 2023
2 parents af7bc8d + a501f7d commit d96e486
Show file tree
Hide file tree
Showing 169 changed files with 36,294 additions and 4,912 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Zeus Kit](https://larazeus.com/images/zeus-kit.png)](https://github.com/lara-zeus/zeus)
[![Zeus Kit](https://larazeus.com/images/zeus-banner.png)](https://github.com/lara-zeus/zeus)

<p align="center">

Expand All @@ -11,11 +11,11 @@

</p>

# Laravel Zeus
provide you with a collection of Laravel packages that help you build your site faster and focus on your business
# Lara Zeus
provide you with a collection of Laravel packages and filament plugins that help you build your site faster and focus on your business

## Intro
this project is a standalone app., a Starter Kit; it's pre-configured to run all Zeus packages and some extra perks.
This project is a standalone app, a Starter Kit; it's pre-configured to run all Zeus packages and some extra perks.

- Layout and Widget manager using [lara Zeus Rain](https://larazeus.com/rain)
- Posts and pages using [lara Zeus Sky](https://larazeus.com/sky)
Expand All @@ -24,7 +24,6 @@ this project is a standalone app., a Starter Kit; it's pre-configured to run all
- Forms builder using [lara Zeus Bolt](https://larazeus.com/bolt)
- Login, registration, and profile using [Laravel Breeze](https://laravel.com/docs/master/starter-kits#laravel-breeze)
- Users and permissions management using [Filament Shield](https://github.com/bezhanSalleh/filament-shield#shieldsuper-admin)
- Dashboard Widget Counter [Overlook](https://github.com/awcodes/overlook)

## Installations
you can start with
Expand All @@ -50,8 +49,14 @@ php artisan make:filament-user
## Configuration

### Layout
- create your first layout and set the slug in the 'zeus-rain' config file.
- create your navigation and set the slug in the 'Zeus' config file.
- create your first layout and set the slug in the 'AdminPanelProvider' file:
```php
RainPlugin::make()
->defaultLayout('new-page')
```
the default is: `home-page`.

- create your navigation and set the slug in the 'zeus.php' config file. the default is: `home-nav`

### Build assets
run
Expand Down
73 changes: 73 additions & 0 deletions app/Classes/RenderNavItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace App\Classes;

use LaraZeus\Sky\SkyPlugin;

class RenderNavItem
{
public static function render(array $item, string $class = ''): string
{
$color = 'border-b border-b-secondary-500 text-secondary-500';

if ($item['type'] === 'page-link' || $item['type'] === 'page_link') {
$page = SkyPlugin::get()->getModel('Post')::page()->find($item['data']['page_id']) ?? '';
$activeClass = (request()->routeIs('page', $page)) ? $color : 'border-transparent';

return '<a class="'.$class.' '.$activeClass.'"
target="'.($item['data']['target'] ?? '_self').'"
href="'.route('page', $page).'"
>'.
$item['label'].
'</a>';
} elseif ($item['type'] === 'post-link' || $item['type'] === 'post_link') {
$post = SkyPlugin::get()->getModel('Post')::find($item['data']['post_id']) ?? '';
$activeClass = (request()->routeIs('post', $post)) ? $color : 'border-transparent';

return '<a class="'.$class.' '.$activeClass.'"
target="'.($item['data']['target'] ?? '_self').'"
href="'.route('post', $post).'"
>'.
$item['label'].
'</a>';
} elseif ($item['type'] === 'library-link' || $item['type'] === 'library_link') {
$tag = SkyPlugin::get()->getModel('Tag')::find($item['data']['library_id']) ?? '';
$activeClass = (str(request()->url())->contains($tag->library->first()->slug)) ? $color : 'border-transparent';

return '<a class="'.$class.' '.$activeClass.'"
target="'.($item['data']['target'] ?? '_self').'"
href="'.route('library.tag', $tag->slug).'"
>'.
$item['label'].
'</a>';

} elseif ($item['type'] === 'app-link' || $item['type'] === 'app_link') {
$activeClass = (request()->routeIs($item['data']['app_code'])) ? $color : 'border-transparent';

return '<a class="'.$class.' '.$activeClass.'"
target="'.($item['data']['target'] ?? '_self').'"
href="'.url(self::getAppUrl($item['data']['app_code'])).'"
>'.
$item['label'].
'</a>';
} else {
return '<a class="'.$class.'"
target="'.($item['data']['target'] ?? '_self').'"
href="'.$item['data']['url'].'"
>'.
$item['label'].
'</a>';
}
}

private static function getAppUrl($app)
{
return match ($app) {
'blog' => 'blog',
'contact' => 'contact-us',
'faq' => 'blog/faq',
'libraries' => 'blog/library',
'forms' => 'forms',
};
}
}
8 changes: 4 additions & 4 deletions app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
use App\Filament\Resources\UserResource\Pages;
use App\Models\User;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Form;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

Expand All @@ -22,7 +22,7 @@ class UserResource extends Resource

protected static ?string $navigationIcon = 'heroicon-o-lock-closed';

protected static function getNavigationLabel(): string
public static function getNavigationLabel(): string
{
return 'Users';
}
Expand All @@ -37,7 +37,7 @@ public static function getLabel(): string
return 'user';
}

protected static function getNavigationGroup(): ?string
public static function getNavigationGroup(): ?string
{
return 'Users';
}
Expand Down
8 changes: 4 additions & 4 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

namespace App\Models;

use BezhanSalleh\FilamentShield\Traits\HasFilamentShield;
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable implements MustVerifyEmail, FilamentUser
class User extends Authenticatable implements FilamentUser, MustVerifyEmail
{
use HasApiTokens, HasFactory, Notifiable, CanResetPassword, HasFilamentShield;
use CanResetPassword, HasApiTokens, HasFactory, HasRoles, Notifiable;

/**
* The attributes that are mass assignable.
Expand Down Expand Up @@ -46,7 +46,7 @@ class User extends Authenticatable implements MustVerifyEmail, FilamentUser
'password' => 'hashed',
];

public function canAccessFilament(): bool
public function canAccessPanel(\Filament\Panel $panel): bool
{
return true; //str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail();
}
Expand Down
48 changes: 12 additions & 36 deletions app/Policies/CategoryPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,120 +12,96 @@ class CategoryPolicy

/**
* Determine whether the user can view any models.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function viewAny(User $user)
public function viewAny(User $user): bool
{
return $user->can('view_any_category');
}

/**
* Determine whether the user can view the model.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function view(User $user, Category $category)
public function view(User $user, Category $category): bool
{
return $user->can('view_category');
}

/**
* Determine whether the user can create models.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function create(User $user)
public function create(User $user): bool
{
return $user->can('create_category');
}

/**
* Determine whether the user can update the model.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function update(User $user, Category $category)
public function update(User $user, Category $category): bool
{
return $user->can('update_category');
}

/**
* Determine whether the user can delete the model.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function delete(User $user, Category $category)
public function delete(User $user, Category $category): bool
{
return $user->can('delete_category');
}

/**
* Determine whether the user can bulk delete.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function deleteAny(User $user)
public function deleteAny(User $user): bool
{
return $user->can('delete_any_category');
}

/**
* Determine whether the user can permanently delete.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function forceDelete(User $user, Category $category)
public function forceDelete(User $user, Category $category): bool
{
return $user->can('force_delete_category');
}

/**
* Determine whether the user can permanently bulk delete.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function forceDeleteAny(User $user)
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_category');
}

/**
* Determine whether the user can restore.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function restore(User $user, Category $category)
public function restore(User $user, Category $category): bool
{
return $user->can('restore_category');
}

/**
* Determine whether the user can bulk restore.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function restoreAny(User $user)
public function restoreAny(User $user): bool
{
return $user->can('restore_any_category');
}

/**
* Determine whether the user can replicate.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function replicate(User $user, Category $category)
public function replicate(User $user, Category $category): bool
{
return $user->can('replicate_category');
}

/**
* Determine whether the user can reorder.
*
* @return \Illuminate\Auth\Access\Response|bool
*/
public function reorder(User $user)
public function reorder(User $user): bool
{
return $user->can('reorder_category');
}
Expand Down
Loading

0 comments on commit d96e486

Please sign in to comment.