简体   繁体   中英

How to get the post_id from data

I want to get the post_id from the object data. How do I get this?

Here is my code from my controller:

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);
    }
}

您可以这样获得对象值:

$post_id = $data->post_id;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM