Skip to content

Commit

Permalink
Merge pull request #17 from langleyfoxall/IsRelatedToTrait
Browse files Browse the repository at this point in the history
IsRelatedTo trait
  • Loading branch information
DivineOmega authored Aug 31, 2018
2 parents 450aea9 + 83054de commit cbf1471
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/LangleyFoxall/Helpers/Traits/IsRelatedTo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace LangleyFoxall\Helpers\Traits;

use Illuminate\Database\Eloquent\Model;
use LangleyFoxall\Helpers\Models;

trait IsRelatedTo
{
/**
* Check if the current model is related to a specified model
*
* @param Model|array $relations
* @throws \InvalidArgumentException|\Exception
* @return bool
*/
function isRelatedTo($model)
{
return Models::areRelated($this, $model);
}

}

0 comments on commit cbf1471

Please sign in to comment.