i have model below and i run php artisan make:filament-resource Application --generat
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\Pivot;
class Application extends Pivot
{
use HasFactory;
/
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'program_id',
'applicant_id',
'status',
'values',
];
public $table = 'applications';
/
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'id' => 'integer',
'program_id' => 'integer',
'applicant_id' => 'integer',
'values' => 'array',
];
public function program(): BelongsTo
{
return $this->belongsTo(Program::class);
}
public function applicant(): BelongsTo
{
return $this->belongsTo(Applicant::class);
}
public function reviews(): HasMany
{
return $this->hasMany(Review::class);
}
public function reviewers(): BelongsToMany
{
return $this->belongsToMany(Reviewer::class, 'reviews')
->using(Review::class)
->as('review')
->withPivot('id', 'note', 'reviewer_id', 'application_id')
->withTimestamps();
}
}
will generate resource with columns and filters empty and with another model or pivot table work well what the problem ?
->columns([
//
])
->filters([
//
])
2 Replies
I've found that when I use
--generate
but haven't run the migrations already, it doesn't build the columns
/filters
sections, because it can't inspect the db for them.i find the problem its from enum property but now faced new problem with pivot model its appear when create new element to this model resource and the when create and create another everything it goes well??