FareedR
3 months ago
432
4
Laravel

How can I hide data that has been deleted ?

Posted 3 months ago by FareedR

I cannot find any of docs to not display deleted data .

// database 
follow_stocks 
id | stock_id |
1          1
stocks 
id | deleted_at |
1        now()

// controller
most_followed_stocks   = FollowStock::with(['stock' => function ($query){
            $query->withoutTrashed();
        }])->select('stock_id',\DB::raw('count(*) as followed_count'))->groupBy('stock_id')->orderBy('followed_count','desc')->get();

        dd($most_followed_stocks); // still getting the data

Please sign in or create an account to participate in this conversation.