本文整理汇总了PHP中Illuminate\Http\Request::flashExcept方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::flashExcept方法的具体用法?PHP Request::flashExcept怎么用?PHP Request::flashExcept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Http\Request
的用法示例。
在下文中一共展示了Request::flashExcept方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update(Request $request, $id = 0)
{
if ($id) {
try {
$user = User::findOrFail($id);
} catch (ModelNotFoundException $e) {
$request->flash();
return redirect('admin/user', ['act' => $id, 'errors' => $e]);
}
} else {
return redirect('admin/user');
}
$data = ['email' => $request->input('email'), 'name' => $request->input('name'), 'slug' => $request->input('slug')];
$validator = Validator::make($data, ['name' => 'required', 'email' => "required|email|unique:users,email,{$id}", 'slug' => 'required|exists:roles,id']);
if ($validator->fails()) {
$request->flashExcept('password');
return view('admin.user.show', ['act' => $id, 'user' => [], 'errors' => $validator->messages(), 'roles' => Role::all()]);
} else {
$user->email = $data['email'];
$user->name = $data['name'];
if ($request->input('password')) {
$user->password = bcrypt($request->input('password'));
}
$user->detachAllRoles();
$user->attachRole($request->input('slug'));
$user->save();
return redirect('admin/user');
}
}
示例2: register
public function register(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$request->flashExcept('password');
$messages = $validator->messages()->toArray();
return view('registration', ['errors' => $messages]);
}
$user = $this->create($request->all());
Auth::login($user);
return redirect($this->redirectTo);
}
示例3: flashExcept
/**
* Flash only some of the input to the session.
*
* @param array|mixed $keys
* @return void
* @static
*/
public static function flashExcept($keys)
{
\Illuminate\Http\Request::flashExcept($keys);
}
示例4: update
/**
* @param $îd
* @param Request $request
* @return mixed
*/
public function update($id, Request $request)
{
// we get the news
try {
$news = $this->repository->find($id);
} catch (Exception $e) {
// we flash the request
$request->flashExcept('image');
// we notify the current user
Modal::alert([trans('news.message.find.failure', ['id' => $id]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
return redirect()->back();
}
// we check the current user permission
if (!Permission::hasPermission('news.update')) {
// we redirect the current user to the permissions list if he has the required permission
if (Sentinel::getUser()->hasAccess('news.view')) {
return redirect()->route('news.edit', ['id' => $id]);
} else {
// or we redirect the current user to the home page
return redirect()->route('dashboard.index');
}
}
// if the active field is not given, we set it to false
$request->merge(['active' => $request->get('active', false)]);
// we sanitize the entries
$request->replace(InputSanitizer::sanitize($request->all()));
// we check if the current user has the permission to activate the news
if ($request->get('active') && !Permission::hasPermission('news.activate')) {
// we flash the request
$request->flashExcept('image');
return redirect()->back();
}
// we convert the title into a slug
$request->merge(['key' => str_slug($request->get('title'))]);
// we convert the fr date to database format
if ($request->get('released_at')) {
$request->merge(['released_at' => Carbon::createFromFormat('d/m/Y H:i', $request->get('released_at'))->format('Y-m-d H:i:s')]);
}
// we check inputs validity
$rules = ['author_id' => 'numeric|exists:users,id', 'category_id' => 'required|in:' . implode(',', array_keys(config('news.category'))), 'photo_album_id' => 'numeric|exists:photos,id', 'video_id' => 'numeric|exists:videos,id', 'image' => 'image|mimes:jpg,jpeg,png|image_size:>=2560,>=1440', 'key' => 'required|alpha_dash|unique:news,key,' . $request->get('_id'), 'title' => 'required|string', 'meta_title' => 'string', 'meta_description' => 'string', 'meta_keywords' => 'string', 'content' => 'string', 'released_at' => 'required|date_format:Y-m-d H:i:s', 'active' => 'required|boolean'];
// we check the inputs validity
if (!Validation::check($request->all(), $rules)) {
// we flash the request
$request->flashExcept('image');
return redirect()->back();
}
try {
// we update the news
$news->update($request->except('_token', 'image', 'author_id'));
// we set the author
if (Sentinel::getUser()->hasAccess('news.author') && ($author_id = $request->get('author_id'))) {
$news->author_id = $author_id;
$news->save();
}
// we store the image
if ($img = $request->file('image')) {
// if we find a previous recorded image, we remove it
if (isset($news->image)) {
ImageManager::remove($news->image, $news->storagePath(), $news->availableSizes('image'));
}
// we optimize, resize and save the image
$file_name = ImageManager::optimizeAndResize($img->getRealPath(), $news->imageName('image'), $img->getClientOriginalExtension(), $news->storagePath(), $news->availableSizes('image'));
// we add the image name to the inputs for saving
$news->image = $file_name;
$news->save();
}
// we notify the current user
Modal::alert([trans('news.message.update.success', ['news' => $news->title])], 'success');
return redirect()->back();
} catch (Exception $e) {
// we flash the request
$request->flashExcept('image');
// we log the error
CustomLog::error($e);
// we notify the current user
Modal::alert([trans('news.message.update.failure', ['news' => $news->title]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
return redirect()->back();
}
}
示例5: login
/**
* User login
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
*/
public function login(Request $request)
{
if ($request->isMethod('post')) {
$email = $request->input('email');
$password = $request->input('pass');
$remember = $request->has('remember');
if (Auth::attempt(['email' => $email, 'password' => $password, 'role_id' => 2, 'approve' => 1], $remember)) {
$user = User::getUserById(Auth::user()->id);
$user->online = 1;
$user->save();
return redirect()->route('posts');
} else {
$request->session()->flash('error', 'error');
$request->flashExcept('pass');
return redirect()->back();
}
} else {
if (Auth::check() && Auth::user()->role_id == 2) {
return redirect()->route('posts');
} else {
return view('site.auth.login');
}
}
}
示例6: update
public function update($id, Request $request)
{
// we get the slide
try {
$slide = $this->repository->find($id);
} catch (Exception $e) {
// we log the error
CustomLog::error($e);
// we notify the current user
Modal::alert([trans('home.message.slide.find.failure', ['id' => $id]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
// we redirect the current user to the home edit page if he has the required permission
if (Sentinel::getUser()->hasAccess('home.view')) {
return redirect()->route('home.edit');
} else {
// or we redirect the current user to the dashboard page
return redirect()->route('dashboard.index');
}
}
// we check the current user permission
if (!Permission::hasPermission('home.slides.update')) {
// we redirect the current user to the user list if he has the required permission
if (Sentinel::getUser()->hasAccess('home.slides.view')) {
return redirect()->route('home.slides.edit', ['id' => $id]);
} else {
// or we redirect the current user to the home page
return redirect()->route('dashboard.index');
}
}
// if the active field is not given, we set it to false
$request->merge(['active' => $request->get('active', false)]);
// we sanitize the entries
$request->replace(InputSanitizer::sanitize($request->all()));
// we set the verification rules
$rules = ['_id' => 'numeric|exists:slides,id', 'title' => 'required|string', 'url' => 'active_url', 'quote' => 'required|string|min:50|max:150', 'picto' => 'image|mimes:png|image_size:>=300,>=300', 'background_image' => 'image|mimes:jpg,jpeg|image_size:>=2560,>=1440', 'active' => 'required|boolean'];
if ($request->get('previous_slide_id') === 0) {
$rules['previous_slide_id'] = 'numeric';
} else {
$rules['previous_slide_id'] = 'required|numeric|exists:slides,id';
}
if (!Validation::check($request->all(), $rules)) {
// we flash the request
$request->flashExcept('picto', 'background_image');
return redirect()->back();
}
try {
// we update the roles hierarchy
$new_position = $this->repository->updatePositions($request->get('previous_slide_id'));
// we update the slide
$slide->update(['title' => $request->get('title'), 'url' => $request->get('url'), 'quote' => $request->get('quote'), 'position' => $new_position, 'active' => $request->get('active')]);
// we store the picto file
if ($picto = $request->file('picto')) {
// we optimize, resize and save the image
$file_name = ImageManager::optimizeAndResize($picto->getRealPath(), $slide->imageName('picto'), $picto->getClientOriginalExtension(), $slide->storagePath(), $slide->availableSizes('picto'));
// we save the picto name
$slide->picto = $file_name;
$slide->save();
}
// we store the background image file
if ($background_image = $request->file('background_image')) {
// we optimize, resize and save the image
$file_name = ImageManager::optimizeAndResize($background_image->getRealPath(), $slide->imageName('background_image'), $background_image->getClientOriginalExtension(), $slide->storagePath(), $slide->availableSizes('background_image'));
// we save the background image name
$slide->background_image = $file_name;
$slide->save();
}
// we sanitize the roles ranks
$this->repository->sanitizePositions();
Modal::alert([trans('home.message.slide.update.success', ['slide' => $slide->name])], 'success');
return redirect()->back();
} catch (Exception $e) {
// we flash the request
$request->flashExcept('picto', 'background_image');
// we log the error
CustomLog::error($e);
// we notify the current user
Modal::alert([trans('home.message.slide.update.failure', ['slide' => $request->get('name')]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
return redirect()->back();
}
}
示例7: update
/**
* @param $id
* @param Request $request
* @return mixed
*/
public function update($id, Request $request)
{
// we get the partner
try {
$partner = $this->repository->find($id);
} catch (Exception $e) {
// we notify the current user
Modal::alert([trans('partners.message.find.failure', ['id' => $id]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
return redirect()->back();
}
// we check the current user permission
if (!Permission::hasPermission('partners.update')) {
// we redirect the current user to the permissions list if he has the required permission
if (Sentinel::getUser()->hasAccess('partners.view')) {
return redirect()->route('partners.edit', ['id' => $id]);
} else {
// or we redirect the current user to the home page
return redirect()->route('dashboard.index');
}
}
// if the active field is not given, we set it to false
$request->merge(['active' => $request->get('active', false)]);
// we sanitize the entries
$request->replace(InputSanitizer::sanitize($request->all()));
// we set the validation rules
$rules = ['logo' => 'image|mimes:png|image_size:*,>=100', 'name' => 'required|string', 'url' => 'url', 'active' => 'required|boolean'];
if ($request->get('previous_partner_id') === 0) {
$rules['previous_partner_id'] = 'numeric';
} else {
$rules['previous_partner_id'] = 'required|numeric|exists:slides,id';
}
// we check the inputs validity
if (!Validation::check($request->all(), $rules)) {
// we flash the request
$request->flashExcept('logo');
return redirect()->back();
}
try {
// we update the schedule
$partner->update($request->except('_token', 'logo'));
// we store the logo
if ($logo = $request->file('logo')) {
// we optimize, resize and save the image
$file_name = ImageManager::optimizeAndResize($logo->getRealPath(), $partner->imageName('logo'), $logo->getClientOriginalExtension(), $partner->storagePath(), $partner->availableSizes('logo'));
// we add the image name to the inputs for saving
$partner->logo = $file_name;
$partner->save();
}
// we notify the current user
Modal::alert([trans('partners.message.update.success', ['partner' => $partner->name])], 'success');
return redirect()->back();
} catch (Exception $e) {
// we flash the request
$request->flashExcept('logo');
// we log the error
CustomLog::error($e);
// we notify the current user
Modal::alert([trans('partners.message.update.failure'), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
return redirect()->back();
}
}
示例8: update
/**
* @param $id
* @param Request $request
* @return mixed
*/
public function update($id, Request $request)
{
// we get the user
if (!($user = Sentinel::findById($id))) {
Modal::alert([trans('users.message.find.failure', ['id' => $id]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
// we redirect the current user to the users list if he has the required permission
if (Sentinel::getUser()->hasAccess('users.list')) {
return redirect()->route('users.index');
} else {
// or we redirect the current user to the home page
return redirect()->route('dashboard.index');
}
}
// if the updated user is not the current user
if ($user->id !== Sentinel::getUser()->id) {
// we check the current user permission
if (!Permission::hasPermission('users.update')) {
// we redirect the current user to the user list if he has the required permission
if (Sentinel::getUser()->hasAccess('users.view')) {
return redirect()->route('users.edit', ['id' => $id]);
} else {
// or we redirect the current user to the home page
return redirect()->route('dashboard.index');
}
}
}
// we check if the current user has a role position high enough to edit the user
$edited_user_role = $user->roles->first();
$current_user_role = Sentinel::getUser()->roles->first();
if ($edited_user_role && $current_user_role && $edited_user_role->position < $current_user_role->position) {
Modal::alert([trans('users.message.permission.denied', ['action' => trans('users.message.permission.action.edit')])], 'error');
return redirect()->back();
}
// we check if the chosen role is not higher than the role of the current user
$new_user_role = Sentinel::findRoleById($request->get('role'));
$current_user_role = Sentinel::getUser()->roles->first();
if ($new_user_role && $current_user_role && $new_user_role->position < $current_user_role->position) {
// we flash the request
$request->flashExcept('photo');
// we notify the user
Modal::alert([trans('users.message.permission.denied', ['action' => trans('users.message.permission.action.edit')])], 'error');
return redirect()->back();
}
// if the remove_photo field is not given, we set it to false
$request->merge(['remove_photo' => $request->get('remove_photo', false)]);
// we sanitize the entries
$request->replace(InputSanitizer::sanitize($request->all()));
try {
// we convert the en/fr date to the database format
if ($birth_date = $request->get('birth_date')) {
$request->merge(['birth_date' => Carbon::createFromFormat('d/m/Y', $birth_date)->format('Y-m-d')]);
}
} catch (Exception $e) {
// we log the error
CustomLog::error($e);
}
// we set the validation rules
$rules = ['photo' => 'image|mimes:jpg,jpeg,png|image_size:>=145,>=160', 'remove_photo' => 'required|boolean', 'gender' => 'in:' . implode(',', array_keys(config('user.gender'))), 'last_name' => 'required|string', 'first_name' => 'required|string', 'birth_date' => 'date_format:Y-m-d', 'phone_number' => 'phone:FR', 'email' => 'required|email|unique:users,email,' . $id, 'address' => 'string', 'zip_code' => 'digits:5', 'city' => 'string', 'country' => 'string', 'password' => 'min:' . config('password.min.length') . '|confirmed'];
// according if we update the current profile account or a user profile
if ($user->id !== Sentinel::getUser()->id) {
$rules['role'] = 'required|numeric|exists:roles,id';
$rules['active'] = 'boolean';
$rules['status_id'] = 'required|numeric|in:' . implode(',', array_keys(config('user.status')));
$rules['board_id'] = 'numeric|in:' . implode(',', array_keys(config('user.board')));
}
// we sort the rules by keys
ksort($rules);
// we check the inputs validity
if (!Validation::check($request->all(), $rules)) {
// we flash the request
$request->flashExcept('photo');
return redirect()->back();
}
try {
// we update the user
Sentinel::update($user, $request->except('password', 'photo'));
// we format the number into its international equivalent
if ($phone_number = $request->get('phone_number')) {
Sentinel::update($user, ['phone_number' => phone_format($phone_number, 'FR', PhoneNumberFormat::INTERNATIONAL)]);
}
// we store the photo
if ($photo = $request->file('photo')) {
// we optimize, resize and save the image
$file_name = ImageManager::optimizeAndResize($photo->getRealPath(), $user->imageName('photo'), $photo->getClientOriginalExtension(), $user->storagePath(), $user->availableSizes('photo'));
// we update the user
Sentinel::update($user, ['photo' => $file_name]);
} elseif (!$request->get('photo') && !$user->photo || $request->get('remove_photo')) {
// we set the una logo as the user image
$file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/users-default-avatar.png'), $user->imageName('photo'), 'png', $user->storagePath(), $user->availableSizes('photo'), false);
// we update the user
Sentinel::update($user, ['photo' => $file_name]);
}
// we update the user password
if ($password = $request->get('password')) {
Sentinel::update($user, ['password' => $password]);
//.........这里部分代码省略.........
示例9: pageUpdate
/**
* @param Request $request
* @return mixed
*/
public function pageUpdate(Request $request)
{
// we check the current user permission
if (!Permission::hasPermission('registration.page.update')) {
// we redirect the current user to the registration page view if he has the required permission
if (Sentinel::getUser()->hasAccess('registration.page.view')) {
return redirect()->route('registration.page.edit');
} else {
// or we redirect the current user to the home page
return redirect()->route('dashboard.index');
}
}
// we get the json registration content
$registration = null;
if (is_file(storage_path('app/registration/content.json'))) {
$registration = json_decode(file_get_contents(storage_path('app/registration/content.json')));
}
// if the active field is not given, we set it to false
$request->merge(['remove_background_image' => $request->get('remove_background_image', false)]);
// we sanitize the entries
$request->replace(InputSanitizer::sanitize($request->all()));
// we check inputs validity
$rules = ['title' => 'required|string', 'description' => 'string', 'background_image' => 'image|mimes:jpg,jpeg|image_size:>=2560,>=1440', 'remove_background_image' => 'required|boolean', 'registration_form_file' => 'mimes:pdf'];
// we check the inputs validity
if (!Validation::check($request->all(), $rules)) {
// we flash the request
$request->flashExcept('background_image', 'registration_form_file');
return redirect()->back();
}
// try {
$inputs = $request->except('_token', '_method', 'background_image', 'remove_background_image');
// we store the background image file
if ($background_image = $request->file('background_image')) {
// we remove the background image
if ($registration->background_image) {
ImageManager::remove($registration->background_image, config('image.registration.storage_path'), config('image.registration.background_image.sizes'));
}
// we optimize, resize and save the image
$file_name = ImageManager::optimizeAndResize($background_image->getRealPath(), config('image.registration.background_image.name'), $background_image->getClientOriginalExtension(), config('image.registration.storage_path'), config('image.registration.background_image.sizes'));
// we set the file name
$inputs['background_image'] = $file_name;
} elseif ($request->get('remove_background_image')) {
// we remove the background image
if (isset($registration->background_image)) {
ImageManager::remove($registration->background_image, config('image.registration.storage_path'), config('image.registration.background_image.sizes'));
}
$inputs['background_image'] = null;
} else {
$inputs['background_image'] = isset($registration->background_image) ? $registration->background_image : null;
}
// we store the registration form file
if ($registration_form_file = $request->file('registration_form_file')) {
// we remove the registration form file
if ($registration->registration_form_file) {
FileManager::remove($registration->registration_form_file, config('file.registration.storage_path'));
}
// we save the registration form file
$file_name = FileManager::storeAndRename($registration_form_file->getRealPath(), config('file.registration.registration_form_file.name'), $registration_form_file->getClientOriginalExtension(), config('file.registration.storage_path'));
// we set the file name
$inputs['registration_form_file'] = $file_name;
} else {
$inputs['registration_form_file'] = isset($registration->registration_form_file) ? $registration->registration_form_file : null;
}
// we store the content into a json file
file_put_contents(storage_path('app/registration/content.json'), json_encode($inputs));
Modal::alert([trans('registration.message.content.update.success', ['title' => $request->get('title')])], 'success');
return redirect()->back();
// } catch (Exception $e) {
//
// // we flash the request
// $request->flashExcept('background_image', 'registration_form_file');
//
// // we log the error
// CustomLog::error($e);
//
// // we notify the current user
// Modal::alert([
// trans('registration.message.content.update.failure', ['title' => isset($registration->title) ? $registration->title : null]),
// trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')]),
// ], 'error');
//
// return redirect()->back();
// }
}
示例10: update
/**
* @param $îd
* @param Request $request
* @return mixed
*/
public function update($id, Request $request)
{
// we get the photo
try {
$photo = $this->repository->find($id);
} catch (Exception $e) {
// we flash the request
$request->flashExcept('cover');
// we notify the current user
Modal::alert([trans('photos.message.find.failure', ['id' => $id]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
return redirect()->back();
}
// we check the current user permission
if (!Permission::hasPermission('photos.update')) {
// we redirect the current user to the permissions list if he has the required permission
if (Sentinel::getUser()->hasAccess('photos.view')) {
return redirect()->route('photos.edit', ['id' => $id]);
} else {
// or we redirect the current user to the home page
return redirect()->route('dashboard.index');
}
}
// if the active field is not given, we set it to false
$request->merge(['active' => $request->get('active', false)]);
// we sanitize the entries
$request->replace(InputSanitizer::sanitize($request->all()));
// we convert the fr date to database format
if ($request->get('date')) {
$request->merge(['date' => Carbon::createFromFormat('d/m/Y', $request->get('date'))->format('Y-m-d')]);
}
// we check inputs validity
$rules = ['cover' => 'image|mimes:jpg,jpeg,png|image_size:>=220,>=220', 'title' => 'required|string', 'link' => 'required|url', 'date' => 'required|date_format:Y-m-d', 'active' => 'required|boolean'];
// we check the inputs validity
if (!Validation::check($request->all(), $rules)) {
// we flash the request
$request->flashExcept('cover');
return redirect()->back();
}
try {
// we update the photo
$photo->update($request->except('_token', 'cover'));
// we store the image
if ($img = $request->file('cover')) {
// we optimize, resize and save the image
$file_name = ImageManager::optimizeAndResize($img->getRealPath(), $photo->imageName('cover'), $img->getClientOriginalExtension(), $photo->storagePath(), $photo->availableSizes('cover'));
// we add the image name to the inputs for saving
$photo->cover = $file_name;
$photo->save();
}
// we notify the current user
Modal::alert([trans('photos.message.update.success', ['album' => $photo->title])], 'success');
return redirect()->back();
} catch (Exception $e) {
// we flash the request
$request->flashExcept('cover');
// we log the error
CustomLog::error($e);
// we notify the current user
Modal::alert([trans('$photo.message.update.failure', ['album' => $photo->title]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
return redirect()->back();
}
}
示例11: update
/**
* @param $id
* @param Request $request
* @return mixed
*/
public function update($id, Request $request)
{
// we get the page
try {
$page = $this->repository->find($id);
} catch (Exception $e) {
// we flash the request
$request->flashExcept('image');
// we notify the current user
Modal::alert([trans('pages.message.find.failure', ['id' => $id]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
return redirect()->back();
}
// we check the current user permission
if (!Permission::hasPermission('pages.update')) {
// we redirect the current user to the permissions list if he has the required permission
if (Sentinel::getUser()->hasAccess('pages.view')) {
return redirect()->route('pages.edit', ['id' => $id]);
} else {
// or we redirect the current user to the home page
return redirect()->route('backoffice.index');
}
}
// if the active field is not given, we set it to false
$request->merge(['active' => $request->get('active', false)]);
// we sanitize the entries
$request->replace(InputSanitizer::sanitize($request->all()));
// we slugify the slug
$request->merge(['slug' => str_slug(strip_tags($request->slug))]);
// we set the validity rules
$rules = ['image' => 'image|mimes:jpg,jpeg,png|image_size:>=2560,>=1440', 'active' => 'required|boolean', 'slug' => 'required_with:title|alpha_dash|unique:pages,slug,' . $page->id, 'title' => 'required|string', 'content' => 'string', 'meta_title' => 'string', 'meta_description' => 'string', 'meta_keywords' => 'string'];
// we check inputs validity
if (!Validation::check($request->all(), $rules)) {
// we flash the request
$request->flashExcept('image');
return redirect()->back();
}
try {
// we update the fields
if (Sentinel::getUser()->hasAccess('pages.slug')) {
$page->slug = $request->slug;
}
$page->title = $request->title;
$page->content = $request->content;
$page->meta_title = $request->meta_title;
$page->meta_description = $request->meta_description;
$page->meta_keywords = $request->meta_keywords;
$page->active = $request->active;
// we store the image
if ($img = $request->file('image')) {
// if we find a previous recorded image, we remove it
if ($page->image) {
ImageManager::remove($page->image, $page->storagePath(), $page->availableSizes('image'));
}
// we optimize, resize and save the image
$file_name = ImageManager::optimizeAndResize($img->getRealPath(), $page->imageName('image'), $img->getClientOriginalExtension(), $page->storagePath(), $page->availableSizes('image'));
// we add the image name to the inputs for saving
$page->image = $file_name;
}
// we save the changes
$page->save();
// we notify the current user
Modal::alert([trans('pages.message.update.success', ['page' => $page->title])], 'success');
return redirect()->back();
} catch (Exception $e) {
// we flash the request
$request->flashExcept('image');
// we log the error
CustomLog::error($e);
// we notify the current user
Modal::alert([trans('pages.message.update.failure', ['page' => $page->title]), trans('global.message.global.failure.contact.support', ['email' => config('settings.support_email')])], 'error');
return redirect()->back();
}
}