[英]Undefined property: App\Http\Controllers\PostController::$p
my controller look like我的控制器看起来像
public function react(Request $request){
//echo "hi";
//return;
//return response()->json($request);
$this->validate($request, [
'postid' => 'required',
'react' => 'required'
]);
$reaction = Reaction::firstOrNew([
'post_id'=>$request->postid,
'user_id'=> Auth::id()
]);
$reaction->user_id = Auth::id();
$reaction->type = $request->react;
$reactType = "";
if ($request->react === "l"){$reactType = "liked";}
else if ($request->react === "d"){$reactType = "disliked";}
else if ($request->react === "h"){$reactType = "loved";}
else if ($request->react === "s"){$reactType = "Smiled";}
else{}
$post = Post::find($request->postid);
$postuser = $post->user->name;
if($post->reactions()->save($reaction)){
$data['message'] = Auth::user()->name.' '.$reactType. ' a Post from' . $postuser;
$data['type'] = 'reaction';
**$this->p->trigger('user-'.$post->user_id, 'new-post', $data);**
return response()->json([
'success' => true,
'message' => 'Reacted'
]);
}
else{
return response()->json([
'success' => false,
'message' => 'Error'
]);
}
AND I AM UNABLE TO LINK WITH PUSHER CHANNEL But I keep getting an error而且我无法与 PUSHER CHANNEL 链接但我不断收到错误消息
Undefined property: App\\Http\\Controllers\\MyController::$p未定义的属性:App\\Http\\Controllers\\MyController::$p
What am I doing wrong?我究竟做错了什么? Would highly appreciate any possible help!非常感谢任何可能的帮助!
my controller look like我的控制器看起来像
public function react(Request $request){
//echo "hi";
//return;
//return response()->json($request);
$this->validate($request, [
'postid' => 'required',
'react' => 'required'
]);
$reaction = Reaction::firstOrNew([
'post_id'=>$request->postid,
'user_id'=> Auth::id()
]);
$reaction->user_id = Auth::id();
$reaction->type = $request->react;
$reactType = "";
if ($request->react === "l"){$reactType = "liked";}
else if ($request->react === "d"){$reactType = "disliked";}
else if ($request->react === "h"){$reactType = "loved";}
else if ($request->react === "s"){$reactType = "Smiled";}
else{}
$post = Post::find($request->postid);
$postuser = $post->user->name;
if($post->reactions()->save($reaction)){
$data['message'] = Auth::user()->name.' '.$reactType. ' a Post from' . $postuser;
$data['type'] = 'reaction';
**$this->p->trigger('user-'.$post->user_id, 'new-post', $data);**
return response()->json([
'success' => true,
'message' => 'Reacted'
]);
}
else{
return response()->json([
'success' => false,
'message' => 'Error'
]);
}
AND I AM UNABLE TO LINK WITH PUSHER CHANNEL But I keep getting an error而且我无法与推销渠道建立联系,但我不断收到错误消息
Undefined property: App\\Http\\Controllers\\MyController::$p未定义的属性:App \\ Http \\ Controllers \\ MyController :: $ p
What am I doing wrong?我究竟做错了什么? Would highly appreciate any possible help!非常感谢您提供任何可能的帮助!
property $this->p
(p) , You have not set the value属性$this->p
(p) ,你还没有设置值
$this->p = Value ;
After setting, you can use the information.设置后,您可以使用该信息。
$this->p->trigger('user-'.$post->user_id, 'new-post', $data);
In the code written above, $this->p
has an null value在上面写的代码中, $this->p
有一个空值
$this->null->trigger('user-'.$post->user_id, 'new-post', $data);
In fact, this is how you use it事实上,这就是你如何使用它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.