Created
February 5, 2020 19:11
-
-
Save ambrosiora/e65169f5dba94b2822ed3bcedaeb8e46 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; | |
use Illuminate\Database\Eloquent\Model; | |
class PapelUsuario extends Model | |
{ | |
protected $table = 'papel_usuarios'; | |
public function users() | |
{ | |
return $this->belongsToMany('App\User', 'user_sistema_papel_usuarios')->withPivot('sistema_id');//->as('user_sistema_papel_usuarios'); | |
} | |
public function sistemas() | |
{ | |
return $this->belongsToMany('App\Sistemas', 'user_sistema_papel_usuarios')->withPivot('user_id');//->as('user_sistema_papel_usuarios'); | |
} | |
// public function newPivot(Model $parent, array $attributes, $table, $exists, $using = NULL) | |
// { | |
// if ($parent instanceof Sistema) { | |
// return new SistemaGroupPivot($attributes, $table, $exists); | |
// } | |
// if ($parent instanceof User) { | |
// return new UserGroupPivot($attributes, $table, $exists); | |
// } | |
// return parent::newPivot($parent, $attributes, $table, $exists); | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment