Created
January 11, 2021 00:10
-
-
Save EricMcWinNer/a182fac6eefa7a605a31c103ca60624b to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
use Illuminate\Database\Eloquent\Model; | |
class Document extends Model | |
{ | |
/** | |
* Get the owner of the relationship which could either be a broker or a company | |
*/ | |
public function documentable() | |
{ | |
return $this->morphTo('documentable', 'documentable_type', 'documentable_id'); | |
// The first argument is the function name, we can also use the magic constant __FUNCTION__ like so | |
// return $this->morphTo(__FUNCTION__, 'documentable_type', 'documentable_id'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment