-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/inikoo/aiku into main
- Loading branch information
Showing
10 changed files
with
104 additions
and
61 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
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 |
---|---|---|
@@ -1,54 +1,54 @@ | ||
<?php | ||
/* | ||
* author Arya Permana - Kirin | ||
* created on 24-02-2025-13h-07m | ||
* github: https://github.com/KirinZero0 | ||
* copyright 2025 | ||
*/ | ||
|
||
namespace App\Actions\Inventory\Location; | ||
|
||
use App\Actions\OrgAction; | ||
use App\Models\Inventory\Warehouse; | ||
use App\Models\Inventory\WarehouseArea; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Support\Facades\Redirect; | ||
use Lorisleiva\Actions\ActionRequest; | ||
use Lorisleiva\Actions\Concerns\AsController; | ||
use Lorisleiva\Actions\Concerns\WithAttributes; | ||
use App\Models\Inventory\Location; | ||
use App\Models\SysAdmin\Organisation; | ||
use App\Models\Inventory\Warehouse; | ||
use App\Events\FileDownloadProgress; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Maatwebsite\Excel\Concerns\Exportable; | ||
use Maatwebsite\Excel\Concerns\FromCollection; | ||
use Maatwebsite\Excel\Concerns\FromQuery; | ||
use Maatwebsite\Excel\Concerns\WithHeadings; | ||
use Maatwebsite\Excel\Concerns\WithMapping; | ||
|
||
class LocationsExport implements FromQuery, WithMapping, WithHeadings | ||
class LocationsExport implements FromQuery, WithMapping, WithHeadings, ShouldQueue | ||
{ | ||
use Exportable; | ||
|
||
private Warehouse $warehouse; | ||
private array $columns; | ||
|
||
public int $processed = 0; | ||
public int $totalCount = 0; | ||
|
||
public function __construct(Warehouse $warehouse, array $columns) | ||
{ | ||
$this->warehouse = $warehouse; | ||
$this->columns = $columns; | ||
} | ||
|
||
|
||
public function map($row): array | ||
{ | ||
return collect($this->columns)->map(fn($column) => $row->{$column})->toArray(); | ||
{ | ||
$this->processed++; | ||
|
||
$progress = $this->totalCount > 0 | ||
? ($this->processed / $this->totalCount) * 100 | ||
: 100; | ||
|
||
broadcast(new FileDownloadProgress($this->warehouse->id, (int) $progress)); | ||
|
||
return collect($this->columns)->map(fn ($col) => $row->{$col} ?? '')->toArray(); | ||
} | ||
|
||
public function headings(): array | ||
{ | ||
return array_map(fn($col) => str_replace('_', ' ', ucfirst($col)), $this->columns); | ||
return array_map(fn ($col) => str_replace('_', ' ', ucfirst($col)), $this->columns); | ||
} | ||
|
||
public function query() | ||
{ | ||
return Location::query()->where('warehouse_id', $this->warehouse->id); | ||
$query = Location::query()->where('warehouse_id', $this->warehouse->id); | ||
$this->totalCount = $query->count(); | ||
|
||
return $query; | ||
} | ||
} | ||
} |
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,45 @@ | ||
<?php | ||
|
||
namespace App\Events; | ||
|
||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class FileDownloadProgress | ||
{ | ||
use Dispatchable; | ||
use InteractsWithSockets; | ||
use SerializesModels; | ||
public int $userId; | ||
public int $progress; | ||
public string|null $fileName; | ||
/** | ||
* Create a new event instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct($userId, $progress, $fileName = null) | ||
{ | ||
$this->userId = $userId; | ||
$this->progress = $progress; | ||
$this->fileName = $fileName; | ||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return \Illuminate\Broadcasting\Channel|array | ||
*/ | ||
public function broadcastOn(): Channel|PrivateChannel|array | ||
{ | ||
return new PrivateChannel('grp.download-progress.' . $this->userId); | ||
} | ||
|
||
public function broadcastAs(): string | ||
{ | ||
return 'FileDownloadProgress'; | ||
} | ||
} |
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
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