Janky-ass form request stuff

This commit is contained in:
snipe 2016-06-06 21:02:06 -07:00
parent d4e231d5d4
commit 75eb2bbe09
3 changed files with 38 additions and 4 deletions

View file

@ -13,6 +13,7 @@ use App\Models\Location;
use App\Models\Setting;
use App\Models\Statuslabel;
use App\Http\Requests\SaveUserRequest;
use App\Http\Requests\UpdateUserRequest;
use App\Models\User;
use Auth;
use Config;
@ -96,7 +97,7 @@ class UsersController extends Controller
* @since [v1.0]
* @return Redirect
*/
public function postCreate(Request $request, SaveUserRequest $request)
public function postCreate(SaveUserRequest $request)
{
$user = new User;
@ -138,7 +139,7 @@ class UsersController extends Controller
return redirect::route('users')->with('success', trans('admin/users/message.success.create'));
}
return redirect()->back()->withInput()->withErrors($user->getErrors())->withErrors($errors);
return redirect()->back()->withInput()->withErrors($user->getErrors());
@ -236,7 +237,7 @@ class UsersController extends Controller
* @param int $id
* @return Redirect
*/
public function postEdit(Request $request, SaveUserRequest $request, $id = null)
public function postEdit(UpdateUserRequest $request, $id = null)
{
// We need to reverse the UI specific logic for our
// permissions here before we update the user.

View file

@ -29,7 +29,7 @@ class SaveUserRequest extends Request
'username' => 'required|string|min:2|unique:users,username,NULL,deleted_at',
'email' => 'email',
'password' => 'required|min:6',
'password_confirm' => 'required|same:password',
'password_confirm' => 'sometimes|required_with:password',
];
}
}

View file

@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class UpdateUserRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'first_name' => 'required|string|min:1',
'last_name' => 'required|string|min:1',
'email' => 'email',
'password_confirm' => 'sometimes|required_with:password',
];
}
}