diff --git a/src/DTO/FilterField.php b/src/DTO/FilterField.php index 30d778f..6ee3c78 100644 --- a/src/DTO/FilterField.php +++ b/src/DTO/FilterField.php @@ -2,9 +2,13 @@ namespace Aldeebhasan\NaiveCrud\DTO; +use Aldeebhasan\NaiveCrud\Traits\Makable; + /**@method static FilterField make(string $field, ?string $column = null, ?string $operator = '=', callable $callback = null, mixed $value = null) */ final readonly class FilterField { + use Makable; + public ?string $column; public mixed $callback; diff --git a/src/Http/Controllers/UploadController.php b/src/Http/Controllers/UploadController.php index 483cf7e..3bd6387 100644 --- a/src/Http/Controllers/UploadController.php +++ b/src/Http/Controllers/UploadController.php @@ -5,7 +5,6 @@ use Aldeebhasan\NaiveCrud\Logic\Managers\FileManager; use Aldeebhasan\NaiveCrud\Traits\Crud\ResponseTrait; use Illuminate\Contracts\Support\Responsable; -use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Symfony\Component\HttpFoundation\Response; diff --git a/src/Logic/Managers/FileManager.php b/src/Logic/Managers/FileManager.php index 69e3a2c..d92321d 100644 --- a/src/Logic/Managers/FileManager.php +++ b/src/Logic/Managers/FileManager.php @@ -24,9 +24,10 @@ class FileManager protected array $thumbnailDim = []; protected string $file; + protected array $meta = [ 'mime' => 'image/jpeg', - 'size' => "1024", + 'size' => '1024', 'extension' => 'jpeg', ]; @@ -40,7 +41,7 @@ public function setFile(UploadedFile|string $file): self ]; $this->file = file_get_contents($file); } else { - if (str($file)->startsWith("http")) { + if (str($file)->startsWith('http')) { $this->file = file_get_contents($file); } else { $file = $this->getStoragePath($file); @@ -88,7 +89,7 @@ public function uploadImage(string $name = ''): array } $encoded = $image->encodeByExtension($this->meta['extension'], quality: 75)->toString(); - $name = $name ?: (time() . uniqid()); + $name = $name ?: (time().uniqid()); $response = $this->upload($encoded, $name); $this->generateThumbnail($name); @@ -98,7 +99,7 @@ public function uploadImage(string $name = ''): array protected function generateThumbnail(string $name): void { - if (!$this->thumbnail) { + if (! $this->thumbnail) { return; } @@ -118,8 +119,8 @@ public function uploadFile(string $name = ''): array private function upload(string $file, string $name): array { - $name = $name ?: (time() . uniqid()); - $name = "$name." . $this->meta['extension']; + $name = $name ?: (time().uniqid()); + $name = "$name.".$this->meta['extension']; $path = "$this->path/$name"; Storage::put($this->getStoragePath($path), $file, 'public'); $path = $this->getAssetPath($path); diff --git a/src/Traits/Crud/IndexTrait.php b/src/Traits/Crud/IndexTrait.php index 742773a..0f58270 100644 --- a/src/Traits/Crud/IndexTrait.php +++ b/src/Traits/Crud/IndexTrait.php @@ -16,7 +16,9 @@ trait IndexTrait { protected bool $paginated = true; + protected bool $preserveQueryParams = true; + protected array $paginationMeta = ['current_page', 'from', 'last_page', 'path', 'per_page', 'to', 'total']; protected function indexQuery(Builder $query): Builder