FEATURE #1423: add uploading of title photo for content pages

This commit is contained in:
Michal Kváček
2016-03-31 22:39:38 +02:00
parent e789b02a93
commit 590e1eeaca
12 changed files with 204 additions and 51 deletions
+17 -3
View File
@@ -6,9 +6,9 @@ use App\Enumerations\ModulesHandlerToId;
use App\Http\Requests\EditContentRequest;
use App\Models\Content;
use App\Models\ContentHistory;
use App\Models\File;
use App\Models\Template;
use Illuminate\Support\Str;
use Modules\StaticPages\Http\Requests\EditStaticPageRequest;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class EditContent extends Controller
@@ -17,10 +17,15 @@ class EditContent extends Controller
* @var ContentHistory
*/
private $history;
/**
* @var File
*/
private $file;
public function __construct(ContentHistory $history)
public function __construct(ContentHistory $history, File $file)
{
$this->history = $history;
$this->file = $file;
}
/**
@@ -81,6 +86,14 @@ class EditContent extends Controller
$request->url = Str::slug($request->url);
$request->parentPage = $request->parentPage ? $request->parentPage : null;
$request->titlePhotoFilename = $page->title_photo;
// upload file - if provided
if ($request->hasFile('titlePhoto')) {
$file = $this->file->upload($request->file('titlePhoto'), $request);
$request->titlePhotoFilename = $file['filename'];
}
// array of fields in database and fields from request
$fields = [
@@ -93,7 +106,8 @@ class EditContent extends Controller
'meta_description' => 'metaDescription',
'content' => 'pageContent',
'parent_id' => 'parentPage',
'status' => 'status'
'status' => 'status',
'title_photo' => 'titlePhotoFilename'
];
// save new values with history