Skip to content

Commit d73f5da

Browse files
committed
wip
1 parent e5de284 commit d73f5da

File tree

3 files changed

+18
-39
lines changed

3 files changed

+18
-39
lines changed

src/Commands/stubs/base-repository.stub

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,43 @@ namespace DummyNamespace;
44

55
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
66
use Binaryk\LaravelRestify\Repositories\Repository as RestifyRepository;
7-
use Illuminate\Contracts\Pagination\Paginator;
87

98
abstract class Repository extends RestifyRepository
109
{
10+
1111
/**
12-
* Build an "index" query for the given repository.
12+
* Build a "show" and "index" query for the given repository.
1313
*
1414
* @param RestifyRequest $request
1515
* @param \Illuminate\Database\Eloquent\Builder $query
1616
* @return \Illuminate\Database\Eloquent\Builder
1717
*/
18-
public static function indexQuery(RestifyRequest $request, $query)
18+
public static function mainQuery(RestifyRequest $request, $query)
1919
{
2020
return $query;
2121
}
2222

2323
/**
24-
* Build an "detail" query for the given repository.
24+
* Build an "index" query for the given repository.
2525
*
2626
* @param RestifyRequest $request
2727
* @param \Illuminate\Database\Eloquent\Builder $query
2828
* @return \Illuminate\Database\Eloquent\Builder
2929
*/
30-
public static function detailQuery(RestifyRequest $request, $query)
30+
public static function indexQuery(RestifyRequest $request, $query)
3131
{
3232
return $query;
3333
}
3434

35-
public function index(RestifyRequest $request)
36-
{
37-
return parent::index($request);
38-
}
39-
40-
public function show(RestifyRequest $request, $repositoryId)
41-
{
42-
return parent::show($request, $repositoryId);
43-
}
44-
45-
46-
public function store(RestifyRequest $request)
47-
{
48-
return parent::store($request);
49-
}
50-
51-
public function update(RestifyRequest $request, $repositoryId)
52-
{
53-
return parent::update($request, $repositoryId);
54-
}
55-
56-
public function destroy(RestifyRequest $request, $repositoryId)
35+
/**
36+
* Build a "show" query for the given repository.
37+
*
38+
* @param RestifyRequest $request
39+
* @param \Illuminate\Database\Eloquent\Builder $query
40+
* @return \Illuminate\Database\Eloquent\Builder
41+
*/
42+
public static function detailQuery(RestifyRequest $request, $query)
5743
{
58-
return parent::destroy($request, $repositoryId);
44+
return $query;
5945
}
60-
6146
}

src/Commands/stubs/repository.stub

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,8 @@ use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
77

88
class DummyClass extends Repository
99
{
10-
/**
11-
* The model the repository corresponds to.
12-
*
13-
* @var string
14-
*/
1510
public static $model = '{{ model }}';
1611

17-
/**
18-
* @param RestifyRequest $request
19-
* @return array
20-
*/
2112
public function fields(RestifyRequest $request)
2213
{
2314
return [

src/Http/Controllers/RepositoryShowController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ public function __invoke(RepositoryShowRequest $request)
1313
$repository = $request->repository();
1414

1515
return $request->newRepositoryWith(tap(
16-
tap($request->findModelQuery(), fn ($query) => $repository::mainQuery($request, $query->with($repository::getWiths()))),
16+
tap($request->findModelQuery(), fn ($query) => $repository::detailQuery(
17+
$request,
18+
$repository::mainQuery($request, $query->with($repository::getWiths()))
19+
)),
1720
fn ($query) => $repository::showQuery($request, $query))->firstOrFail())
1821
->allowToShow($request)
1922
->show($request, request('repositoryId'));

0 commit comments

Comments
 (0)