PHP code example of mohammedmanssour / laravel-recurring-models

1. Go to this page and download the library: Download mohammedmanssour/laravel-recurring-models library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mohammedmanssour / laravel-recurring-models example snippets


use MohammedManssour\LaravelRecurringModels\Contracts\Repeatable as RepeatableContract;

class Task extends Model implements RepeatableContract
{

}

use MohammedManssour\LaravelRecurringModels\Contracts\Repeatable as RepeatableContract;
use MohammedManssour\LaravelRecurringModels\Concerns\Repeatable;

class Task extends Model implements RepeatableContract
{
    use Repeatable;
}

/**
 * define the base date that we would use to calculate repetition start_at
 */
public function repetitionBaseDate(RepetitionType $type = null): Carbon
{
    return $this->created_at;
}

$model->repeat()->daily()

$model->repeat()->everyNDays(days: 3)

$model->repeat()->weekly()

$model->repeat()->weekly()->on(['sunday', 'monday', 'tuesday'])

$model->repeat()
    ->complex(
        year: '*',
        month: '*',
        day: '*',
        week: '*',
        weekOfMonth: '*',
        weekday: '*'
    )

$model->repeat()->complex(weekOfMonth: 2, weekday: Carbon::FRIDAY)

$model->repeat()->complex(day: 15)

$model->repeat()->daily()->endsAt(
    Carbon::make('2023-06-01')
)

$model->repeat()->daily()->endsAfter($times);

$model->repeat()->daily()->startsAt(
    Carbon::make()
)
bash
php artisan vendor:publish --tag="recurring-models-migrations"
php artisan migrate