ok this is my UserValidationStore class which is working correctly.
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UserValidationStore extends FormRequest
{
/**
* 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[
'firstName' => 'required',
'lastName' => 'required',
'login_name' => 'required|unique:users,login_name',
'password' => 'required|min:8',
'confirm-password' => 'required|min:8|same:password',
'email' => 'required|email|unique:users,email'
];
}
}
The issue is with my UserValidationUpdate Request Class.
Which you and nash have provided solutions for, this is the way that it looks now .
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UserValidationUpdate extends FormRequest
{
/**
* 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 [
'password' => 'min:8',
'confirm-password' => 'min:8|same:password',
'email' => [
'required',
Rule::unique('users')->ignore($this->user()->id),
],
];
}
}
When hitting the save button with out changing anything on the user information i get
ErrorException in UserValidationUpdate.php line 33:
Trying to get property of non-object
I do not know why I am getting the error on Update of the user
I did diedump this and it returned null
$this->user()->id
i then changed it up to
$this->user
and it returned the Id of the user and when I clicked the save button without changing any of the user data. I get the flash message that the user was successfully saved. which is the correct action that should occur.
but when i deliberately change the email address to one that already exists in the database it should come back with an error alert that this email already exists right ?
When I click save it just goes to a blank page with the url showing
drac/admin/user/{id of user}
like it is trying to go back but it cannot render the page correctly.
is there anywhere else i should be looking to get more information on what is going on?