<?php
namespace App\Http\Controllers\Api\V1;
use Illuminate\Http\Request;
use Spatie\MediaLibrary\Media;
class DownloadController extends ApiController
{
public function __construct()
{
}
/**
* Download media based on media id
* @param Request $request
* @param $media_id
* @return Media
*/
public function downloadMedia(Request $request, $media_id)
{
$media = Media::findOrFail($media_id);
return $media;
}
}
// download API in routes/api.php
$api->get('media/{media_id}/download','DownloadController@downloadMedia');