Skip to content

Instantly share code, notes, and snippets.

@ambrosiora
Created February 5, 2020 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ambrosiora/47cdef8c3a7adefc61b82379c01225e5 to your computer and use it in GitHub Desktop.
Save ambrosiora/47cdef8c3a7adefc61b82379c01225e5 to your computer and use it in GitHub Desktop.
<?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