FEATURE #1423: add uploading of title photo for content pages
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user