© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
6 replies
wandiaprianto

How to access resource from resource?

Help me, i want to access resource from resource
i want to create "promo" from cars

expected url like:
http://127.0.0.1:8000/car/{carId}/promos

so, when i create new promo, it will be related the car_id


this is my code:
Action::make('view_promo')
  ->url(fn ($record) => PromoResource::getUrl('view', ['record' => $record->id])),
Action::make('view_promo')
  ->url(fn ($record) => PromoResource::getUrl('view', ['record' => $record->id])),


this is the result:
Route [filament.admin.resources.car.promos.view] not defined.
Route [filament.admin.resources.car.promos.view] not defined.


i have 2 models:
"Cars" and "Promo"

class Car extends Model implements HasMedia
{
    use HasFactory;
    use InteractsWithMedia;

    /**
     * @var string
     */
    protected $table = 'cars';

    public function promos(): HasMany
    {
        return $this->hasMany(Promo::class, 'car_id');
    }

    ...
}
class Car extends Model implements HasMedia
{
    use HasFactory;
    use InteractsWithMedia;

    /**
     * @var string
     */
    protected $table = 'cars';

    public function promos(): HasMany
    {
        return $this->hasMany(Promo::class, 'car_id');
    }

    ...
}


class Original extends Model implements HasMedia
{
    use HasFactory;
    use InteractsWithMedia;

    /**
     * @var string
     */
    protected $table = 'photos_car_original';

    public function car(): BelongsTo
    {
        return $this->belongsTo(Car::class, 'car_id');
    }
}
class Original extends Model implements HasMedia
{
    use HasFactory;
    use InteractsWithMedia;

    /**
     * @var string
     */
    protected $table = 'photos_car_original';

    public function car(): BelongsTo
    {
        return $this->belongsTo(Car::class, 'car_id');
    }
}


can u help me? thanks
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to access "TextInput" data from Resource to Relation manager?
FilamentFFilament / ❓┊help
3y ago
Access current resource page from widget
FilamentFFilament / ❓┊help
6mo ago
How to create a resource record from another resource?
FilamentFFilament / ❓┊help
3y ago
How to access scoped resource data in RenderHook?
FilamentFFilament / ❓┊help
4mo ago