我想从对象数据中获取post_id
。我怎么得到这个?
这是我的控制器中的代码:
class NotificationController extends Controller
{
/**
* Show All Notifications
*
* @return \Illuminate\Http\JsonResponse
*/
public function index()
{
$user = JWTAuth::parseToken()->toUser();
// where('data', 'like', '%"post_id": 35%')
$notification = $user->notifications->where('type', 'App\Notifications\LikePost');
return response()->json(['notification'=> $notification], 200);
}
}
答案 0 :(得分:1)
您可以获取如下对象值:
$post_id = $data->post_id;