Skip to content

Commit

Permalink
Merge branch '3.x' of github.com:BinarCode/laravel-restify into 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryk committed Jul 17, 2020
2 parents 9423e4e + 5746794 commit dddd1d3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
7 changes: 3 additions & 4 deletions src/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Binaryk\LaravelRestify\Http\Requests\ProfileAvatarRequest;
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
use Binaryk\LaravelRestify\Repositories\Repository;
use Binaryk\LaravelRestify\Repositories\UserProfile;
use Binaryk\LaravelRestify\Services\Search\RepositorySearchService;

class ProfileController extends RepositoryController
Expand All @@ -29,7 +28,7 @@ public function __invoke(RestifyRequest $request)
$meta = [];

if (method_exists($user, 'profile')) {
$meta = (array)call_user_func([$user, 'profile'], $request);
$meta = (array) call_user_func([$user, 'profile'], $request);
}

return $this->response()
Expand All @@ -41,12 +40,12 @@ public function guessRepository(RestifyRequest $request): ?Repository
{
$repository = $request->repository('users');

if (!$repository) {
if (! $repository) {
return null;
}

if (method_exists($repository, 'canUseForProfile')) {
if (!call_user_func([$repository, 'canUseForProfile'], $request)) {
if (! call_user_func([$repository, 'canUseForProfile'], $request)) {
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/ProfileUpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function guessRepository(RestifyRequest $request): ?Repository
}

if (method_exists($repository, 'canUseForProfileUpdate')) {
if (!call_user_func([$repository, 'canUseForProfileUpdate'], $request)) {
if (! call_user_func([$repository, 'canUseForProfileUpdate'], $request)) {
return null;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Repositories/UserProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public static function metaProfile(Request $request): array
public function resolveShowMeta($request)
{
return [
'authorizedToShow' => $this->authorizedToShow($request),
'authorizedToStore' => $this->authorizedToStore($request),
'authorizedToUpdate' => $this->authorizedToUpdate($request),
'authorizedToDelete' => $this->authorizedToDelete($request),
] + static::metaProfile($request);
'authorizedToShow' => $this->authorizedToShow($request),
'authorizedToStore' => $this->authorizedToStore($request),
'authorizedToUpdate' => $this->authorizedToUpdate($request),
'authorizedToDelete' => $this->authorizedToDelete($request),
] + static::metaProfile($request);
}
}
20 changes: 9 additions & 11 deletions tests/Controllers/ProfileControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public function test_profile_returns_authenticated_user_with_related_posts()
'data' => [
'posts' => [
[
'title'
]
]
]
'title',
],
],
],
]);
}

Expand Down Expand Up @@ -140,7 +140,7 @@ public function test_get_profile_can_use_repository()
->assertStatus(200)
->assertJsonStructure([
'attributes',
'meta'
'meta',
]);

$response->assertJsonFragment([
Expand All @@ -159,10 +159,10 @@ public function test_profile_returns_authenticated_user_with_related_posts_via_r
'relationships' => [
'posts' => [
[
'attributes'
]
]
]
'attributes',
],
],
],
]);

$response->assertJsonFragment([
Expand Down Expand Up @@ -203,6 +203,4 @@ public function test_profile_update_via_repository()
'name' => 'Eduard',
]);
}


}

0 comments on commit dddd1d3

Please sign in to comment.