generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from AuroraWebSoftware/v2-dev
V2 dev
- Loading branch information
Showing
24 changed files
with
1,336 additions
and
909 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
docker-compose up -d | ||
composer test | ||
|
||
pint | ||
phpstan | ||
./vendor/bin/pint | ||
./vendor/bin/phpstan analyse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
- Tüm modellerin eventlerini alan bir facade | ||
- config dosyasındaki gereklilik | ||
- dökümantasyon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace AuroraWebSoftware\ACalendar\Collections; | ||
|
||
use AuroraWebSoftware\ACalendar\DTOs\EventInstanceDTO; | ||
use Carbon\CarbonPeriod; | ||
use Illuminate\Support\Collection; | ||
|
||
class EventInstanceDTOCollection extends Collection | ||
{ | ||
/** | ||
* Group and sort by Calendar Day view | ||
*/ | ||
public function byDay(): Collection | ||
{ | ||
$byDayCollection = collect(); | ||
|
||
$this->each(function (EventInstanceDTO $eventInstanceDTO) use ($byDayCollection) { | ||
|
||
$period = CarbonPeriod::create($eventInstanceDTO->start, $eventInstanceDTO->end ?? $eventInstanceDTO->start); | ||
|
||
foreach ($period as $item) { | ||
|
||
$key = $item->format('Y-m-d'); | ||
|
||
if ($byDayCollection->get($key) == null) { | ||
$byDayCollection->put($key, collect()); | ||
} | ||
$byDayCollection->get($key)->push($eventInstanceDTO); | ||
} | ||
}); | ||
|
||
return $byDayCollection; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace AuroraWebSoftware\ACalendar\Contracts; | ||
|
||
use AuroraWebSoftware\ACalendar\Collections\EventInstanceDTOCollection; | ||
use AuroraWebSoftware\ACalendar\DTOs\EventInstanceDTO; | ||
use AuroraWebSoftware\ACalendar\Enums\RepeatFrequency; | ||
use AuroraWebSoftware\ACalendar\Enums\Type; | ||
use AuroraWebSoftware\ACalendar\Models\Event; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Support\Carbon; | ||
|
||
interface EventableModelContract | ||
{ | ||
public static function getModelType(): string; | ||
|
||
public function getModelId(): int; | ||
|
||
public function getEventTitle(): ?string; | ||
|
||
public function updateOrCreateEvent( | ||
string $key, | ||
Type $type, | ||
?Carbon $start = null, | ||
?Carbon $end = null, | ||
?RepeatFrequency $repeatFrequency = null, | ||
?int $repeatPeriod = null, | ||
?Carbon $repeatUntil = null, | ||
): Event; | ||
|
||
/** | ||
* returns the event with the given key with polymorphic relation | ||
* | ||
* @return Event|Builder<Event> | ||
*/ | ||
public function event(string $key): Event|Builder; | ||
|
||
/** | ||
* returns the events of the model with the given keys with polymorphic relation | ||
* returns all if $key is null | ||
* | ||
* @return Event|Builder<Event> | ||
*/ | ||
public function events(?array $key = null): Event|Builder; | ||
|
||
public function deleteEvent(string $key): void; | ||
|
||
/** | ||
* gives all events and recurring occurrences between $start and $end and given keys for a model instance with polymorphic relation | ||
* | ||
* @return EventInstanceDTOCollection<EventInstanceDTO> | ||
*/ | ||
public function eventInstances( | ||
array|string|null $keyOrKeys, | ||
Carbon $start, | ||
Carbon $end, | ||
): EventInstanceDTOCollection; | ||
|
||
/** | ||
* gives all events and recurring occurrences between $start and $end and given keys for a model instance with polymorphic relation | ||
* | ||
* @return EventInstanceDTOCollection<EventInstanceDTO> | ||
*/ | ||
public function scopeAllEventInstances( | ||
Builder $query, | ||
array|string|null $keyOrKeys, | ||
Carbon $start, | ||
Carbon $end, | ||
): EventInstanceDTOCollection; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace AuroraWebSoftware\ACalendar\DTOs; | ||
|
||
use AuroraWebSoftware\ACalendar\Enums\Type; | ||
use Carbon\Carbon; | ||
|
||
/** | ||
* Represents an Instance of Event | ||
*/ | ||
class EventInstanceDTO | ||
{ | ||
/** | ||
* Unique code for each event instance | ||
*/ | ||
public string $code; | ||
|
||
public ?string $modelType; | ||
|
||
public ?int $modelId; | ||
|
||
public string $key; | ||
|
||
public Type $type; | ||
|
||
public string $title; | ||
|
||
public ?Carbon $start; | ||
|
||
public ?Carbon $end; | ||
|
||
public function __construct( | ||
string $code, | ||
?string $modelType, | ||
?int $modelId, | ||
string $key, | ||
Type $type, | ||
string $title, | ||
?Carbon $start = null, | ||
?Carbon $end = null | ||
) { | ||
$this->code = $code; | ||
$this->modelType = $modelType; | ||
$this->modelId = $modelId; | ||
$this->key = $key; | ||
$this->type = $type; | ||
$this->title = $title; | ||
$this->start = $start; | ||
$this->end = $end; | ||
} | ||
|
||
public function calendarStartDatetimePoint(): Carbon | ||
{ | ||
return $this->start; | ||
} | ||
|
||
public function calendarEndDatetimePoint(): Carbon | ||
{ | ||
return $this->end; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.