Search code examples
laravellaravel-5laravel-5.3laravel-5.4php-carbon

how to check if time is greater than created_at in database with carbon laravel


I want to write a code whereby if a user is created in my database the user must make payment. If the user does not make payment the user should be blocked. I have a column called blocked which is set to 0 by default, but if a user is blocked then its set to 1. On creation of account the created_at column is set to Carbon::now(), but if the user does not pay in 24 hours i want to block the user(i.e set the blocked column to = 1). Please help


Solution

  • whereColumn

    The whereColumn method may be used to verify that two columns are equal

    use Carbon\Carbon;
    
    ->whereColumn('created_at','<=', Carbon::today())