Skip to content

Instantly share code, notes, and snippets.

@cursosdesarrolloweb
Last active June 14, 2021 17:17
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 cursosdesarrolloweb/ceefdd7acb510e4f0d4fb240760d7368 to your computer and use it in GitHub Desktop.
Save cursosdesarrolloweb/ceefdd7acb510e4f0d4fb240760d7368 to your computer and use it in GitHub Desktop.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\Pivot;
/**
* Class Tag
* @package App\Models
*/
class Tag extends Model
{
use HasFactory;
/**
* @return BelongsToMany
*/
public function projects(): BelongsToMany {
return $this->belongsToMany(Project::class)
->using(new class extends Pivot {
use MyTrait; // ¡REEMPLAZAR POR TU TRAIT!
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment