Commit 2f3d1e5d authored by Nicolas Widart's avatar Nicolas Widart

Adding the update file

parent 5d353749
<?php namespace Modules\Media\Http\Controllers\Admin;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use Laracasts\Flash\Flash;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Media\Entities\File;
use Modules\Media\Http\Requests\UpdateMediaRequest;
use Modules\Media\Repositories\FileRepository;
class MediaController extends AdminBaseController
......@@ -71,11 +74,15 @@ class MediaController extends AdminBaseController
* Update the specified resource in storage.
*
* @param File $file
* @param UpdateMediaRequest $request
* @return Response
*/
public function update(File $file)
public function update(File $file, UpdateMediaRequest $request)
{
dd('form posted');
$this->file->update($file, $request->all());
Flash::success('File updated');
return Redirect::route('dashboard.media.index');
}
/**
......
<?php namespace Modules\Media\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateMediaRequest extends FormRequest
{
public function rules()
{
return [];
}
public function authorize()
{
return true;
}
public function messages()
{
return [];
}
}
<?php namespace Modules\Media\Repositories\Eloquent;
use Modules\Core\Internationalisation\Helper;
use Modules\Core\Repositories\Eloquent\EloquentBaseRepository;
use Modules\Media\Entities\File;
use Modules\Media\Helpers\FileHelper;
use Modules\Media\Repositories\FileRepository;
use Symfony\Component\HttpFoundation\File\UploadedFile;
......@@ -9,12 +11,16 @@ class EloquentFileRepository extends EloquentBaseRepository implements FileRepos
{
/**
* Update a resource
* @param $id
* @param File $file
* @param $data
* @return mixed
*/
public function update($id, $data)
public function update($file, $data)
{
$translatableData = Helper::separateLanguages($data);
Helper::updateTranslated($file, $translatableData);
return $file;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment