如何在Laravel中生成月度和年度重复发票[关闭]

I am doing an invoice application in Laravel. In my application, users can create recurring profiles. Those profiles are automatically generated invoices for monthly or yearly based on invoice date. I want to know how to do this task, can anybody give suggestions?

What I Do: When a user creates a recurring profile, I save the next recurring date in recurring profile table. Every time I generate an invoice based on next recurring date. In this process I have following problem, user deactivate the profile and again activate after 2 months, the invoice cannot generated.

Open kernal.php file in app->console folder

protected function schedule(Schedule $schedule)
    {
        $schedule->call(function () {
           //code
        })->monthly();

        $schedule->call(function () {
           //code
        })->yearly();

        //this following code will execute the task on last day of every month 
        $schedule->call(function () {
           //code
        })->when(function () {
                return \Carbon\Carbon::now()->endOfMonth()->isToday();
                });
    }

In the schedule method, write your code inside anonymous function and use monthly() and yearly() function to trigger the method every month and year automatically.

More information here https://laravel.com/docs/5.4/scheduling#schedule-frequency-options