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/ */
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
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.