im doing save cookie but have a problem . Here is my helper
public function check_if_exist($user){
$isExisted = User::where('email', $request->get('email'))->first();
if(!$isExisted) {
$user = new User();
$user = $user->isExisted($request);
$user->save();
Cookie::queue($user);
}
Cookie::queue($user);
}
and here is my controller , i
public function store(SignRequest $request, WiuCookie $wcookie, CheckUser $check)
{
$check = ActionUsers::where('petition_id', $request->get('petition_id'))->where('email', $request->get('email'))->first();
if($check) {
return back()->with('fail','You fail');
}
$sign = new ActionUsers();
$sign = $sign->init($request);
if( $sign->save() ){
$wcookie->setById($sign->petition_id);
$check->check_if_exist($sign);
return redirect('/thanks/signed/'.$sign->petition->slug);
}else{
return redirect()->back();
}
}
and error is
Call to a member function check_if_exist() on null.
I dont know i called variable right or not. i'm use enough params but it's not working Anyone can solve that. Thanks