feat(attachments): add HasAttachments trait to manage attachment relationships
This commit is contained in:
18
app/Domains/Attachable/Models/Concerns/HasAttachments.php
Normal file
18
app/Domains/Attachable/Models/Concerns/HasAttachments.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Attachable\Models\Concerns;
|
||||
|
||||
use App\Domains\Attachable\Models\Attachment;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
trait HasAttachments
|
||||
{
|
||||
/**
|
||||
* @return MorphMany<Attachment, Model>
|
||||
*/
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachable');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user