FrozenNode / Laravel-Administrator

An administrative interface package for Laravel
http://administrator.frozennode.com/
MIT License
1.94k stars 502 forks source link

Filtering by mulitple fields from relation, filtering by nested relation's field #991

Open mvysh opened 8 years ago

mvysh commented 8 years ago

Is it possible to filter by muliple fields from one relation and not them to be overridden (because of same key for relationship name)? Can nested relations be used? Example. Applicant belongsTo Customer, Applicant hasOne Registration. 1) Can I filter on both applicant.name and applicant.surname from registration? 2) Filter by customer.name from registrations (registration -> applicant -> customer.name).

mvysh commented 8 years ago

I figured out how to add two filter fields by applicant. I've created duplicate relation for the model with other name. I've also suceeded in adding customers relation directly to registration (in framework it works fine).

public function customer()
    {
        if(empty($this->created_at)) return;

        return $this->applicant->belongsTo('App\Models\Customer');
    }

But in admin I have next error:

The 'customer' relationship field you supplied for registrations is not a valid relationship method name on the supplied Eloquent model