1. Go to this page and download the library: Download blackpig-creatif/ephemeride 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/ */
blackpig-creatif / ephemeride example snippets
namespace App\BlackpigCreatif\Ephemeride;
use BlackpigCreatif\Ephemeride\Contracts\ProvidesEphemerides;
use BlackpigCreatif\Ephemeride\Data\EphemerisEvent;
use Carbon\Carbon;
use Illuminate\Support\Collection;
class FestivalsProvider implements ProvidesEphemerides
{
public function getEphemerides(Carbon $from, Carbon $to): Collection
{
return Event::query()
->whereBetween('starts_at', [$from, $to])
->get()
->map(fn (Event $event) => EphemerisEvent::make(
id: (string) $event->id,
title: $event->title,
startsAt: $event->starts_at,
endsAt: $event->ends_at,
colour: $event->colour,
url: route('events.show', $event),
));
}
}
return [
// Views available in the switcher. Supported: 'month', 'week'.
'views' => ['month', 'week'],
// The view shown on first render.
'default_view' => 'month',
// Hour range for the week view time grid. Events outside this window are not shown.
'week_start_hour' => 7,
'week_end_hour' => 21,
// Slot interval in minutes.
'slot_interval' => 30,
// First day of the week. 1 = Monday (ISO), 0 = Sunday.
'week_starts_at' => 1,
// Maximum event chips per day cell before '+X more' is shown.
'month_max_events_per_day' => 3,
// Label for the CTA button in the popover and as the panel single-url fallback.
// Has no effect when the event provides a `links` array.
'popover_cta_label' => 'View Details',
// Global CSS custom property overrides. Merged with package defaults.
// Per-instance :theme prop values take precedence over these.
'theme' => [],
];
namespace App\BlackpigCreatif\Ephemeride;
class FestivalsProvider implements ProvidesEphemerides
{
public function __construct(private readonly EventRepository $repository) {}
public function getEphemerides(Carbon $from, Carbon $to): Collection
{
return $this->repository->forWindow($from, $to)->map(/* ... */);
}
}
$this->app->bind(FestivalsProvider::class, fn () => new FestivalsProvider(
app(EventRepository::class),
));