Commit b986c66b authored by Vipul Basapati's avatar Vipul Basapati

Settings Responsable trait implementation Complete

parent addee78f
...@@ -63,7 +63,7 @@ class PermissionController extends Controller ...@@ -63,7 +63,7 @@ class PermissionController extends Controller
{ {
$this->permissions->create($request->all()); $this->permissions->create($request->all());
return new RedirectResponse('admin.access.permission.index', ['flash_success' => trans('alerts.backend.permissions.created')]); return new RedirectResponse(route('admin.access.permission.index'), ['flash_success' => trans('alerts.backend.permissions.created')]);
} }
/** /**
...@@ -87,7 +87,7 @@ class PermissionController extends Controller ...@@ -87,7 +87,7 @@ class PermissionController extends Controller
{ {
$this->permissions->update($permission, $request->all()); $this->permissions->update($permission, $request->all());
return new RedirectResponse('admin.access.permission.index', ['flash_success' => trans('alerts.backend.permissions.updated')]); return new RedirectResponse(route('admin.access.permission.index'), ['flash_success' => trans('alerts.backend.permissions.updated')]);
} }
/** /**
...@@ -100,6 +100,6 @@ class PermissionController extends Controller ...@@ -100,6 +100,6 @@ class PermissionController extends Controller
{ {
$this->permissions->delete($permission); $this->permissions->delete($permission);
return new RedirectResponse('admin.access.permission.index', ['flash_success' => trans('alerts.backend.permissions.deleted')]); return new RedirectResponse(route('admin.access.permission.index'), ['flash_success' => trans('alerts.backend.permissions.deleted')]);
} }
} }
...@@ -71,7 +71,7 @@ class RoleController extends Controller ...@@ -71,7 +71,7 @@ class RoleController extends Controller
{ {
$this->roles->create($request->all()); $this->roles->create($request->all());
return new RedirectResponse('admin.access.role.index', ['flash_success' => trans('alerts.backend.roles.created')]); return new RedirectResponse(route('admin.access.role.index'), ['flash_success' => trans('alerts.backend.roles.created')]);
} }
/** /**
...@@ -95,7 +95,7 @@ class RoleController extends Controller ...@@ -95,7 +95,7 @@ class RoleController extends Controller
{ {
$this->roles->update($role, $request->all()); $this->roles->update($role, $request->all());
return new RedirectResponse('admin.access.role.index', ['flash_success' => trans('alerts.backend.roles.updated')]); return new RedirectResponse(route('admin.access.role.index'), ['flash_success' => trans('alerts.backend.roles.updated')]);
} }
/** /**
...@@ -108,6 +108,6 @@ class RoleController extends Controller ...@@ -108,6 +108,6 @@ class RoleController extends Controller
{ {
$this->roles->delete($role); $this->roles->delete($role);
return new RedirectResponse('admin.access.role.index', ['flash_success' => trans('alerts.backend.roles.deleted')]); return new RedirectResponse(route('admin.access.role.index'), ['flash_success' => trans('alerts.backend.roles.deleted')]);
} }
} }
...@@ -76,7 +76,7 @@ class UserController extends Controller ...@@ -76,7 +76,7 @@ class UserController extends Controller
{ {
$this->users->create($request); $this->users->create($request);
return new RedirectResponse('admin.access.user.index', ['flash_success' => trans('alerts.backend.users.created')]); return new RedirectResponse(route('admin.access.user.index'), ['flash_success' => trans('alerts.backend.users.created')]);
} }
/** /**
...@@ -114,7 +114,7 @@ class UserController extends Controller ...@@ -114,7 +114,7 @@ class UserController extends Controller
{ {
$this->users->update($user, $request); $this->users->update($user, $request);
return new RedirectResponse('admin.access.user.index', ['flash_success' => trans('alerts.backend.users.updated')]); return new RedirectResponse(route('admin.access.user.index'), ['flash_success' => trans('alerts.backend.users.updated')]);
} }
/** /**
...@@ -127,6 +127,6 @@ class UserController extends Controller ...@@ -127,6 +127,6 @@ class UserController extends Controller
{ {
$this->users->delete($user); $this->users->delete($user);
return new RedirectResponse('admin.access.user.index', ['flash_success' => trans('alerts.backend.users.deleted')]); return new RedirectResponse(route('admin.access.user.index'), ['flash_success' => trans('alerts.backend.users.deleted')]);
} }
} }
...@@ -75,7 +75,7 @@ class BlogsController extends Controller ...@@ -75,7 +75,7 @@ class BlogsController extends Controller
{ {
$this->blog->create($request->except('_token')); $this->blog->create($request->except('_token'));
return new RedirectResponse('admin.blogs.index', ['flash_success' => trans('alerts.backend.blogs.created')]); return new RedirectResponse(route('admin.blogs.index'), ['flash_success' => trans('alerts.backend.blogs.created')]);
} }
/** /**
...@@ -104,7 +104,7 @@ class BlogsController extends Controller ...@@ -104,7 +104,7 @@ class BlogsController extends Controller
$this->blog->update($blog, $request->except(['_token', '_method'])); $this->blog->update($blog, $request->except(['_token', '_method']));
return new RedirectResponse('admin.blogs.index', ['flash_success' => trans('alerts.backend.blogs.updated')]); return new RedirectResponse(route('admin.blogs.index'), ['flash_success' => trans('alerts.backend.blogs.updated')]);
} }
/** /**
...@@ -117,6 +117,6 @@ class BlogsController extends Controller ...@@ -117,6 +117,6 @@ class BlogsController extends Controller
{ {
$this->blog->delete($blog); $this->blog->delete($blog);
return new RedirectResponse('admin.blogs.index', ['flash_success' => trans('alerts.backend.blogs.deleted')]); return new RedirectResponse(route('admin.blogs.index'), ['flash_success' => trans('alerts.backend.blogs.deleted')]);
} }
} }
...@@ -92,7 +92,7 @@ class MenuController extends Controller ...@@ -92,7 +92,7 @@ class MenuController extends Controller
{ {
$this->menu->create($request->except('_token')); $this->menu->create($request->except('_token'));
return new RedirectResponse('admin.menus.index', ['flash_success' => trans('alerts.backend.menus.created')]); return new RedirectResponse(route('admin.menus.index'), ['flash_success' => trans('alerts.backend.menus.created')]);
} }
/** /**
...@@ -120,7 +120,7 @@ class MenuController extends Controller ...@@ -120,7 +120,7 @@ class MenuController extends Controller
{ {
$this->menu->update($menu, $request->all()); $this->menu->update($menu, $request->all());
return new RedirectResponse('admin.menus.index', ['flash_success' => trans('alerts.backend.menus.updated')]); return new RedirectResponse(route('admin.menus.index'), ['flash_success' => trans('alerts.backend.menus.updated')]);
} }
/** /**
...@@ -135,6 +135,6 @@ class MenuController extends Controller ...@@ -135,6 +135,6 @@ class MenuController extends Controller
{ {
$this->menu->delete($menu); $this->menu->delete($menu);
return new RedirectResponse('admin.menus.index', ['flash_success' => trans('alerts.backend.menus.deleted')]); return new RedirectResponse(route('admin.menus.index'), ['flash_success' => trans('alerts.backend.menus.deleted')]);
} }
} }
...@@ -59,7 +59,7 @@ class PagesController extends Controller ...@@ -59,7 +59,7 @@ class PagesController extends Controller
{ {
$this->pages->create($request->except(['_token'])); $this->pages->create($request->except(['_token']));
return new RedirectResponse('admin.pages.index', ['flash_success' => trans('alerts.backend.pages.created')]); return new RedirectResponse(route('admin.pages.index'), ['flash_success' => trans('alerts.backend.pages.created')]);
} }
/** /**
...@@ -83,7 +83,7 @@ class PagesController extends Controller ...@@ -83,7 +83,7 @@ class PagesController extends Controller
{ {
$this->pages->update($page, $request->except(['_method', '_token'])); $this->pages->update($page, $request->except(['_method', '_token']));
return new RedirectResponse('admin.pages.index', ['flash_success' => trans('alerts.backend.pages.updated')]); return new RedirectResponse(route('admin.pages.index'), ['flash_success' => trans('alerts.backend.pages.updated')]);
} }
/** /**
...@@ -96,6 +96,6 @@ class PagesController extends Controller ...@@ -96,6 +96,6 @@ class PagesController extends Controller
{ {
$this->pages->delete($page); $this->pages->delete($page);
return new RedirectResponse('admin.pages.index', ['flash_success' => trans('alerts.backend.pages.deleted')]); return new RedirectResponse(route('admin.pages.index'), ['flash_success' => trans('alerts.backend.pages.deleted')]);
} }
} }
...@@ -2,11 +2,13 @@ ...@@ -2,11 +2,13 @@
namespace App\Http\Controllers\Backend\Settings; namespace App\Http\Controllers\Backend\Settings;
use App\Models\Settings\Setting;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Responses\RedirectResponse;
use App\Http\Responses\Backend\Setting\EditResponse;
use App\Repositories\Backend\Settings\SettingsRepository;
use App\Http\Requests\Backend\Settings\ManageSettingsRequest; use App\Http\Requests\Backend\Settings\ManageSettingsRequest;
use App\Http\Requests\Backend\Settings\UpdateSettingsRequest; use App\Http\Requests\Backend\Settings\UpdateSettingsRequest;
use App\Models\Settings\Setting;
use App\Repositories\Backend\Settings\SettingsRepository;
/** /**
* Class SettingsController. * Class SettingsController.
...@@ -27,26 +29,23 @@ class SettingsController extends Controller ...@@ -27,26 +29,23 @@ class SettingsController extends Controller
* @param \App\Models\Settings\Setting $setting * @param \App\Models\Settings\Setting $setting
* @param \App\Http\Requests\Backend\Settings\ManageSettingsRequest $request * @param \App\Http\Requests\Backend\Settings\ManageSettingsRequest $request
* *
* @return mixed * @return \App\Http\Responses\Backend\Setting\EditResponse
*/ */
public function edit(Setting $setting, ManageSettingsRequest $request) public function edit(Setting $setting, ManageSettingsRequest $request)
{ {
return view('backend.settings.edit') return new EditResponse($setting);
->withSetting($setting);
} }
/** /**
* @param \App\Models\Settings\Setting $setting * @param \App\Models\Settings\Setting $setting
* @param \App\Http\Requests\Backend\Settings\UpdateSettingsRequest $request * @param \App\Http\Requests\Backend\Settings\UpdateSettingsRequest $request
* *
* @return mixed * @return \App\Http\Responses\RedirectResponse
*/ */
public function update(Setting $setting, UpdateSettingsRequest $request) public function update(Setting $setting, UpdateSettingsRequest $request)
{ {
$this->settings->update($setting, $request->except(['_token', '_method'])); $this->settings->update($setting, $request->except(['_token', '_method']));
return redirect() return new RedirectResponse(route('admin.settings.edit', $setting->id), ['flash_success' => trans('alerts.backend.settings.updated')]);
->route('admin.settings.edit', $setting->id)
->with('flash_success', trans('alerts.backend.settings.updated'));
} }
} }
<?php <?php
namespace App\Http\Responses\Backend\Page; namespace App\Http\Responses\Backend\Setting;
use Illuminate\Contracts\Support\Responsable; use Illuminate\Contracts\Support\Responsable;
class CreateResponse implements Responsable class EditResponse implements Responsable
{ {
/** /**
* In Response. * @var \App\Models\Settings\Setting
* */
* @param \App\Http\Requests\Request $request protected $setting;
/**
* @param \App\Models\Settings\Setting $setting
*/
public function __construct($setting)
{
$this->setting = $setting;
}
/**
* toReponse
* *
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/ */
public function toResponse($request) public function toResponse($request)
{ {
// return view('backend.settings.edit')
->withSetting($this->setting);
} }
} }
...@@ -18,7 +18,7 @@ class RedirectResponse implements Responsable ...@@ -18,7 +18,7 @@ class RedirectResponse implements Responsable
public function toResponse($request) public function toResponse($request)
{ {
return redirect() return redirect()
->route($this->route) ->to($this->route)
->with($this->message); ->with($this->message);
} }
} }
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