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
12 changes: 6 additions & 6 deletions src/Fields/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ public function fillAttribute(RestifyRequest $request, $model)
$this->resolveValueBeforeUpdate($request, $model);

if ($this->isHidden($request)) {
if (!isset($this->appendCallback)) {
if (! isset($this->appendCallback)) {
return;
}
}

if (!$this->isHidden($request) && isset($this->fillCallback)) {
if (! $this->isHidden($request) && isset($this->fillCallback)) {
return call_user_func(
$this->fillCallback, $request, $model, $this->attribute
);
Expand Down Expand Up @@ -253,7 +253,7 @@ protected function fillAttributeFromRequest(RestifyRequest $request, $model, $at
*/
protected function fillAttributeFromAppend(RestifyRequest $request, $model, $attribute)
{
if (!isset($this->appendCallback)) {
if (! isset($this->appendCallback)) {
return;
}

Expand Down Expand Up @@ -356,7 +356,7 @@ public function resolveForShow($repository, $attribute = null)
return;
}

if (!$this->showCallback) {
if (! $this->showCallback) {
$this->resolve($repository, $attribute);
} elseif (is_callable($this->showCallback)) {
tap($this->value ?? $this->resolveAttribute($repository, $attribute), function ($value) use ($repository, $attribute) {
Expand All @@ -379,7 +379,7 @@ public function resolveForIndex($repository, $attribute = null)
return;
}

if (!$this->indexCallback) {
if (! $this->indexCallback) {
$this->resolve($repository, $attribute);
} elseif (is_callable($this->indexCallback)) {
tap($this->value ?? $this->resolveAttribute($repository, $attribute), function ($value) use ($repository, $attribute) {
Expand All @@ -399,7 +399,7 @@ public function resolve($repository, $attribute = null)
return;
}

if (!$this->resolveCallback) {
if (! $this->resolveCallback) {
$this->value = $this->resolveAttribute($repository, $attribute);
} elseif (is_callable($this->resolveCallback)) {
tap($this->resolveAttribute($repository, $attribute), function ($value) use ($repository, $attribute) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Controllers/RepositoryShowControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public function test_repository_hidden_fields_could_not_be_updated()

public function test_repository_hidden_fields_could_be_updated_through_append()
{
$post = factory(Post::class)->create(['user_id' => 2, 'title' => 'Eduard', 'category' => 'Hidden category before update.',]);
$post = factory(Post::class)->create(['user_id' => 2, 'title' => 'Eduard', 'category' => 'Hidden category before update.']);

$this->putJson('/restify-api/post-with-hidden-fields/1', [
'title' => 'Updated title',
'category' => 'Trying to update hidden category.'
'category' => 'Trying to update hidden category.',
]);

$this->assertEquals('Append category for a hidden field.', $post->fresh()->category);
Expand Down
3 changes: 1 addition & 2 deletions tests/Unit/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Binaryk\LaravelRestify\Tests\Unit;

use Binaryk\LaravelRestify\Fields\Field;
use Binaryk\LaravelRestify\Http\Requests\RepositoryIndexRequest;
use Binaryk\LaravelRestify\Http\Requests\RepositoryStoreRequest;
use Binaryk\LaravelRestify\Http\Requests\RepositoryUpdateRequest;
use Binaryk\LaravelRestify\Tests\Fixtures\Post\PostRepository;
Expand Down Expand Up @@ -292,7 +291,7 @@ public function test_field_can_be_filled_from_the_append_callback()
};

/** * @var Field $field */
$field = Field::new('title')->append(fn() => 'Append title');
$field = Field::new('title')->append(fn () => 'Append title');

$field->fillAttribute($request, $model);

Expand Down