D
D
Danila5342020-12-05 17:54:43
Laravel
Danila534, 2020-12-05 17:54:43

How to make a loop execute when a user enters the site?

Good evening,

I want to implement a cycle, if a registered person visits the site, and his registration date is greater than Carbon::now() , then he will receive 10 rubles on his balance.

The bottom line is that the laravel debugger crawls out if the person is not registered, and if he is registered, then no cycle is performed.

Here is the code for demonstration:

$today = Carbon::now();
        $User = Auth::user();

        $information = DB::table('role_user')->where('user_id', $User->id)->first();

        if($information->times >= $today)
        {
            DB::table('users')->where('name', $User)->update(['money' => 10]);
        }


Please tell me what I did wrong...

($Information is needed, I need to understand the essence, the balance will not end here.)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sanes, 2020-12-05
@Sanes

To hang up event on authorization?

U
uni_rush, 2020-12-07
@uni_rush

Check Authorization

if(Auth::check()){
//
}

the problem is that 10p will be added every time the page is updated if you check by the date of registration.
And yes, this is not a cycle, but a condition.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question