PHP code example of laravel-admin / media-manager

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

    

laravel-admin / media-manager example snippets


use LaravelAdmin\MediaManager\Upload;

$media = Upload::handle($request, 'file');


$media = Upload::storage('s3')->handle($request, 'file');

$media = Upload::with('url')->handle($request, 'http://domain.com/somefile.jpg');

$media = Upload::update($current_model)->handle($request, 'file');

$table->integer('media_id')->unsigned()->nullable();
$table->foreign('media_id')->references('id')->on('media')->onDelete('set null');


namespace App;

use Illuminate\Database\Eloquent\Model;
use LaravelAdmin\MediaManager\Traits\MediaTrait;

class Blog extends Model
{
	use MediaTrait;

public function myfieldname()
{
	return $this->belongsTo(\LaravelAdmin\MediaManager\Models\Media::class);
}