PHP code example of okipa / laravel-medialibrary-ext

1. Go to this page and download the library: Download okipa/laravel-medialibrary-ext 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/ */

    

okipa / laravel-medialibrary-ext example snippets



use Illuminate\Database\Eloquent\Model;
use Okipa\MediaLibraryExt\ExtendsMediaAbilities;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;

class Page extends Model implements HasMedia
{
    use InteractsWithMedia;
    use ExtendsMediaAbilities;

	// ...
}

// In your user storing form request for example
public function rules()
{
    return [
        'avatar' => (new User)->getMediaValidationRules('avatar'),
        // your other validation rules
    ];
}

    // Example
    ['mimetypes:image/jpeg,image/png', 'mimes:jpg,jpeg,jpe,png', 'dimensions:min_width=60,min_height=20', 'max:5000'];