app/Console/Commands/SendEmailWeeklyAboutAssetsTransactions.php
/**
     * Execute the console command.
     *
     * @return int
     */
Execute the console command.
@return int
Execute the console command . @return int
public function handle()
    {
        $users = User::all();
        $emails = [];
        foreach ($users as $key => $user) {
         array_push($emails, $user->email);
     }
    $date = Carbon::today()->subDays(7);
    $trans = Transaction::whereBetween('date', [$date, Carbon::today()])->orderBy('date', 'desc')->get();
     Mail::to($emails)->send(new AssetsTransactions($trans));
 }
public function handle ( ) { $ users = User :: all ( ) ; $ emails = [ ] ; foreach ( $ users as $ key => $ user ) { array_push ( $ emails , $ user -> email ) ; } $ date = Carbon :: today ( ) -> subDays ( 7 ) ; $ trans = Transaction :: whereBetween ( 'date' , [ $ date , Carbon :: today ( ) ] ) -> orderBy ( 'date' , 'desc' ) -> get ( ) ; Mail :: to ( $ emails ) -> send ( new AssetsTransactions ( $ trans ) ) ; }
Execute the console command.
Execute the console command .