1. Go to this page and download the library: Download dot-env-it/laravel-calendar 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/ */
dot-env-it / laravel-calendar example snippets
use DotEnv\Calendar\Traits\HasCalendarEvents;
use Illuminate\Database\Eloquent\Casts\Attribute;
class Task extends Model
{
use HasCalendarEvents;
protected $calendar_fillable = [
'title' => 'name', // Source column for event labels
'date_field' => 'next_date', // // Target named route for click actions
'link_id' => 'id', // Optional Primary key for route resolution,(min',
);
}
/**
* Example: Custom attribute for dynamic coloring
*/
protected function eventColor(): Attribute
{
return Attribute::make(
get: fn () => $this->priority === 'high' ? '#e74c3c' : '#3498db',
);
}
}
// In your Model
protected static function booted(): void
{
static::addGlobalScope('active', function (Builder $builder) {
$builder->where('status', 'active');
});
}
use Illuminate\Database\Eloquent\Builder;
class Task extends Model
{
use HasCalendarEvents;
/**
* Specifically filter records for the calendar view
*/
public function applyCalendarFilters(Builder $query): Builder
{
return $query->where('user_id', auth()->id())
->whereNull('deleted_at')
->where('is_private', false);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.