wip
This commit is contained in:
1 parent
2cb88a4290
commit
ff672c3371
21 files changed
+261
-73
No files matched your search
@@ -14,6 +14,7 @@ class KontosTable
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id'),
|
||||
TextColumn::make('gender')->label('Geschlecht'),
|
||||
TextColumn::make('title')->label('Title'),
|
||||
TextColumn::make('first_name')->label('Vorname'),
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Konto;
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
|
||||
class KontoSwitch extends Component
|
||||
{
|
||||
public $kontos = [];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->kontos = Konto::pluck('company', 'id')->all();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.konto-switch');
|
||||
}
|
||||
|
||||
public function swop($konto_id)
|
||||
{
|
||||
User::find(auth()->user()->id)->update(['konto_id' => $konto_id]);
|
||||
|
||||
$this->js('window.location.reload()');
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
|
||||
class TenancySwitch extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.tenancy-switch');
|
||||
}
|
||||
|
||||
public function swop($kammer_id)
|
||||
{
|
||||
User::find(auth()->user()->id)->update(['kammer_id' => $kammer_id]);
|
||||
|
||||
$this->js('window.location.reload()');
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use App\Models\Scopes\KontoScope;
|
||||
use App\Models\Scopes\KontoScope;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -10,9 +10,9 @@ class Gutachter extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
// protected static function booted(): void
|
||||
// {
|
||||
// static::addGlobalScope(new KontoScope);
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::addGlobalScope(new KontoScope);
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ class KontoScope implements Scope
|
||||
*/
|
||||
public function apply(Builder $builder, Model $model): void
|
||||
{
|
||||
$builder->where('konto_id', auth()->user()->konto_id);
|
||||
if (auth()->hasUser()) {
|
||||
$builder->where('konto_id', auth()->user()->konto_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -72,11 +72,11 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
|
||||
];
|
||||
}
|
||||
|
||||
// protected static function booted(): void
|
||||
// {
|
||||
// static::addGlobalScope(new KontoScope);
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::addGlobalScope(new KontoScope);
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
public function getAppAuthenticationSecret(): ?string
|
||||
{
|
||||
|
||||
@@ -46,11 +46,11 @@ class AdminPanelProvider extends PanelProvider
|
||||
->profile()
|
||||
->default()
|
||||
->colors([
|
||||
'primary' => Color::Blue,
|
||||
'primary' => Color::Gray,
|
||||
])
|
||||
->renderHook(
|
||||
PanelsRenderHook::GLOBAL_SEARCH_BEFORE,
|
||||
fn (): string => auth()->user()->hasRole('gutachter_switch') ? Blade::render('@livewire(\'tenancy-switch\')') : false
|
||||
fn (): string => auth()->user()->hasRole('konto_switch') ? Blade::render('@livewire(\'konto-switch\')') : false
|
||||
)
|
||||
->multiFactorAuthentication([
|
||||
EmailAuthentication::make(),
|
||||
@@ -63,6 +63,7 @@ class AdminPanelProvider extends PanelProvider
|
||||
// ->font('Open Sans')
|
||||
->favicon(asset('images/favicon.svg'))
|
||||
->brandLogo(fn () => view('filament.admin.logo'))
|
||||
->brandLogoHeight('2.6rem')
|
||||
->unsavedChangesAlerts()
|
||||
->databaseTransactions()
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
||||
|
||||
Reference in new issue
Block a user