Commit 6299fa27 authored by Nicolas Widart's avatar Nicolas Widart

Adding the role update and destroy methods

parent 18fc99c7
......@@ -6,6 +6,7 @@ use Illuminate\Support\Facades\View;
use Laracasts\Flash\Flash;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\User\Http\Requests\CreateRolesRequest;
use Modules\User\Http\Requests\UpdateRoleRequest;
class RolesController extends AdminBaseController
{
......@@ -83,11 +84,19 @@ class RolesController extends AdminBaseController
* Update the specified resource in storage.
*
* @param int $id
* @param UpdateRoleRequest $request
* @return Response
*/
public function update($id)
public function update($id, UpdateRoleRequest $request)
{
//
$role = $this->roles->find($id);
$role->fill($request->all());
$role->save();
Flash::success('Role updated!');
return Redirect::route('dashboard.role.index');
}
/**
......@@ -98,6 +107,14 @@ class RolesController extends AdminBaseController
*/
public function destroy($id)
{
//
if ($role = $this->roles->find($id))
{
$role->delete();
Flash::success('Role deleted!');
return Redirect::route('dashboard.role.index');
}
return Redirect::route('dashboard.role.index');
}
}
\ No newline at end of file
<?php namespace Modules\User\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateRoleRequest extends FormRequest
{
public function rules()
{
return [
'name' => 'required',
'slug' => 'required',
];
}
public function authorize()
{
return true;
}
public function messages()
{
return [];
}
}
\ No newline at end of file
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