D
D
Danila5342020-12-06 18:24:42
Laravel
Danila534, 2020-12-06 18:24:42

Why does the debugger crash?

I don't understand what's the matter, in theory my function should work only when the time >= Carbon::now()
But... Most likely the reason is that laravel allocates the entire table via get() , despite the condition.

public  function  privil(Request $request)
    {
        $User = Auth::user();
        $now = Carbon::now();
        $quantity = 10;
        $information = DB::table('role_user')->select('times', 'user_id')->get();
        
        if($information->times >= $now) {
            DB::table('users')->where($information->user_id, 'id')->update(['Money' => 10]);
        }

        return back()->with('success', ['Баланс успешно пополнен!']);
    }

Error: "Property [times] does not exist on this collection instance."

Some lines are empty, most likely because of this and an error, how to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question