In my Laravel Application when someone edits their Profile and waits till admin approval, they cannot edit the profile again.I need to implement this rule in FormRequest while user profile is edited.
My User model hasMany profile, but I am taking only the active profile,
public function profile()
{
return $this->hasMany(Profile::class)->where('active', 1);
}
So when user edits profile I will insert into Profile table as active = 0, and update the flag in my User table "profile_review_pending = 1"
Now what I need is I need to define some rule in FormRequest like if profile_review_pending =1 then don't allow editing. Can this be done using exists or something like that?
FormRequestso far.required_if:anotherfield,value,...The field under validation must be present and not empty if the anotherfield field is equal to any value.authorize()method in theFormRequestto prevent the profile from being updated. A more robust way, that you can then use throughout your application, would be to make a policy (laravel.com/docs/7.x/authorization#creating-policies).