Creating a create role request

parent 8f86b43c
......@@ -2,7 +2,7 @@
namespace Modules\User\Http\Controllers\Admin;
use Modules\User\Http\Requests\RolesRequest;
use Modules\User\Http\Requests\UpdateRoleRequest;
use Modules\User\Permissions\PermissionManager;
use Modules\User\Repositories\RoleRepository;
......@@ -45,11 +45,10 @@ class RolesController extends BaseUserModuleController
/**
* Store a newly created resource in storage.
*
* @param RolesRequest $request
* @param UpdateRoleRequest $request
* @return Response
*/
public function store(RolesRequest $request)
public function store(UpdateRoleRequest $request)
{
$data = $this->mergeRequestWithPermissions($request);
......@@ -77,12 +76,11 @@ class RolesController extends BaseUserModuleController
/**
* Update the specified resource in storage.
*
* @param int $id
* @param RolesRequest $request
* @param UpdateRoleRequest $request
* @return Response
*/
public function update($id, RolesRequest $request)
public function update($id, UpdateRoleRequest $request)
{
$data = $this->mergeRequestWithPermissions($request);
......
......@@ -4,15 +4,13 @@ namespace Modules\User\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RolesRequest extends FormRequest
class CreateRoleRequest extends FormRequest
{
public function rules()
{
$roleID = $this->route('roles');
return [
'name' => 'required',
'slug' => 'required|unique:roles,slug,' . $roleID . ',id',
'slug' => 'required|unique:roles,slug',
];
}
......
<?php
namespace Modules\User\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRoleRequest extends FormRequest
{
public function rules()
{
$role = $this->route('role');
return [
'name' => 'required',
'slug' => 'required|unique:roles,slug,' . $role->id . ',id',
];
}
public function authorize()
{
return true;
}
public function messages()
{
return [];
}
}
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