PHP code example of imagina / media-module

1. Go to this page and download the library: Download imagina/media-module 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/ */

    

imagina / media-module example snippets


 public array $dispatchesEventsWithBindings = [
    'created' => [['path' => 'Modules\Imedia\Events\CreateMedia']],
    'creating' => [],
    'updated' => [['path' => 'Modules\Imedia\Events\UpdateMedia']],
    'updating' => [],
    'deleting' => [['path' => 'Modules\Imedia\Events\DeleteMedia']],
    'deleted' => []
];

/**
* Media Fillable
*/
public $mediaFillable = [
    'mainimage' => 'single'
];

/**
* Relation Media
* Make the Many To Many Morph
*/
public function files()
{
    if (isModuleEnabled('Imedia')) {
        return app(\Modules\Imedia\Relations\FilesRelation::class)->resolve($this);
    }
    return new \Imagina\Icore\Relations\EmptyRelation();
}
 php
//Implementation with Media
 return [
    'files' => $this->whenLoaded('files', fn() => $this->files->byZones($this->mediaFillable, $this)),
];