HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/netwerkbrabant.komma.pro/app/KommaApp/Documents/DocumentsTrait.php
<?php
/**
 * Created by PhpStorm.
 * User: Pascal
 * Date: 02/10/2018
 * Time: 13:16
 */

namespace App\KommaApp\Documents;


use App\KommaApp\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');
    }
}