在laravel通知中获取列中的数据

问题描述 投票:1回答:2

在我的控制器中使用DD我有这个结果。现在我想获得“id”:45列名称数据enter image description here

控制器:

 public function readbyid($id){

    $test = DB::table('notifications')->where('id','=', $id)->get();

 dd($test);}
arrays laravel pusher
2个回答
3
投票

Id是独一无二的,使用first而不是get

 $test = DB::table('notifications')->where('id', $id)->first();
 $dataId = $test->data->id;
 //or $dataId = json_decode($test->data)->id;

0
投票
use App\Notification; 

$test = Notification::where('id', $id)->first();
$dataId = $test->id;
dd($dataId);
© www.soinside.com 2019 - 2024. All rights reserved.