Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
allanmcarvalho committed Oct 13, 2023
2 parents 58102cd + eb44a6e commit 4c82ef2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Casts/FilePond.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(
*
* @param array<string, mixed> $attributes
*/
public function get(Model $model, string $key, mixed $value, array $attributes): null|Images
public function get(Model $model, string $key, mixed $value, array $attributes): ?Images
{
if (is_string($value)) {
$value = json_decode($value, true);
Expand Down
3 changes: 2 additions & 1 deletion src/Casts/FilePond/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

readonly class Image implements Arrayable
{

public string $disk;

public string $path;

public string $url;

public function __construct(array $data)
Expand Down
2 changes: 2 additions & 0 deletions src/Casts/FilePond/Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function get(string $name): Image
if (! isset($this->data[$name])) {
throw new \InvalidArgumentException("\"$name\" image does not exist.");
}

return new Image($this->data[$name]);
}

Expand All @@ -41,6 +42,7 @@ public function toArray(): array
foreach ($this->data as $key => $item) {
$images[$key] = (new Image($item))->toArray();
}

return $images;
}
}
4 changes: 3 additions & 1 deletion src/FilePond/FilePondUploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Laravuewind\FilePond;

use const UPLOAD_ERR_OK;

use Illuminate\Http\UploadedFile;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use const UPLOAD_ERR_OK;

class FilePondUploadedFile extends UploadedFile
{
Expand Down Expand Up @@ -94,6 +95,7 @@ public static function fromPath(string $path): FilePondUploadedFile
$serverId = $factory->createServerId($folderId, filesize($path));
$newPath = $factory->getBasePath()."/$folderId/".basename($path);
$factory->disk()->put($newPath, file_get_contents($path));

return new static(
$factory,
$serverId,
Expand Down

0 comments on commit 4c82ef2

Please sign in to comment.