File: D:/HostingSpaces/SBogers10/boldt.komma.pro/app/Komma/Documents/DocumentsTrait.php
<?php
/**
* Created by PhpStorm.
* User: Pascal
* Date: 02/10/2018
* Time: 13:16
*/
namespace App\Komma\Documents;
use App\Komma\Documents\Models\Document;
use Illuminate\Database\Eloquent\Relations\MorphMany;
trait DocumentsTrait
{
/**
* Get the documents belonging to this model
*
* @return MorphMany
*/
public function documents():MorphMany
{
return $this->morphMany(Document::class, 'documentable')
->orderBy('sort_order');
}
/**
* Get the images through documents belonging to this model
*
* @return \Illuminate\Database\Eloquent\Relations\hasMany
*/
public function images():MorphMany
{
return $this->morphMany(Document::class, 'documentable')
->where('mime_type', 'LIKE', 'image/%')
->orderBy('sort_order');
}
}