- menyesuaikan testing - menghapus route untuk delete karena tidak lewat route - menyesuaikan tipe prop dan lainnya
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
use App\Enums\Day;
|
|
use Illuminate\Http\UploadedFile;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Support\Str;
|
|
|
|
function makeLivewireFile(string $name)
|
|
{
|
|
$file = UploadedFile::fake()->image($name, 100, 100);
|
|
$tmpId = Str::random(32);
|
|
$filename = $tmpId.'-'.base64_encode($file->getClientOriginalName()).'.'.$file->getClientOriginalExtension();
|
|
$path = "livewire-tmp/{$filename}";
|
|
|
|
Storage::disk('local')->putFileAs('livewire-tmp', $file, $filename);
|
|
|
|
return [
|
|
'tmpFilename' => $filename,
|
|
'name' => $file->getClientOriginalName(),
|
|
'extension' => $file->getClientOriginalExtension(),
|
|
'path' => storage_path("app/private/{$path}"),
|
|
'temporaryUrl' => url("livewire/preview-file/{$filename}"),
|
|
'size' => $file->getSize(),
|
|
];
|
|
}
|
|
|
|
function makeValidOpeningHours()
|
|
{
|
|
return collect(Day::cases())
|
|
->mapWithKeys(fn ($day) => [
|
|
$day->value => [
|
|
'open_time' => '09:00',
|
|
'close_time' => '21:00',
|
|
],
|
|
])
|
|
->toArray();
|
|
}
|