Skip to content

Instantly share code, notes, and snippets.

@EricMcWinNer
Created January 11, 2021 00:21
Show Gist options
  • Save EricMcWinNer/f630c7daf51173e26b159f034a7c45c0 to your computer and use it in GitHub Desktop.
Save EricMcWinNer/f630c7daf51173e26b159f034a7c45c0 to your computer and use it in GitHub Desktop.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Wallet extends Model
{
/**
* Get the owner of the relationship which could either be a broker or a company
*/
public function walletable()
{
return $this->morphTo('walletable', 'walletable_type', 'walletable_id');
// The first argument is the function name, we can also use the magic constant __FUNCTION__ like so
// return $this->morphTo(__FUNCTION__, 'walletable_type', 'walletable_id');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment