Created
May 21, 2015 11:15
-
-
Save kerwitz/b746d3d3000cadb21f5c to your computer and use it in GitHub Desktop.
Laravel 5: one to many relation with more then one related column
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Models; | |
class Father extends Illuminate\Database\Eloquent\Model { | |
/** | |
* Get all children that call model their father. | |
* | |
* @return array | |
*/ | |
public function children() { | |
return $this | |
->hasMany('App\Models\Child', 'id', 'biological_father_id') | |
->orWhere('stepfather_id', $this->id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment