PHP code example of kaveh / morph-service

1. Go to this page and download the library: Download kaveh/morph-service library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kaveh / morph-service example snippets


Kaveh\LaravelMorphService\MorphServiceProvider::class,

use Illuminate\Database\Eloquent\Relations\MorphMany;
use App\Models\Media;

public function medias(): MorphMany
{
    return $this->morphMany(Media::class, 'mediable');
}

use Kaveh\LaravelMorphService\Services\MediaService;
use Illuminate\Http\UploadedFile;

// Upload media
MediaService::uploadMedia(instance of UploadedFile, instance of Model);
bash
composer dump-autoload
bash
php artisan morph:migrate