Skip to content

Instantly share code, notes, and snippets.

@kerwitz
Created May 21, 2015 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kerwitz/b746d3d3000cadb21f5c to your computer and use it in GitHub Desktop.
Save kerwitz/b746d3d3000cadb21f5c to your computer and use it in GitHub Desktop.
Laravel 5: one to many relation with more then one related column
<?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