mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Janky-ass form request stuff
This commit is contained in:
parent
d4e231d5d4
commit
75eb2bbe09
|
@ -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.
|
||||
|
|
|
@ -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',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
33
app/Http/Requests/UpdateUserRequest.php
Normal file
33
app/Http/Requests/UpdateUserRequest.php
Normal 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',
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue