Coolman
Coolman
FFilament
Created by Stormageddon, Dark Lord of All on 6/26/2024 in #❓┊help
Import Model still trying to use user_id despite specifying a different model
4 replies
FFilament
Created by nathan269_ on 6/21/2024 in #❓┊help
What is the best/easiest way to overwrite a resource within a package?
You can create your own resource and extend it from the one you want to edit Example: use path to vendor/z3d0x/filament-logger/src/Resources/ActivityResource.php; class MyResource extends ActivityResource
3 replies
FFilament
Created by Asmit Nepali on 5/17/2024 in #❓┊help
How to make Select field disable to edit but it must send the data.
Why not:
Select::make('permission_id')
->label('Permissions')
->relationship('permissions',
'title',
modifyQueryUsing: function(Builder $query, Callable $get) {
if($get('role_id')) {
//query the role permissions
}
//else empty options

})
->dehydrated(true)
->required()
->multiple()
->searchable()
->preload(),
Select::make('permission_id')
->label('Permissions')
->relationship('permissions',
'title',
modifyQueryUsing: function(Builder $query, Callable $get) {
if($get('role_id')) {
//query the role permissions
}
//else empty options

})
->dehydrated(true)
->required()
->multiple()
->searchable()
->preload(),
Tbh I don't know if the modifyQueryUsing accepts other params other than the Builder $query
10 replies
FFilament
Created by Matteo G on 6/6/2024 in #❓┊help
Saving Optional Relationship to db does not persist
do you have a repo so that I can check the code?
33 replies
FFilament
Created by Matteo G on 6/6/2024 in #❓┊help
Saving Optional Relationship to db does not persist
can you try this on the Poster Model
public function book(): BelongsTo
{
return $this->belongsTo(Book::class, 'book_id', 'id');
}
public function book(): BelongsTo
{
return $this->belongsTo(Book::class, 'book_id', 'id');
}
33 replies
FFilament
Created by Matteo G on 6/6/2024 in #❓┊help
Saving Optional Relationship to db does not persist
but that is on the Bookresource or Bookposterresource?
33 replies
FFilament
Created by Matteo G on 6/6/2024 in #❓┊help
Saving Optional Relationship to db does not persist
I think the poster relation is trying to get the key from a column that doesnt exist...
33 replies
FFilament
Created by Matteo G on 6/6/2024 in #❓┊help
Saving Optional Relationship to db does not persist
Thats my guess
33 replies
FFilament
Created by Matteo G on 6/6/2024 in #❓┊help
Saving Optional Relationship to db does not persist
if this is a one to one relation, only the belongsto table needs the foreign key (in this case, the book_id on the book_poster table). The problem must be on the poster() method on the book Model that it map the relation
33 replies
FFilament
Created by Matteo G on 6/6/2024 in #❓┊help
Saving Optional Relationship to db does not persist
hows the mapping of the foreign keys? Do you have a book_id on the poster table?
33 replies
FFilament
Created by Matteo G on 6/6/2024 in #❓┊help
Saving Optional Relationship to db does not persist
is it a one to one relation? So that 1 book has 1 poster and vice-versa?
33 replies
FFilament
Created by Matteo G on 6/6/2024 in #❓┊help
Saving Optional Relationship to db does not persist
Does both the entities (model) have their relations defined?
33 replies
FFilament
Created by TheNastyPasty on 6/7/2024 in #❓┊help
Is it somehow possible to access the value of a different field?
Components\ImageEntry::make('photo')
->label(function ($component) {
$index = explode('.', $component->getStatePath())[1];
$data = $component
->getContainer()
->getParentComponent()
->getState()[$index];

return $data['first'] . ' ' . $data['last'];
}),
Components\ImageEntry::make('photo')
->label(function ($component) {
$index = explode('.', $component->getStatePath())[1];
$data = $component
->getContainer()
->getParentComponent()
->getState()[$index];

return $data['first'] . ' ' . $data['last'];
}),
Saw this on a discussion on the filament repo, you can trial and error to access the Model $record relation with it.
10 replies
FFilament
Created by TheNastyPasty on 6/7/2024 in #❓┊help
Is it somehow possible to access the value of a different field?
Oh this is infolists. Ok that changes a bit.
10 replies
FFilament
Created by TheNastyPasty on 6/7/2024 in #❓┊help
Is it somehow possible to access the value of a different field?
Can't you just pass Callable $get and use $get('operating_expenses_name') ?
10 replies
FFilament
Created by Barbaracrlp on 6/7/2024 in #❓┊help
Redirect non-authorized users.
Hello there! I think your best choice is to create a custom authenticate.php that extends the one on the authMiddleware on the panelProvider. Like this
<?php

namespace Filament\Http\Middleware;

use Filament\Facades\Filament;
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Database\Eloquent\Model;

class Authenticate extends Middleware
{
/**
* @param array<string> $guards
*/
protected function authenticate($request, array $guards): void
{
$guard = Filament::auth();

if (! $guard->check()) {
$this->unauthenticated($request, $guards);

return;
}

$this->auth->shouldUse(Filament::getAuthGuard());

/** @var Model $user */
$user = $guard->user();

$panel = Filament::getCurrentPanel();

if (!$user->canAccessPanel($panel)) {
redirect()->route('home);
}

# abort_if(
# $user instanceof FilamentUser ?
# (! $user->canAccessPanel($panel)) :
# (config('app.env') !== 'local'),
# 403,
#);
}

protected function redirectTo($request): ?string
{
return Filament::getLoginUrl();
}
}
<?php

namespace Filament\Http\Middleware;

use Filament\Facades\Filament;
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Database\Eloquent\Model;

class Authenticate extends Middleware
{
/**
* @param array<string> $guards
*/
protected function authenticate($request, array $guards): void
{
$guard = Filament::auth();

if (! $guard->check()) {
$this->unauthenticated($request, $guards);

return;
}

$this->auth->shouldUse(Filament::getAuthGuard());

/** @var Model $user */
$user = $guard->user();

$panel = Filament::getCurrentPanel();

if (!$user->canAccessPanel($panel)) {
redirect()->route('home);
}

# abort_if(
# $user instanceof FilamentUser ?
# (! $user->canAccessPanel($panel)) :
# (config('app.env') !== 'local'),
# 403,
#);
}

protected function redirectTo($request): ?string
{
return Filament::getLoginUrl();
}
}
4 replies
FFilament
Created by Coolman on 2/15/2024 in #❓┊help
FilamentColor::register() not working properly
Ok, after looking at the source code I was able to use the classes with:
->extraInputAttributes([
'class' => 'bg-custom-50 dark:bg-custom-400/10',
'style' => \Filament\Support\get_color_css_variables(
'success',
shades: [50, 400, 600],
),
])
->extraInputAttributes([
'class' => 'bg-custom-50 dark:bg-custom-400/10',
'style' => \Filament\Support\get_color_css_variables(
'success',
shades: [50, 400, 600],
),
])
6 replies
FFilament
Created by Coolman on 2/15/2024 in #❓┊help
FilamentColor::register() not working properly
Hey thanks for the reply but I'm using the default colors of filament, they already exist. For example if I'm sending a notification of type success the color will be green but in the register method I say that 'success' is Color::Amber it doesn't work
6 replies
FFilament
Created by Coolman on 8/3/2023 in #❓┊help
Missing files running php artisan vendor:publish --tag="filament-views" on filament v3
Thanks and likewise 👍🏻
57 replies