Pan
Pan
FFilament
Created by Pan on 2/20/2024 in #❓┊help
Images & Barcode not working when web hosted (Hostinger)
No description
16 replies
FFilament
Created by Pan on 2/20/2024 in #❓┊help
Images & Barcode not working when web hosted (Hostinger)
No description
16 replies
FFilament
Created by Pan on 2/16/2024 in #❓┊help
Searchable either name or barcode
No description
7 replies
FFilament
Created by Pan on 2/16/2024 in #❓┊help
Searchable either name or barcode
No description
7 replies
FFilament
Created by Pan on 2/9/2024 in #❓┊help
Upgrade from 3.0 to 3.2 led to SpatieMedia::hasRelationship does not exist in my livewire
another bump, now, i tried rolling back and i still get the same error
16 replies
FFilament
Created by Pan on 2/9/2024 in #❓┊help
Upgrade from 3.0 to 3.2 led to SpatieMedia::hasRelationship does not exist in my livewire
bump 🥹
16 replies
FFilament
Created by Pan on 2/9/2024 in #❓┊help
Upgrade from 3.0 to 3.2 led to SpatieMedia::hasRelationship does not exist in my livewire
actually it occurs on pages wherein I am using SpatieMediaLibraryImageColumn like within the filament itself.
16 replies
FFilament
Created by Pan on 2/2/2024 in #❓┊help
Get the owner record while at their Edit Page
is there something I am missing on how to get the ownerRecord when in EditPage of a record?
3 replies
FFilament
Created by Pan on 1/24/2024 in #❓┊help
Custom Action
hi, i've posted all the codes, I really need help. Thank you!
19 replies
FFilament
Created by Pan on 1/24/2024 in #❓┊help
Custom Action
bump, is the problem the type of relationship I used for associate not to work?
19 replies
FFilament
Created by Pan on 1/24/2024 in #❓┊help
Custom Action
Equipment model code
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Equipment extends Model
{
use HasFactory;
protected $fillable = [
'name','user_id'
];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Equipment extends Model
{
use HasFactory;
protected $fillable = [
'name','user_id'
];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}
19 replies
FFilament
Created by Pan on 1/24/2024 in #❓┊help
Custom Action
Here are the codes for the User model
namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable implements FilamentUser
{
use HasApiTokens, HasFactory, Notifiable;

/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
'role_id',
];

/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];

/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
public function role(): BelongsTo
{
return $this->belongsTo(Role::class);
}

public function equipments(): HasMany
{
return $this->hasMany(Equipment::class);
}

public function isAdmin(): bool
{
return $this->role->name === 'Admin';
}

public function canAccessPanel(Panel $panel): bool
{
// Uncomment this to require roles to access panel
if ($panel->getId() === 'admin'){
return str_contains($this->role_id, 5);
}
if ($panel->getId() === 'moderator'){
if (str_contains($this->role_id, 4) || str_contains($this->role_id, 5)){
return true;
}return false;
}
return true;

}
}
namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable implements FilamentUser
{
use HasApiTokens, HasFactory, Notifiable;

/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
'role_id',
];

/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];

/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
public function role(): BelongsTo
{
return $this->belongsTo(Role::class);
}

public function equipments(): HasMany
{
return $this->hasMany(Equipment::class);
}

public function isAdmin(): bool
{
return $this->role->name === 'Admin';
}

public function canAccessPanel(Panel $panel): bool
{
// Uncomment this to require roles to access panel
if ($panel->getId() === 'admin'){
return str_contains($this->role_id, 5);
}
if ($panel->getId() === 'moderator'){
if (str_contains($this->role_id, 4) || str_contains($this->role_id, 5)){
return true;
}return false;
}
return true;

}
}
I'll send the next Equipmentmodel
19 replies
FFilament
Created by Pan on 1/24/2024 in #❓┊help
Custom Action
I tried but it still does the same, I also added the use App\Models\User;
Tables\Actions\Action::make('Borrow Test')
->form([
Forms\Components\Select::make('name')
->searchable()
->options([
'1' => 'VOM',
])
//Equipment::query()->pluck('name','barcode')
//->getSearchResultsUsing(fn (string $search): array => Equipment::where('barcode', 'like', "%{$search}%")->limit(50)->pluck('name')->toArray())
])
->action(function (array $data, Equipment $equipment): void{
$user = User::find(1);
$equipment->user()->associate($user);
$equipment->save();
})
Tables\Actions\Action::make('Borrow Test')
->form([
Forms\Components\Select::make('name')
->searchable()
->options([
'1' => 'VOM',
])
//Equipment::query()->pluck('name','barcode')
//->getSearchResultsUsing(fn (string $search): array => Equipment::where('barcode', 'like', "%{$search}%")->limit(50)->pluck('name')->toArray())
])
->action(function (array $data, Equipment $equipment): void{
$user = User::find(1);
$equipment->user()->associate($user);
$equipment->save();
})
Also for some reason the ->options(Equipment::query()->pluck('name','barcode')) stopped working so I tried temporarily the options with hard coded options and I get this error Filament\Forms\Components\Select::isOptionDisabled(): Argument #2 ($label) must be of type string, null given But focusing on the main issue is that it does the same where it also creates a new record instead of associating the user_id to the VOM
19 replies
FFilament
Created by Pan on 1/24/2024 in #❓┊help
Custom Action
No description
19 replies
FFilament
Created by Pan on 1/24/2024 in #❓┊help
Custom Action
I still get the same error SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value In my model I have this
class Equipment extends Model
{
use HasFactory;
protected $fillable = [
'name','user_id'
];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}
class Equipment extends Model
{
use HasFactory;
protected $fillable = [
'name','user_id'
];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}
19 replies
FFilament
Created by Pan on 1/24/2024 in #❓┊help
Custom Action
Thanks it seem to should work fine now since I get a new error after trying the code you gave.
->action(function (array $data, Equipment $equipment): void{
$equipment->user_id = 1;
$equipment->save();
})
->action(function (array $data, Equipment $equipment): void{
$equipment->user_id = 1;
$equipment->save();
})
I get an error SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value
insert into `equipment` (`user_id`, `updated_at`, `created_at`) values (1, 2024-01-24 23:40:49, 2024-01-24 23:40:49)
insert into `equipment` (`user_id`, `updated_at`, `created_at`) values (1, 2024-01-24 23:40:49, 2024-01-24 23:40:49)
I also have in my AppServiceProvider.php
public function boot(): void
{
//
Model::unguard();
}
public function boot(): void
{
//
Model::unguard();
}
19 replies
FFilament
Created by Pan on 1/18/2024 in #❓┊help
Change relation manager to instead creating a new record, select from an existing record to attach.
I found out that there is an appropriate headeraction for it using "AssosciateAction" at https://filamentphp.com/docs/3.x/panels/resources/relation-managers#associating-and-dissociating-records
4 replies
FFilament
Created by Pan on 11/3/2023 in #❓┊help
Moving specific Resource for a different panel
Damn, Thank you, I found the mistake, I thought the use Filament\Resources\Pages\CreateRecord; use Filament\Resources\Pages\EditRecord; use Filament\Resources\Pages\ListRecords; Should also be adjusted to use Filament\Moderator\Resources\Pages\CreateRecord; use Filament\Moderator\Resources\Pages\EditRecord; use Filament\Moderator\Resources\Pages\ListRecords; Thank you, I thought I'd give up and start from scratch!
8 replies
FFilament
Created by Pan on 11/3/2023 in #❓┊help
Moving specific Resource for a different panel
No description
8 replies