amitshahc

amitshahc

Member Since 1 Year Ago

Vadodara

Experience Points
4,500
Total
Experience

500 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
35
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
4,500 XP
Jan
16
1 week ago
Activity icon

Replied to Laravel Passport Token Idle Time Setting?

I still didn't understand the use of refreshTokensExpireIn.

Can you please explain with a scenario/example explaining in simple words? I can't find anything in the documentation.

Activity icon

Replied to Laravel Passport Token Idle Time Setting?

ok, so using that check of last activity I can make some logic to refresh token. but i am not clear about what exactly the refreshTokensExpireIn() used for.

also, what is the difference between tokensExpireIn() and personalAccessTokensExpireIn().

Jan
13
1 week ago
Activity icon

Started a new Conversation Laravel Passport Token Idle Time Setting?

Is it possible to set the token idle time for Laravel Passport, such that if the user is not active with his API calls for last few minutes then the token gets expired?

Jan
06
2 weeks ago
Activity icon

Replied to Hierarchical User Management

It's ultimately same as spatie/laravel-permission. I was asking for Hierarchical tree structure in addition.

Jan
04
2 weeks ago
Activity icon

Started a new Conversation Hierarchical User Management

Is there any best package in Laravel for hierarchical user management, together with roles and permissions? Currently i have choose to use spatie/laravel-permission +kalnoy/nestedset. But i am bit confused how should i approach to integrate the both.

My query is: should I integrate the nested plugin on user table or on roles table? or on both and manage them in coding.

Or is there a better alternative which solves both above?

Dec
31
3 weeks ago
Activity icon

Started a new Conversation Laravel\Cashier\PaymentMethod API Documentation

Where can i find the documentation of Laravel\Cashier\PaymentMethod collection/class returned from $user->paymentMethods().

Dec
19
1 month ago
Activity icon

Replied to Laravel 6 Custom Package Development: How To Auto Publish The Package Config File?

@johnbraun This is very helpful. I will emphatically try this.

Activity icon

Started a new Conversation Laravel 6 Custom Package Development: How To Auto Publish The Package Config File?

I have developed a Laravel v6.0 package. I am trying to auto publish the package's config file immediately after the package installation using below scripts directives in my package's composer.json file:

package/composer.json:

"scripts": {
        "post-package-install": [
            "php artisan vendor:publish --tag=advertisement-config --force"
        ],
        "post-package-update": [
            "php artisan vendor:publish --tag=advertisement-config --force"
        ]
    }

The above scripts commands are not executing anytime during/after installing the package. I have to run this command manually after the installation completes. Is there any way that the config file publishes automatically after successful installation?

Oct
23
3 months ago
Activity icon

Replied to Laravel 5 Package Development Helpers File

@peanut your first approach to declare in composer.json > autoload > files is perfect. but to make it included in your package is to have it initiated at the time of installing the package. meaning if you have already installed the package and want to add this file then you either need to reinstall it or run composer update <your package>.

Oct
09
3 months ago
Activity icon

Replied to How To Automaticly Update Updated_by, Created_by Fields Using Eloquent?

@quentinbontemps I tried this

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use app\Observers\RecordFingerPrintObserver;

class RecordFingerPrintModel extends Model
{
    

    public static function boot()
    {
        $class = get_called_class();
        $class::observe(new RecordFingerPrintObserver(2));
    
        parent::boot();
    }
}

but the error says:

ErrorException
Undefined index: Modules\Admin\Entities\Pages

this is actually a model class

Sep
25
3 months ago
Activity icon

Replied to Laravel 6: Route::group Array Parameter Are Not Working As Per 5.x

Thanks it works as as instead of name. but why it's hard to find this keyword/syntax in documentation, wondering.!

Activity icon

Started a new Conversation Laravel 6: Route::group Array Parameter Are Not Working As Per 5.x

According to the documentation below both should work same:

Route::middleware('web')->name('admin.')->prefix('admin')->group(function () {
...
});

This 1st approach is working and the admin.login url can be found in the route:list

Route::group(['middleware' => 'web', 'prefix' => 'admin', 'name' => 'admin.'], function () {
...
});

but in 2nd approach the name is not getting updated as admin.login

I guess there is something that some parameters are removed from array notation list.

Sep
23
4 months ago
Activity icon

Replied to Dynamic Sub-domain Creation On New User Registration In Laravel 5 And WampServer

but in this tc.dev is hardcoded?

I have my domain name as test1.com on my local pc and on server when i deploy it can be testing.com so how do we manage the dynamic domain (root level domain name) in the route?

Sep
19
4 months ago
Activity icon

Replied to Passing A Variable Into Blade Directive Doesn't Pass Variable Content, But Name Of Variable

This one is very odd usage. what if i want to pass some date as string and timezone so that i can print the local time on the template? This kind of approach is waste. it doesn't meet its goal.

public function registerBladeDirectives()
    {
        \Blade::directive('localtime', function ($datetime, $timezone = null) {
            dd($datetime);
            $datetime_carbon = \DateTimeOperations::getCarbonObject($datetime);
            $timezone = $timezone ?? config('app.timezone');
dd($datetime, $datetime_carbon);
            return "<?php echo ($datetime_carbon->setTimezone($timezone)->toDayDateTimeString(), $datetime_carbon->tzName); ?>";
        });
    }

so calling @localtime($appointment->start_time, $shop->timzone) will just print "$appointment->start_time" i can't get the parsed value inside it.

Sep
14
4 months ago
Activity icon

Replied to $schedule->job Alway Goes To OnFailure

no, i don't think it will have any change in it's behavior as per your explanations, so i just let it be like this.

Sep
09
4 months ago
Activity icon

Replied to $schedule->job Alway Goes To OnFailure

it will take me till today, as i come office only during working days. :P

class SubscriptionRenewal // implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, SerializesModels; // Queueable

still same.. anyways it's going into after() block but still i am not satisfied with the way it always going into onFailure() block too.

Sep
08
4 months ago
Activity icon

Replied to $schedule->job Alway Goes To OnFailure

I will try that tomorrow. but note that my default queue is sync so won't go to database. whereas in notification class i have added $this->connection = 'database'

Activity icon

Replied to $schedule->job Alway Goes To OnFailure

You are not understanding me either.

The scheduler creates a job. That job is queued. (in my case the job is executing and no being queued, only the notifications inside that jobs are being queue. but that's not the point i am asking anyways...)

The scheduler is done. (here it should at least go inside after() function. even if it do not supports the job result evaluation in terms of success or failure.

Activity icon

Replied to $schedule->job Alway Goes To OnFailure

"SubscriptionRenewal job is started" is being printed so the before block is executing. the jobs are also being added in jobs table. but then it always prints the text which is inside onFailure(), i know its working fine. but my question is it's not reporting truth. what if in failure case we want to do something else?

again, my question is only with regards to its wrong reporting. whereas the the other codes with $schedule->commands are reporting exact truth.

Activity icon

Replied to $schedule->job Alway Goes To OnFailure

same flow and behavior like it does for commands.

Sep
06
4 months ago
Activity icon

Replied to $schedule->job Alway Goes To OnFailure

yes, as i mentioned the notification jobs are being added to the jobs table successfully.

Activity icon

Started a new Conversation $schedule->job Alway Goes To OnFailure

I have this code as one of the scheduler task in my Kernel.php file:

$schedule->job(new SubscriptionRenewal($this->repo))->everyMinute()
            ->before(function () {
                echo "\r\n\nSubscriptionRenewal job is started..\n";
            })
            ->after(function () {
                echo "\r\n\nFinished.!\n";
                // $this->_runDBqueue($schedule);
            })
            ->onSuccess(function () use ($schedule) {
                echo "\r\n\nSuccess\n";
                // $this->_runDBqueue($schedule);
            })
            ->onFailure(function () {
                echo "\r\n\nFailed\n";
            })
        // ->withoutOverlapping()
            ->appendOutputTo($this->logfile)
            ->emailOutputTo(config('constants.scheduler.report_email'));

When i run php artisan schedule:run from CLI it always print the Failed message even if the Queued notification i am executing in that job are being added in jobs table. So the task is successfully adding the jobs in table but still it is being considered as Failed task. no log can be found anywhere in the system.

This is my SubscriptionRenewal job class:

<?php

namespace Modules\SuperAdmin\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Modules\SuperAdmin\Entities\Repository\Contract\CronjobRepository;
use Modules\SuperAdmin\Notifications\SubscriptionRenewal as RenewalNotification;

class SubscriptionRenewal implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $repo;
    
    // public $tries   = 10; // Max tries
    // public $timeout = 60; // Timeout seconds

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(CronjobRepository $repo)
    {
        $this->repo = $repo;
        // $this->connection = 'database';
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $shopowners_expiring = $this->repo->getExpiringSubscriptions($days = 7);
        // dd($shopowners_expiring->toArray());
        $shopowners_expiring->each(function ($shopowner) {

            \Notification::send($shopowner, new RenewalNotification);

            // \Mail::to($shopowner)->send((new SubscriptionRenewal($shopowner))->onConnection('database'));

            // dump($shopowner->toArray());
        });

        return true;
    }

    public function failed(\Exception $e)
    {
        dump($e);
        report($e);
    }
}

Aug
30
4 months ago
Activity icon

Replied to Informal Poll: Routes File

The beginner will go blank about the route file location.. where to put it for first run. What is the problem for default route file is there?

Activity icon

Replied to Custom Command Running Directly From CLI But Not From Schedule:run In CLI

New issue of execution order

I refactored my Kernel.php as follows:

<?php

namespace App\Console;

use Artisan;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Modules\SuperAdmin\Entities\Repository\Contract\CronjobRepository;
use Modules\SuperAdmin\Jobs\SubscriptionRenewal;

class Kernel extends ConsoleKernel
{
    protected $repo;
    protected $logfile;
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        \App\Console\Commands\FreeSubscriptionFallback::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $today         = \DateTimeOperations::today()->toDateString();
        $this->logfile = config('constants.scheduler.logfile_path') . $today . '.log';
        $this->repo    = resolve(CronjobRepository::class);

        $this->_renewalNotificationJob($schedule);
        $this->_subscriptionFallback($schedule);

        $schedule->command("inspire")->everyMinute()
        // ->appendOutputTo($logfile)
            ->emailOutputTo(config('constants.scheduler.report_email'));

    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

        require base_path('routes/console.php');
    }

    private function _renewalNotificationJob(&$schedule)
    {
        $schedule->job(new SubscriptionRenewal($this->repo))->everyMinute() //daily()
            ->before(function () {
                echo "SubscriptionRenewal job is started..\n";
            })
            ->after(function () {
                echo "Databse queue is started..\n";
                echo $exitCode = Artisan::call('queue:work database --stop-when-empty');
                echo "Finished.!\n";
                echo Artisan::output();
            })
        // ->withoutOverlapping()
            ->appendOutputTo($this->logfile)
            ->emailOutputTo(config('constants.scheduler.report_email'));
    }

    private function _subscriptionFallback(&$schedule)
    {
        $schedule->command("subscriptions:fallback 2")->everyMinute()
            ->before(function () {
                echo "subscriptions:fallback command is started..\n";
            })
            ->after(function () {
                echo "Finished.!\n";
            })
            ->onSuccess(function () {
                echo "Success\n";
            })
            ->onFailure(function () {
                echo "Failed\n";
            })
        // ->withoutOverlapping()
            ->appendOutputTo($this->logfile)
            ->emailOutputTo(config('constants.scheduler.report_email'));
    }
}

The issue is if i run the job first then no more command are being executed.

$this->_renewalNotificationJob($schedule);
$this->_subscriptionFallback($schedule);

but if i run all the command first and job at last, then everything is being executed.


        $this->_subscriptionFallback($schedule);

        $schedule->command("inspire")->everyMinute()
            ->appendOutputTo($this->logfile)
            ->emailOutputTo(config('constants.scheduler.report_email'));
        
        $this->_renewalNotificationJob($schedule);

The moral of the story is $schedule->job stops further execution.

Activity icon

Replied to Custom Command Running Directly From CLI But Not From Schedule:run In CLI

SOLVED

For those who are failing without having any error logs anywhere make sure this things first. In my case there were a combinations of the reasons.

  1. The "--force" option does not exist remove any options that do not support your custom command and try to run it independent.
  2. This was the most important change: the $logfile path was inside /storage/logs/schedule/today.log so i was expecting that the schedule sub directory will be getting created by its own like a normal behavior. but i was wrong either keep the log file path directly in to /storage/logs/ or create/keep the sub directory /schedule/ being existed before running this command.
Activity icon

Replied to Schedule:run Not Calling Artisan Command

I have created new thread here: https://laracasts.com/discuss/channels/laravel/custom-command-running-directly-from-cli-but-not-from-schedulerun-in-cli#

I realized it's going into onFailure after adding that block. but can't find any logs anywhere.

Activity icon

Started a new Conversation Custom Command Running Directly From CLI But Not From Schedule:run In CLI

My OS is Windows 7 : Laravel 5.8

Some how I also found the same issue and tried everything listed here but no solution yet. I am using Laravel 5.8 and when i run the command from my windows cmd using

php artisan subscription:fallback it's running and i can verify the entries in the database which been created by that job.

But the same command is not executing when i call php artisan schedule:run it prints the messages in before() and after() hooks plus sending the email but with blank content. but no code being executed inside the handle() method.

myLaravelProject >php artisan schedule:run
Running scheduled command: "D:\Installation\php7114\php.exe" "artisan" inspire >> "D:\Installation\Apache24\htdocs\spaadvisor.com\storage\logs/schedule/2019-08-29.log" 2>&1
Running scheduled command: "D:\Installation\php7114\php.exe" "artisan" subscriptions:fallback 2 --force >> "D:\Installation\Apache24\htdocs\spaadvisor.com\storage\logs/schedule/2019-08-29.log" 2>&1
subscriptions:fallback command is started..
Finished.!

FreeSubscriptionFallback:

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Modules\SuperAdmin\Entities\Repository\Contract\CronjobRepository;

class FreeSubscriptionFallback extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'subscriptions:fallback {days=2: number of max days from today to calculate expiry date range}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Auto renewal of shop-owner\'s subscriptions to Free for which are expiring within next {days=2} days';

    /**
     * Create a new command instance.
     *
     * @return void
     */

    protected $repo;

    public function __construct(CronjobRepository $repo)
    {
        parent::__construct();
        $this->repo = $repo;
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $this->info('Subscription fallback command logic : STARTED');
        // dd('hello');
        $days       = (int) $this->argument('days');
        $shopowners = $this->repo->getActiveSubscriptions($days);
        // dd($shopowners);
        try {
            $shopowners->each(function ($shopowner) {
                $this->line('Creating default subscription for shopowner id:', $shopowner->id);
                $this->repo->beginTransaction();
                $this->repo->createSubscription_default($shopowner);
                $this->repo->commit();
            });

            $this->info('Subscription fallback command logic : ENDED');

        } catch (\Throwable $th) {
            $this->repo->rollback();
            $this->error('Subscription fallback command logic : ERROR', $th);
            report($th);
        }
    }
}

Kernel.php:

<?php

namespace App\Console;

use Artisan;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Modules\SuperAdmin\Jobs\SubscriptionRenewal;
use Modules\SuperAdmin\Entities\Repository\Contract\CronjobRepository;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        \App\Console\Commands\FreeSubscriptionFallback::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
        //          ->hourly();
        $today    = \DateTimeOperations::today()->toDateString();
        $logfile  = config('constants.scheduler.logfile_path') . $today . '.log'; //storage_path("logs/schedule/". $today .".log");
        $cronRepo = resolve(CronjobRepository::class);

        $schedule->job(new SubscriptionRenewal($cronRepo))->daily()
            ->before(function () {
                echo "SubscriptionRenewal job is started..\n";
            })
            ->after(function () {
                echo "Databse queue is started..\n";
                echo $exitCode = Artisan::call('queue:work database --stop-when-empty');
                echo "Finished.!\n";
                echo Artisan::output();
            })
            ->appendOutputTo($logfile)
            ->emailOutputTo(config('constants.scheduler.report_email'));

        $schedule->command("inspire")->everyMinute()
            ->appendOutputTo($logfile)
            ->emailOutputTo(config('constants.scheduler.report_email'));

        $schedule->command("subscriptions:fallback 2 --force")->everyMinute()
            ->before(function () {
                echo "subscriptions:fallback command is started..\n";
            })
            ->after(function () {
                echo "Finished.!\n";
                // echo Artisan::output();
            })
            ->onSuccess(function () {
                echo "Success";
            })
            ->onFailure(function () {
                echo "Failed";
            })
            ->appendOutputTo($logfile)
            ->emailOutputTo(config('constants.scheduler.report_email'));
        // echo Artisan::output();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

        require base_path('routes/console.php');
    }
}

After adding ->onFailure() in above i realized that it's printing Failed but no logs anywhere can be found (email, logfile, laravel log, catch..) So how to print the Failure reason?

Aug
29
4 months ago
Activity icon

Replied to Schedule:run Not Calling Artisan Command

Some how I also found the same issue and tried everything listed here but no solution yet. I am using Laravel 5.8 and when i run the command from my windows cmd using

php artisan subscription:fallback it's running and i can verify the entries in the database which been created by that job.

But the same command is not executing when i call php artisan schedule:run it prints the messages in before() and after() hooks plus sending the email but with blank content. but no code being executed inside the handle() method.

myLaravelProject >php artisan schedule:run
Running scheduled command: "D:\Installation\php7114\php.exe" "artisan" inspire >> "D:\Installation\Apache24\htdocs\spaadvisor.com\storage\logs/schedule/2019-08-29.log" 2>&1
Running scheduled command: "D:\Installation\php7114\php.exe" "artisan" subscriptions:fallback 2 --force >> "D:\Installation\Apache24\htdocs\spaadvisor.com\storage\logs/schedule/2019-08-29.log" 2>&1
subscriptions:fallback command is started..
Finished.!

FreeSubscriptionFallback:

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Modules\SuperAdmin\Entities\Repository\Contract\CronjobRepository;

class FreeSubscriptionFallback extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'subscriptions:fallback {days=2: number of max days from today to calculate expiry date range}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Auto renewal of shop-owner\'s subscriptions to Free for which are expiring within next {days=2} days';

    /**
     * Create a new command instance.
     *
     * @return void
     */

    protected $repo;

    public function __construct(CronjobRepository $repo)
    {
        parent::__construct();
        $this->repo = $repo;
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $this->info('Subscription fallback command logic : STARTED');
        // dd('hello');
        $days       = (int) $this->argument('days');
        $shopowners = $this->repo->getActiveSubscriptions($days);
        // dd($shopowners);
        try {
            $shopowners->each(function ($shopowner) {
                $this->line('Creating default subscription for shopowner id:', $shopowner->id);
                $this->repo->beginTransaction();
                $this->repo->createSubscription_default($shopowner);
                $this->repo->commit();
            });

            $this->info('Subscription fallback command logic : ENDED');

        } catch (\Throwable $th) {
            $this->repo->rollback();
            $this->error('Subscription fallback command logic : ERROR', $th);
            report($th);
        }
    }
}

Kernel.php:

<?php

namespace App\Console;

use Artisan;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Modules\SuperAdmin\Jobs\SubscriptionRenewal;
use Modules\SuperAdmin\Entities\Repository\Contract\CronjobRepository;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        \App\Console\Commands\FreeSubscriptionFallback::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
        //          ->hourly();
        $today    = \DateTimeOperations::today()->toDateString();
        $logfile  = config('constants.scheduler.logfile_path') . $today . '.log'; //storage_path("logs/schedule/". $today .".log");
        $cronRepo = resolve(CronjobRepository::class);

        $schedule->job(new SubscriptionRenewal($cronRepo))->daily()
            ->before(function () {
                echo "SubscriptionRenewal job is started..\n";
            })
            ->after(function () {
                echo "Databse queue is started..\n";
                echo $exitCode = Artisan::call('queue:work database --stop-when-empty');
                echo "Finished.!\n";
                echo Artisan::output();
            })
            ->appendOutputTo($logfile)
            ->emailOutputTo(config('constants.scheduler.report_email'));

        $schedule->command("inspire")->everyMinute()
            ->appendOutputTo($logfile)
            ->emailOutputTo(config('constants.scheduler.report_email'));

        $schedule->command("subscriptions:fallback 2 --force")->everyMinute()
            ->before(function () {
                echo "subscriptions:fallback command is started..\n";
            })
            ->after(function () {
                echo "Finished.!\n";
                // echo Artisan::output();
            })
            ->appendOutputTo($logfile)
            ->emailOutputTo(config('constants.scheduler.report_email'));
        // echo Artisan::output();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

        require base_path('routes/console.php');
    }
}
Aug
21
5 months ago
Activity icon

Replied to SQLSTATE[HY000] [1045] Access Denied For User 'root'@'localhost' (using Password: YES)

Recently I just upgraded my project from Laravel 5.5 to 5.8. But was getting an error when I deployed on the live web server.

SQLSTATE[HY000] [1045] Access denied for user 'avixxxxx_xxxxx'@'localhost' (using password: YES) (SQL: select * from `users` where `username` = [email protected] limit 1)

The password DB_PASSWORD=qoq#12ba i had entered in the .env file was completely fine. but when I checked the /bootstrap/cache/config.php file there it was compiled as 'qoq'. that means the # was being parsed as a comment in .env file.

I was forced to wrap the password inside quotes DB_PASSWORD="qoq#12ba" then it worked.