Created
February 5, 2020 19:12
-
-
Save ambrosiora/47cdef8c3a7adefc61b82379c01225e5 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 Sistema extends Model | |
{ | |
public function users() | |
{ | |
return $this->belongsToMany('App\User', 'user_sistema_papel_usuarios')->withPivot('papel_usuario_id'); | |
} | |
public function papelUsuarios() | |
{ | |
return $this->belongsToMany('App\PapelUsuario', 'user_sistema_papel_usuarios')->withPivot('user_id'); | |
} | |
// public function newPivot(Model $parent, array $attributes, $table, $exists, $using = NULL) | |
// { | |
// if ($parent instanceof User) { | |
// return new UserGroupPivot($attributes, $table, $exists); | |
// } | |
// if ($parent instanceof PapelUsuario) { | |
// return new PapelUsuarioGroupPivot($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