Backend for file uploads attached to any generic model, initially on aircraft and airports #226
This commit is contained in:
22
app/Models/Traits/FilesTrait.php
Normal file
22
app/Models/Traits/FilesTrait.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits;
|
||||
|
||||
use App\Models\File;
|
||||
|
||||
trait FilesTrait
|
||||
{
|
||||
/**
|
||||
* Morph to type of File
|
||||
* @return mixed
|
||||
*/
|
||||
public function files()
|
||||
{
|
||||
return $this->morphMany(
|
||||
File::class,
|
||||
'files', # overridden by the next two anyway
|
||||
'ref_model',
|
||||
'ref_model_id'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user