Self Relation on Model with date Constraint - Possible?

Posted 1 year ago by mfoote

Laravel : 5.2 PHP: 5.6

I am trying to figure out how to ask this...

Is it possible to add a relation to self and then exclude anything newer than the current selection....

I am trying to determine if a call is unique by determining if a Call has Calls before the Current Call- I know crazy way to ask it heh... but basically this...


namespace App;

use Illuminate\Database\Eloquent\Model;

class Call extends Model
    public function _previous_calls()
        return $this->hasMany('App\Call', 'ani', 'ani')->where('start_time', '<', $this->start_time);


it seems like $this->start_time is not valid because i am eager loading in my controller.

Please sign in or create an account to participate in this conversation.