Add all files

This commit is contained in:
root
2025-11-30 11:57:22 +01:00
parent 2ee51cac4f
commit 044271db3d
1476 changed files with 142544 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Observers;
use App\Models\Category;
class CategoryObserver
{
/**
* Handle the Category "creating" event.
*
* @return void
*/
public function creating(Category $category)
{
$parent = $category->parent;
$full_slug = $category->slug;
// Set full_slug
while ($parent) {
$fullSlug = $parent->slug;
$full_slug = $fullSlug . '/' . $full_slug;
$parent = $parent->parent;
}
$category->full_slug = $full_slug;
}
/**
* Handle the Category "updating" event.
*
* @return void
*/
public function updating(Category $category)
{
// Did parent or slug change?
if ($category->isDirty('parent_id') || $category->isDirty('slug')) {
$parent = $category->parent;
$full_slug = $category->slug;
// Set full_slug
while ($parent) {
$fullSlug = $parent->slug;
$full_slug = $fullSlug . '/' . $full_slug;
$parent = $parent->parent;
}
$category->full_slug = $full_slug;
// Update children
$category->children->each(function ($child) use ($category) {
$child->update([
'full_slug' => $category->full_slug . '/' . $child->slug,
]);
});
}
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace App\Observers;
use App\Events\InvoiceItem as InvoiceItemEvent;
use App\Models\InvoiceItem;
class InvoiceItemObserver
{
/**
* Handle the InvoiceItem "creating" event.
*/
public function creating(InvoiceItem $invoice): void
{
event(new InvoiceItemEvent\Creating($invoice));
}
/**
* Handle the InvoiceItem "created" event.
*/
public function created(InvoiceItem $invoice): void
{
event(new InvoiceItemEvent\Created($invoice));
}
/**
* Handle the InvoiceItem "updating" event.
*/
public function updating(InvoiceItem $invoice): void
{
event(new InvoiceItemEvent\Updating($invoice));
}
/**
* Handle the InvoiceItem "updated" event.
*/
public function updated(InvoiceItem $invoice): void
{
event(new InvoiceItemEvent\Updated($invoice));
}
/**
* Handle the InvoiceItem "deleted" event.
*/
public function deleted(InvoiceItem $invoice): void
{
event(new InvoiceItemEvent\Deleted($invoice));
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Observers;
use App\Events\Invoice as InvoiceEvent;
use App\Models\Invoice;
class InvoiceObserver
{
/**
* Handle the Invoice "creating" event.
*/
public function creating(Invoice $invoice): void
{
event(new InvoiceEvent\Creating($invoice));
}
/**
* Handle the Invoice "created" event.
*/
public function created(Invoice $invoice): void
{
event(new InvoiceEvent\Created($invoice));
$sendEmail = $invoice->send_create_email;
dispatch(function () use ($invoice, $sendEmail) {
event(new InvoiceEvent\Finalized($invoice, $sendEmail));
})->afterResponse();
}
/**
* Handle the Invoice "updating" event.
*/
public function updating(Invoice $invoice): void
{
event(new InvoiceEvent\Updating($invoice));
}
/**
* Handle the Invoice "updated" event.
*/
public function updated(Invoice $invoice): void
{
if ($invoice->isDirty('status') && $invoice->status == 'paid') {
event(new InvoiceEvent\Paid($invoice));
}
event(new InvoiceEvent\Updated($invoice));
}
/**
* Handle the Invoice "deleted" event.
*/
public function deleted(Invoice $invoice): void
{
event(new InvoiceEvent\Deleted($invoice));
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace App\Observers;
use App\Events\InvoiceTransaction as InvoiceTransactionEvent;
use App\Models\InvoiceTransaction;
class InvoiceTransactionObserver
{
/**
* Handle the InvoiceTransaction "creating" event.
*/
public function creating(InvoiceTransaction $invoice): void
{
event(new InvoiceTransactionEvent\Creating($invoice));
}
/**
* Handle the InvoiceTransaction "created" event.
*/
public function created(InvoiceTransaction $invoice): void
{
event(new InvoiceTransactionEvent\Created($invoice));
}
/**
* Handle the InvoiceTransaction "updating" event.
*/
public function updating(InvoiceTransaction $invoice): void
{
event(new InvoiceTransactionEvent\Updating($invoice));
}
/**
* Handle the InvoiceTransaction "updated" event.
*/
public function updated(InvoiceTransaction $invoice): void
{
event(new InvoiceTransactionEvent\Updated($invoice));
}
/**
* Handle the InvoiceTransaction "deleted" event.
*/
public function deleted(InvoiceTransaction $invoice): void
{
event(new InvoiceTransactionEvent\Deleted($invoice));
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Observers;
use App\Events\Order as OrderEvent;
use App\Models\Order;
class OrderObserver
{
/**
* Handle the Order "creating" event.
*/
public function creating(Order $order): void
{
event(new OrderEvent\Creating($order));
}
/**
* Handle the Order "created" event.
*/
public function created(Order $order): void
{
event(new OrderEvent\Created($order));
$sendEmail = $order->send_create_email;
dispatch(function () use ($order, $sendEmail) {
event(new OrderEvent\Finalized($order, $sendEmail));
})->afterResponse();
}
/**
* Handle the Order "updating" event.
*/
public function updating(Order $order): void
{
event(new OrderEvent\Updating($order));
}
/**
* Handle the Order "updated" event.
*/
public function updated(Order $order): void
{
event(new OrderEvent\Updated($order));
}
/**
* Handle the Order "deleted" event.
*/
public function deleted(Order $order): void
{
event(new OrderEvent\Deleted($order));
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Observers;
use App\Events\Property as PropertyEvent;
use App\Models\Property;
class PropertyObserver
{
/**
* Handle the Property "creating" event.
*/
public function created(Property $property): void
{
event(new PropertyEvent\Created($property));
}
/**
* Handle the Property "updating" event.
*/
public function updated(Property $property): void
{
event(new PropertyEvent\Updated($property));
}
/**
* Handle the Property "deleted" event.
*/
public function deleted(Property $property): void
{
event(new PropertyEvent\Deleted($property));
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Observers;
use App\Events\ServiceCancellation as ServiceCancellationEvent;
use App\Models\ServiceCancellation;
class ServiceCancellationObserver
{
/**
* Handle the ServiceCancellation "created" event.
*/
public function created(ServiceCancellation $serviceCancellation): void
{
event(new ServiceCancellationEvent\Created($serviceCancellation));
}
/**
* Handle the ServiceCancellation "updated" event.
*/
public function updated(ServiceCancellation $serviceCancellation): void
{
event(new ServiceCancellationEvent\Updated($serviceCancellation));
}
/**
* Handle the ServiceCancellation "deleted" event.
*/
public function deleted(ServiceCancellation $serviceCancellation): void
{
event(new ServiceCancellationEvent\Deleted($serviceCancellation));
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Observers;
use App\Events\Service as ServiceEvent;
use App\Models\Service;
class ServiceObserver
{
/**
* Handle the Service "created" event.
*/
public function created(Service $service): void
{
event(new ServiceEvent\Created($service));
}
/**
* Handle the Service "updated" event.
*/
public function updated(Service $service): void
{
event(new ServiceEvent\Updated($service));
}
/**
* Handle the Service "deleted" event.
*/
public function deleted(Service $service): void
{
event(new ServiceEvent\Deleted($service));
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Observers;
use App\Events\ServiceUpgrade as ServiceUpgradeEvent;
use App\Models\ServiceUpgrade;
class ServiceUpgradeObserver
{
/**
* Handle the ServiceUpgrade "created" event.
*/
public function created(ServiceUpgrade $serviceUpgrade): void
{
event(new ServiceUpgradeEvent\Created($serviceUpgrade));
}
/**
* Handle the ServiceUpgrade "updated" event.
*/
public function updated(ServiceUpgrade $serviceUpgrade): void
{
event(new ServiceUpgradeEvent\Updated($serviceUpgrade));
}
/**
* Handle the ServiceUpgrade "deleted" event.
*/
public function deleted(ServiceUpgrade $serviceUpgrade): void
{
event(new ServiceUpgradeEvent\Deleted($serviceUpgrade));
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Observers;
use App\Events\TicketMessage as TicketEvent;
use App\Models\TicketMessage;
class TicketMessageObserver
{
/**
* Handle the TicketMessage "created" event.
*/
public function created(TicketMessage $ticketMessage): void
{
event(new TicketEvent\Created($ticketMessage));
}
/**
* Handle the TicketMessage "uçpdated" event.
*/
public function updated(TicketMessage $ticketMessage): void
{
event(new TicketEvent\Updated($ticketMessage));
}
/**
* Handle the TicketMessage "deleted" event.
*/
public function deleted(TicketMessage $ticketMessage): void
{
event(new TicketEvent\Deleted($ticketMessage));
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Observers;
use App\Events\Ticket as TicketEvent;
use App\Models\Ticket;
class TicketObserver
{
/**
* Handle the Ticket "created" event.
*/
public function created(Ticket $ticket): void
{
event(new TicketEvent\Created($ticket));
}
/**
* Handle the Ticket "uçpdated" event.
*/
public function updated(Ticket $ticket): void
{
event(new TicketEvent\Updated($ticket));
}
/**
* Handle the Ticket "deleted" event.
*/
public function deleted(Ticket $ticket): void
{
event(new TicketEvent\Deleted($ticket));
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Observers;
use App\Events\User as UserEvent;
use App\Models\User;
class UserObserver
{
/**
* Handle the User "creating" event.
*/
public function creating(User $user): void
{
event(new UserEvent\Creating($user));
}
/**
* Handle the User "created" event.
*/
public function created(User $user): void
{
event(new UserEvent\Created($user));
}
/**
* Handle the User "updated" event.
*/
public function updated(User $user): void
{
event(new UserEvent\Updated($user));
}
/**
* Handle the User "deleted" event.
*/
public function deleted(User $user): void
{
//
}
}