morphTo() public method

Define a polymorphic, inverse one-to-one or many relationship.
public morphTo ( string $name = null, string $type = null, string $id = null ) : Illuminate\Database\Eloquent\Relations\MorphTo
$name string
$type string
$id string
return Illuminate\Database\Eloquent\Relations\MorphTo
Exemplo n.º 1
0
 public function morphTo($name = null, $type = null, $id = null)
 {
     if (is_null($name)) {
         $backtrace = debug_backtrace(false, 4);
         $caller = $backtrace[3];
         $name = snake_case($caller['function']);
     }
     return parent::morphTo($name, $type, $id);
 }
Exemplo n.º 2
0
 /**
  * Define an polymorphic, inverse one-to-one or many relationship.
  * Overridden from {@link Eloquent\Model} to allow the usage of the intermediary methods to handle the relation.
  * @return \October\Rain\Database\Relations\BelongsTo
  */
 public function morphTo($name = null, $type = null, $id = null)
 {
     if (is_null($name)) {
         $name = snake_case($this->getRelationCaller());
     }
     return parent::morphTo($name, $type, $id);
 }