forked from MGeurts/genealogy
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Marc Geurts
committed
Jan 24, 2024
1 parent
aca4863
commit fd373b1
Showing
40 changed files
with
2,635 additions
and
62 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
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,107 @@ | ||
<?php | ||
|
||
namespace App\Livewire; | ||
|
||
use App\Models\user; | ||
use Filament\Forms\Concerns\InteractsWithForms; | ||
use Filament\Forms\Contracts\HasForms; | ||
use Filament\Tables; | ||
use Filament\Tables\Concerns\InteractsWithTable; | ||
use Filament\Tables\Contracts\HasTable; | ||
use Filament\Tables\Enums\FiltersLayout; | ||
use Filament\Tables\Filters\Filter; | ||
use Filament\Tables\Table; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\SoftDeletingScope; | ||
use Livewire\Component; | ||
|
||
class users extends Component implements HasForms, HasTable | ||
{ | ||
use InteractsWithForms; | ||
use InteractsWithTable; | ||
|
||
public function table(Table $table): Table | ||
{ | ||
return $table | ||
->query(user::query()) | ||
->columns([ | ||
Tables\Columns\TextColumn::make('surname') | ||
->label(__('user.surname')) | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('firstname') | ||
->label(__('user.firstname')) | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('email') | ||
->label(__('user.email')) | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('email_verified_at') | ||
->label(__('user.email_verified_at')) | ||
->dateTime('Y-m-d h:i') | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('two_factor_confirmed_at') | ||
->label(__('user.two_factor_confirmed_at')) | ||
->dateTime('Y-m-d h:i') | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('current_team.name') | ||
->label(__('user.current_team')), | ||
// Tables\Columns\TextColumn::make('profile_photo_path') | ||
// ->searchable(), | ||
Tables\Columns\TextColumn::make('language') | ||
->label(__('user.language')) | ||
->getStateUsing(function (User $record) { | ||
return strtoupper($record->language); | ||
}) | ||
->searchable(), | ||
Tables\Columns\IconColumn::make('is_developer') | ||
->label(__('user.developer') . ' ?') | ||
->boolean(), | ||
Tables\Columns\TextColumn::make('created_at') | ||
->label(__('user.created_at')) | ||
->dateTime('Y-m-d h:i') | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
Tables\Columns\TextColumn::make('updated_at') | ||
->label(__('user.updated_at')) | ||
->dateTime('Y-m-d h:i') | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
Tables\Columns\TextColumn::make('deleted_at') | ||
->label(__('user.deleted_at')) | ||
->dateTime('Y-m-d h:i') | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
]) | ||
->filters([ | ||
Filter::make('is_developer') | ||
->query(fn (Builder $query): Builder => $query->where('is_developer', true)), | ||
Tables\Filters\TrashedFilter::make(), | ||
], layout: FiltersLayout::AboveContent) | ||
->actions([ | ||
Tables\Actions\DeleteAction::make()->iconButton(), | ||
Tables\Actions\ForceDeleteAction::make()->iconButton(), | ||
Tables\Actions\RestoreAction::make()->iconButton(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
Tables\Actions\ForceDeleteBulkAction::make(), | ||
Tables\Actions\RestoreBulkAction::make(), | ||
]), | ||
]) | ||
->striped(); | ||
} | ||
|
||
public static function getEloquentQuery(): Builder | ||
{ | ||
return parent::getEloquentQuery() | ||
->withoutGlobalScopes([ | ||
SoftDeletingScope::class, | ||
]); | ||
} | ||
|
||
public function render(): View | ||
{ | ||
return view('livewire.users'); | ||
} | ||
} |
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,91 @@ | ||
<?php | ||
|
||
namespace App\Policies; | ||
|
||
use App\Models\User; | ||
use Illuminate\Auth\Access\HandlesAuthorization; | ||
|
||
class UserPolicy | ||
{ | ||
use HandlesAuthorization; | ||
|
||
/** | ||
* Determine whether the user can view any models. | ||
*/ | ||
public function viewAny(User $user): bool | ||
{ | ||
return $user->is_developer; | ||
} | ||
|
||
/** | ||
* Determine whether the user can view the model. | ||
*/ | ||
public function view(User $user, User $model): bool | ||
{ | ||
return $user->is_developer; | ||
} | ||
|
||
/** | ||
* Determine whether the user can create models. | ||
*/ | ||
public function create(User $user): bool | ||
{ | ||
return $user->is_developer; | ||
} | ||
|
||
/** | ||
* Determine whether the user can update the model. | ||
*/ | ||
public function update(User $user, User $model): bool | ||
{ | ||
return $user->is_developer; | ||
} | ||
|
||
/** | ||
* Determine whether the user can delete the model. | ||
*/ | ||
public function delete(User $user, User $model): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* Determine whether the user can delete the model in bulk. | ||
*/ | ||
public function deleteAny(User $user, User $model): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* Determine whether the user can restore the model. | ||
*/ | ||
public function restore(User $user, User $model): bool | ||
{ | ||
return $user->is_developer; | ||
} | ||
|
||
/** | ||
* Determine whether the user can restore the model in bulk. | ||
*/ | ||
public function restoreAny(User $user, User $model): bool | ||
{ | ||
return $user->is_developer; | ||
} | ||
|
||
/** | ||
* Determine whether the user can permanently delete the model. | ||
*/ | ||
public function forceDelete(User $user, User $model): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* Determine whether the user can permanently delete the model in bulk. | ||
*/ | ||
public function forceDeleteAny(User $user, User $model): bool | ||
{ | ||
return false; | ||
} | ||
} |
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
Oops, something went wrong.