25 lines
553 B
PHP
25 lines
553 B
PHP
<?php
|
|
|
|
namespace App\Domains\Attachable\Models\Concerns;
|
|
|
|
use App\Domains\Attachable\Models\Attachment;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
|
|
|
trait HasAttachments
|
|
{
|
|
/**
|
|
* @return MorphToMany<Attachment, Model, $this>
|
|
*/
|
|
public function attachments(): MorphToMany
|
|
{
|
|
return $this->morphToMany(
|
|
Attachment::class,
|
|
'attachable',
|
|
'attachable_attachments',
|
|
'attachable_id',
|
|
'attachment_id',
|
|
);
|
|
}
|
|
}
|