Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,32 @@ name: run-tests

on:
push:
branches: [main]
branches:
- main
pull_request:
branches: [main]
branches:
- main

jobs:
test:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.2, 8.1]
laravel: [10.*]
php: ['8.1', '8.2', '8.3', '8.4', '8.5']
laravel: ['10.*', '13.*']
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
carbon: ^2.63
exclude:
- laravel: 13.*
php: '8.1'
- laravel: 13.*
php: '8.2'

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ Both variants are equal, and it's just up to your personal preference which one
whenever you want to mount an action programmatically within a calendar context, such as in the `onDateClick` method (more on this later), you can use the `mountAction` method.

```php
public function onDateClick(DateClickInfo $info) {
protected function onDateClick(DateClickInfo $info): void {
$this->mountAction('createFoo');
}
```
Expand Down Expand Up @@ -1015,10 +1015,12 @@ To handle the callback, override the `onEventResize` method and implement your o
use Illuminate\Database\Eloquent\Model;
use Guava\Calendar\ValueObjects\EventResizeInfo;

protected function onEventResize(EventResizeInfo $info, Model $event): void
protected function onEventResize(EventResizeInfo $info, Model $event): bool
{
// Validate the data and handle the event
// Most likely you will want to update the event with the new start /end dates to persist the resize in the database

return true;
}
```

Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@
"require": {
"php": "^8.1|^8.2",
"filament/filament": "^5.0",
"illuminate/contracts": "^11.0|^12.0",
"illuminate/contracts": "^11.0|^12.0|^13.0",
"spatie/laravel-package-tools": "^1.14.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.8|^8.0",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^9.0|^10.0",
"pestphp/pest": "^2.36",
"pestphp/pest-plugin": "^2.1.1",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"orchestra/testbench": "^9.0|^10.0|^11.0",
"pestphp/pest": "^2.36|^4.4",
"pestphp/pest-plugin": "^2.1.1|^4.0",
"pestphp/pest-plugin-arch": "^2.0|^4.0",
"pestphp/pest-plugin-laravel": "^2.0|^4.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0"
"phpstan/phpstan-deprecation-rules": "^1.0|^2.0",
"phpstan/phpstan-phpunit": "^1.0|^2.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/CalendarServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function packageBooted(): void
'calendar-event',
__DIR__ . '/../dist/js/calendar-event.js',
),
Css::make('calendar-styles', 'https://cdn.jsdelivr.net/npm/@event-calendar/build@4.5.0/dist/event-calendar.min.css'),
Js::make('calendar-script', 'https://cdn.jsdelivr.net/npm/@event-calendar/build@4.5.0/dist/event-calendar.min.js'),
Css::make('calendar-styles', 'https://cdn.jsdelivr.net/npm/@event-calendar/build@5.5.1/dist/event-calendar.min.css'),
Js::make('calendar-script', 'https://cdn.jsdelivr.net/npm/@event-calendar/build@5.5.1/dist/event-calendar.min.js'),
],
package: 'guava/calendar'
);
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/HandlesEventResize.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait HandlesEventResize
// TODO: -> getEndAttribute()
// TODO: where the user needs to define which attributes is the start/end date
// TODO: Then we can handle the update outselves by default
public function onEventResize(EventResizeInfo $info, Model $event): bool
protected function onEventResize(EventResizeInfo $info, Model $event): bool
{
return true;
}
Expand Down
28 changes: 25 additions & 3 deletions src/ValueObjects/CalendarResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace Guava\Calendar\ValueObjects;

use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Database\Eloquent\Model;

class CalendarResource
{
protected int | string $id;

protected string $title;
protected string | Htmlable $title;

protected ?string $eventBackgroundColor = null;

Expand All @@ -32,7 +33,7 @@ public function getId(): int | string
return $this->id;
}

public function title(string $title): static
public function title(string | Htmlable $title): static
{
$this->title = $title;

Expand Down Expand Up @@ -121,11 +122,32 @@ public function toCalendarObject(): array
{
return [
'id' => $this->id,
'title' => $this->getTitle(),
'title' => $this->getTitle() instanceof Htmlable ? ['html' => $this->getTitle()->toHtml()] : $this->getTitle(),
'eventBackgroundColor' => $this->getEventBackgroundColor(),
'eventTextColor' => $this->getEventTextColor(),
'children' => collect($this->getChildren())->toArray(),
'extendedProps' => $this->getExtendedProps(),
];
}

public static function fromCalendarObject(array $data): CalendarResource
{
$resource = CalendarResource::make(data_get($data, 'id'));

$resource->title(data_get($data, 'title'));

if ($eventBackgroundColor = data_get($data, 'eventBackgroundColor')) {
$resource->eventBackgroundColor($eventBackgroundColor);
}

if ($eventTextColor = data_get($data, 'eventTextColor')) {
$resource->eventTextColor($eventTextColor);
}

if ($extendedProps = data_get($data, 'extendedProps')) {
$resource->extendedProps($extendedProps);
}

return $resource;
}
}
8 changes: 8 additions & 0 deletions src/ValueObjects/DateClickInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

public CalendarView $view;

public ?CalendarResource $resource;

protected array $originalData;

public function __construct(array $data, bool $useFilamentTimezone)
Expand All @@ -35,6 +37,12 @@ public function __construct(array $data, bool $useFilamentTimezone)
data_get($data, 'tzOffset'),
$useFilamentTimezone
);

if ($resource = data_get($data, 'resource')) {
$this->resource = CalendarResource::fromCalendarObject($resource);
} else {
$this->resource = null;
}
}

public function getContext(): Context
Expand Down
8 changes: 8 additions & 0 deletions src/ValueObjects/DateSelectInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

public CalendarView $view;

public ?CalendarResource $resource;

protected array $originalData;

public function __construct(array $data, bool $useFilamentTimezone)
Expand All @@ -43,6 +45,12 @@ public function __construct(array $data, bool $useFilamentTimezone)
data_get($data, 'tzOffset'),
$useFilamentTimezone
);

if ($resource = data_get($data, 'resource')) {
$this->resource = CalendarResource::fromCalendarObject($resource);
} else {
$this->resource = null;
}
}

public function getContext(): Context
Expand Down
Loading