Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Fields/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ public function storeAs($storeAs): self
protected function prepareStorageCallback(callable $storageCallback = null): void
{
$this->storageCallback = $storageCallback ?? function ($request, $model) {
return $this->mergeExtraStorageColumns($request, [
$this->attribute => $this->storeFile($request, $this->attribute),
]);
};
return $this->mergeExtraStorageColumns($request, [
$this->attribute => $this->storeFile($request, $this->attribute),
]);
};
}

/**
Expand Down Expand Up @@ -116,7 +116,7 @@ public function storeSize($column)

protected function storeFile(Request $request, string $requestAttribute)
{
if (!$this->storeAs) {
if (! $this->storeAs) {
return $request->file($requestAttribute)->store($this->getStorageDir(), $this->getStorageDisk());
}

Expand Down Expand Up @@ -186,7 +186,7 @@ protected function columnsThatShouldBeDeleted(): array

public function fillAttribute(RestifyRequest $request, $model, int $bulkRow = null)
{
if (is_null($file = $request->file($this->attribute)) || !$file->isValid()) {
if (is_null($file = $request->file($this->attribute)) || ! $file->isValid()) {
return $this;
}

Expand Down Expand Up @@ -220,7 +220,7 @@ public function fillAttribute(RestifyRequest $request, $model, int $bulkRow = nu
return $result;
}

if (!is_array($result)) {
if (! is_array($result)) {
return $model->{$attribute} = $result;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Fields/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function test_model_updating_will_replace_file()
UserRepository::partialMock()
->shouldReceive('fields')
->andReturn([
Image::make('avatar')->disk('customDisk')->storeAs('newAvatar.jpg')->prunable()
Image::make('avatar')->disk('customDisk')->storeAs('newAvatar.jpg')->prunable(),
]);

$this->post(UserRepository::uriKey()."/{$user->id}", [
Expand Down