Skip to content

Commit

Permalink
Upgrade to Livewire 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Xety committed Sep 29, 2023
1 parent 9d717a6 commit 0140769
Show file tree
Hide file tree
Showing 83 changed files with 2,624 additions and 2,362 deletions.
17 changes: 11 additions & 6 deletions app/Http/Livewire/Calendars.php → app/Livewire/Calendars.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php

namespace Selvah\Http\Livewire;
namespace Selvah\Livewire;

use Carbon\Carbon;
use Illuminate\View\View;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\View\View;
use Livewire\Component;
use Livewire\Attributes\On;
use Selvah\Models\Calendar;

class Calendars extends Component
Expand All @@ -20,10 +21,10 @@ class Calendars extends Component
*
* @var string[]
*/
protected $listeners = [
/*protected $listeners = [
'eventAdd' => 'eventAdd',
'eventDestroy' => 'eventDestroy'
];
];*/

/**
* All the events of the calendar.
Expand Down Expand Up @@ -155,6 +156,8 @@ public function render(): View
*/
public function eventChange(array $event): void
{
$event = $event['event'];

Check warning on line 159 in app/Livewire/Calendars.php

View check run for this annotation

Codecov / codecov/patch

app/Livewire/Calendars.php#L159

Added line #L159 was not covered by tests

$e = Calendar::find($event['id']);
$e->started = Carbon::parse($event['start'])->format('d-m-Y H:i');

Expand Down Expand Up @@ -183,6 +186,7 @@ public function eventChange(array $event): void
*
* @return void
*/
#[On('event-destroy')]

Check warning on line 189 in app/Livewire/Calendars.php

View check run for this annotation

Codecov / codecov/patch

app/Livewire/Calendars.php#L189

Added line #L189 was not covered by tests
public function eventDestroy(array $event): void
{
$this->deleteInfo = $event;
Expand All @@ -202,7 +206,7 @@ public function destroy(): void

Calendar::destroy($this->deleteInfo['id']);
$this->showDeleteModal = false;
$this->emit('evenDestroySuccess', $this->deleteInfo['id']);
$this->dispatch('evenDestroySuccess', $this->deleteInfo['id']);

Check warning on line 209 in app/Livewire/Calendars.php

View check run for this annotation

Codecov / codecov/patch

app/Livewire/Calendars.php#L209

Added line #L209 was not covered by tests
$this->deleteInfo = [];
session()->flash('success', "Cet évènement a été supprimé avec succès !");
}
Expand All @@ -214,6 +218,7 @@ public function destroy(): void
*
* @return void
*/
#[On('event-add')]
public function eventAdd(array $event): void
{
$this->started_at = Carbon::parse($event['startStr'])->format('d-m-Y H:i');
Expand Down Expand Up @@ -251,7 +256,7 @@ public function save(): void
$array['started'] = $this->model->started->toIso8601String();
$array['ended'] = $this->model->ended->toIso8601String();
}
$this->emit('evenAddSuccess', $array);
$this->dispatch('evenAddSuccess', $array);

Check warning on line 259 in app/Livewire/Calendars.php

View check run for this annotation

Codecov / codecov/patch

app/Livewire/Calendars.php#L259

Added line #L259 was not covered by tests

$this->model = $this->makeBlankModel();
session()->flash('success', "Cet évènement a été créée avec succès !");
Expand Down
32 changes: 16 additions & 16 deletions app/Http/Livewire/Cleanings.php → app/Livewire/Cleanings.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Selvah\Http\Livewire;
namespace Selvah\Livewire;

use Carbon\Carbon;
use Illuminate\Contracts\Database\Query\Builder;
Expand All @@ -12,25 +12,25 @@
use Livewire\Component;
use Livewire\WithPagination;
use OpenSpout\Common\Entity\Cell;
use OpenSpout\Common\Entity\Style\Color;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Common\Entity\Style\Border;
use OpenSpout\Common\Entity\Style\BorderPart;
use OpenSpout\Common\Entity\Style\CellAlignment;
use OpenSpout\Common\Entity\Style\CellVerticalAlignment;
use OpenSpout\Common\Entity\Style\Color;
use OpenSpout\Common\Entity\Style\Style;
use OpenSpout\Common\Entity\Style\Border;
use OpenSpout\Common\Entity\Style\BorderPart;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Common\Exception\IOException;
use OpenSpout\Common\Exception\InvalidArgumentException;
use OpenSpout\Common\Exception\IOException;
use OpenSpout\Writer\Exception\InvalidSheetNameException;
use OpenSpout\Writer\Exception\WriterNotOpenedException;
use OpenSpout\Writer\XLSX\Writer;
use OpenSpout\Writer\XLSX\Options;
use Selvah\Http\Livewire\Traits\WithCachedRows;
use Selvah\Http\Livewire\Traits\WithFlash;
use Selvah\Http\Livewire\Traits\WithSorting;
use Selvah\Http\Livewire\Traits\WithBulkActions;
use Selvah\Http\Livewire\Traits\WithFilters;
use Selvah\Http\Livewire\Traits\WithPerPagePagination;
use OpenSpout\Writer\XLSX\Writer;
use Selvah\Livewire\Traits\WithBulkActions;
use Selvah\Livewire\Traits\WithCachedRows;
use Selvah\Livewire\Traits\WithFilters;
use Selvah\Livewire\Traits\WithFlash;
use Selvah\Livewire\Traits\WithPerPagePagination;
use Selvah\Livewire\Traits\WithSorting;
use Selvah\Models\Cleaning;
use Selvah\Models\Material;
use Selvah\Models\User;
Expand Down Expand Up @@ -67,11 +67,11 @@ class Cleanings extends Component
*
* @var string[]
*/
protected $queryString = [
protected array $queryString = [
'sortField' => ['as' => 'f'],
'sortDirection' => ['as' => 'd'],
'qrcode' => ['except' => ''],
'qrcodeid' => ['except' => ''],
'qrcode',
'qrcodeid',
'filters',
];

Expand Down
12 changes: 6 additions & 6 deletions app/Http/Livewire/Companies.php → app/Livewire/Companies.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

namespace Selvah\Http\Livewire;
namespace Selvah\Livewire;

use Illuminate\Contracts\Database\Query\Builder;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Pagination\LengthAwarePaginator;
use Livewire\Component;
use Livewire\WithPagination;
use Selvah\Http\Livewire\Traits\WithCachedRows;
use Selvah\Http\Livewire\Traits\WithFlash;
use Selvah\Http\Livewire\Traits\WithSorting;
use Selvah\Http\Livewire\Traits\WithBulkActions;
use Selvah\Http\Livewire\Traits\WithPerPagePagination;
use Selvah\Livewire\Traits\WithBulkActions;
use Selvah\Livewire\Traits\WithCachedRows;
use Selvah\Livewire\Traits\WithFlash;
use Selvah\Livewire\Traits\WithPerPagePagination;
use Selvah\Livewire\Traits\WithSorting;
use Selvah\Models\Company;

class Companies extends Component
Expand Down
26 changes: 13 additions & 13 deletions app/Http/Livewire/Incidents.php → app/Livewire/Incidents.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Selvah\Http\Livewire;
namespace Selvah\Livewire;

use Carbon\Carbon;
use Illuminate\Contracts\Container\BindingResolutionException;
Expand All @@ -16,24 +16,24 @@
use Livewire\WithPagination;
use LogicException;
use OpenSpout\Common\Entity\Cell;
use OpenSpout\Common\Entity\Style\Color;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Common\Entity\Style\Border;
use OpenSpout\Common\Entity\Style\BorderPart;
use OpenSpout\Common\Entity\Style\CellAlignment;
use OpenSpout\Common\Entity\Style\CellVerticalAlignment;
use OpenSpout\Common\Entity\Style\Color;
use OpenSpout\Common\Entity\Style\Style;
use OpenSpout\Common\Entity\Style\Border;
use OpenSpout\Common\Entity\Style\BorderPart;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Common\Exception\IOException;
use OpenSpout\Common\Exception\InvalidArgumentException;
use OpenSpout\Common\Exception\IOException;
use OpenSpout\Writer\Exception\WriterNotOpenedException;
use OpenSpout\Writer\XLSX\Writer;
use OpenSpout\Writer\XLSX\Options;
use Selvah\Http\Livewire\Traits\WithCachedRows;
use Selvah\Http\Livewire\Traits\WithFlash;
use Selvah\Http\Livewire\Traits\WithSorting;
use Selvah\Http\Livewire\Traits\WithBulkActions;
use Selvah\Http\Livewire\Traits\WithFilters;
use Selvah\Http\Livewire\Traits\WithPerPagePagination;
use OpenSpout\Writer\XLSX\Writer;
use Selvah\Livewire\Traits\WithBulkActions;
use Selvah\Livewire\Traits\WithCachedRows;
use Selvah\Livewire\Traits\WithFilters;
use Selvah\Livewire\Traits\WithFlash;
use Selvah\Livewire\Traits\WithPerPagePagination;
use Selvah\Livewire\Traits\WithSorting;
use Selvah\Models\Incident;
use Selvah\Models\Material;
use Selvah\Models\User;
Expand Down
12 changes: 6 additions & 6 deletions app/Http/Livewire/Lots.php → app/Livewire/Lots.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Selvah\Http\Livewire;
namespace Selvah\Livewire;

use Carbon\Carbon;
use Illuminate\Contracts\Database\Query\Builder;
Expand All @@ -9,11 +9,11 @@
use Illuminate\Pagination\LengthAwarePaginator;
use Livewire\Component;
use Livewire\WithPagination;
use Selvah\Http\Livewire\Traits\WithCachedRows;
use Selvah\Http\Livewire\Traits\WithFlash;
use Selvah\Http\Livewire\Traits\WithSorting;
use Selvah\Http\Livewire\Traits\WithBulkActions;
use Selvah\Http\Livewire\Traits\WithPerPagePagination;
use Selvah\Livewire\Traits\WithBulkActions;
use Selvah\Livewire\Traits\WithCachedRows;
use Selvah\Livewire\Traits\WithFlash;
use Selvah\Livewire\Traits\WithPerPagePagination;
use Selvah\Livewire\Traits\WithSorting;
use Selvah\Models\Lot;

class Lots extends Component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Selvah\Http\Livewire;
namespace Selvah\Livewire;

use Carbon\Carbon;
use Illuminate\Contracts\Container\BindingResolutionException;
Expand All @@ -16,27 +16,27 @@
use Livewire\WithPagination;
use LogicException;
use OpenSpout\Common\Entity\Cell;
use OpenSpout\Common\Entity\Style\Color;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Common\Entity\Style\Border;
use OpenSpout\Common\Entity\Style\BorderPart;
use OpenSpout\Common\Entity\Style\CellAlignment;
use OpenSpout\Common\Entity\Style\CellVerticalAlignment;
use OpenSpout\Common\Entity\Style\Color;
use OpenSpout\Common\Entity\Style\Style;
use OpenSpout\Common\Entity\Style\Border;
use OpenSpout\Common\Entity\Style\BorderPart;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Common\Exception\IOException;
use OpenSpout\Common\Exception\InvalidArgumentException;
use OpenSpout\Common\Exception\IOException;
use OpenSpout\Writer\Exception\WriterNotOpenedException;
use OpenSpout\Writer\XLSX\Writer;
use OpenSpout\Writer\XLSX\Options;
use Selvah\Http\Livewire\Traits\WithCachedRows;
use Selvah\Http\Livewire\Traits\WithFlash;
use Selvah\Http\Livewire\Traits\WithSorting;
use Selvah\Http\Livewire\Traits\WithBulkActions;
use Selvah\Http\Livewire\Traits\WithFilters;
use Selvah\Http\Livewire\Traits\WithPerPagePagination;
use OpenSpout\Writer\XLSX\Writer;
use Selvah\Livewire\Traits\WithBulkActions;
use Selvah\Livewire\Traits\WithCachedRows;
use Selvah\Livewire\Traits\WithFilters;
use Selvah\Livewire\Traits\WithFlash;
use Selvah\Livewire\Traits\WithPerPagePagination;
use Selvah\Livewire\Traits\WithSorting;
use Selvah\Models\Company;
use Selvah\Models\Material;
use Selvah\Models\Maintenance;
use Selvah\Models\Material;
use Selvah\Models\User;
use Symfony\Component\HttpFoundation\StreamedResponse;

Expand Down
43 changes: 22 additions & 21 deletions app/Http/Livewire/Materials.php → app/Livewire/Materials.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Selvah\Http\Livewire;
namespace Selvah\Livewire;

use Carbon\Carbon;
use Illuminate\Contracts\Container\BindingResolutionException;
Expand All @@ -17,26 +17,27 @@
use Livewire\WithPagination;
use LogicException;
use OpenSpout\Common\Entity\Cell;
use OpenSpout\Common\Entity\Style\Color;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Common\Entity\Style\Border;
use OpenSpout\Common\Entity\Style\BorderPart;
use OpenSpout\Common\Entity\Style\CellAlignment;
use OpenSpout\Common\Entity\Style\CellVerticalAlignment;
use OpenSpout\Common\Entity\Style\Color;
use OpenSpout\Common\Entity\Style\Style;
use OpenSpout\Common\Entity\Style\Border;
use OpenSpout\Common\Entity\Style\BorderPart;
use OpenSpout\Common\Entity\Row;
use OpenSpout\Common\Exception\IOException;
use OpenSpout\Common\Exception\InvalidArgumentException;
use OpenSpout\Common\Exception\IOException;
use OpenSpout\Writer\Exception\WriterNotOpenedException;
use OpenSpout\Writer\XLSX\Writer;
use OpenSpout\Writer\XLSX\Options;
use OpenSpout\Writer\XLSX\Writer;
use ReflectionException;
use Selvah\Http\Livewire\Traits\WithCachedRows;
use Selvah\Http\Livewire\Traits\WithFilters;
use Selvah\Http\Livewire\Traits\WithFlash;
use Selvah\Http\Livewire\Traits\WithSorting;
use Selvah\Http\Livewire\Traits\WithBulkActions;
use Selvah\Http\Livewire\Traits\WithPerPagePagination;
use Selvah\Http\Livewire\Traits\WithQrCode;
use Selvah\Http\Livewire\Incident;
use Selvah\Livewire\Traits\WithBulkActions;
use Selvah\Livewire\Traits\WithCachedRows;
use Selvah\Livewire\Traits\WithFilters;
use Selvah\Livewire\Traits\WithFlash;
use Selvah\Livewire\Traits\WithPerPagePagination;
use Selvah\Livewire\Traits\WithQrCode;
use Selvah\Livewire\Traits\WithSorting;
use Selvah\Models\Material;
use Selvah\Models\User;
use Selvah\Models\Zone;
Expand Down Expand Up @@ -80,13 +81,13 @@ class Materials extends Component
*
* @var string[]
*/
protected $queryString = [
protected array $queryString = [
'sortField' => ['as' => 'f'],
'sortDirection' => ['as' => 'd'],
'edit' => ['except' => ''],
'editid' => ['except' => ''],
'qrcode' => ['except' => ''],
'qrcodeid' => ['except' => ''],
'edit',
'editid',
'qrcode',
'qrcodeid',
'filters',
];

Expand Down Expand Up @@ -242,7 +243,7 @@ public function mount(): void
if ($this->edit === true && $this->editid !== null && Auth::user()->can('update material')) {
$model = Material::findOrFail($this->editid);

$this->edit($model);
$this->update($model);
}

// Check if the qrcode option are set into the url, and if yes, open the QR Code Modal if the user has the permissions.
Expand Down Expand Up @@ -365,7 +366,7 @@ public function create(): void
*
* @return void
*/
public function edit(Material $material): void
public function update(Material $material): void
{
$this->authorize('update', Material::class);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

namespace Selvah\Http\Livewire;
namespace Selvah\Livewire;

use Illuminate\Contracts\Database\Query\Builder;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Pagination\LengthAwarePaginator;
use Livewire\Component;
use Livewire\WithPagination;
use Selvah\Http\Livewire\Traits\WithCachedRows;
use Selvah\Http\Livewire\Traits\WithFlash;
use Selvah\Http\Livewire\Traits\WithSorting;
use Selvah\Http\Livewire\Traits\WithBulkActions;
use Selvah\Http\Livewire\Traits\WithPerPagePagination;
use Selvah\Livewire\Traits\WithBulkActions;
use Selvah\Livewire\Traits\WithCachedRows;
use Selvah\Livewire\Traits\WithFlash;
use Selvah\Livewire\Traits\WithPerPagePagination;
use Selvah\Livewire\Traits\WithSorting;
use Selvah\Models\Part;
use Selvah\Models\PartEntry;

Expand Down
Loading

0 comments on commit 0140769

Please sign in to comment.