-
Modules/Category/Repository/v1/CategoryRepository.php
Open in GitHubuse Module\Category\Repository\CategoryRepository as Repository; class CategoryRepository extends Repository { public function getCategories($request): array { return $this->model() ->whereIn('slug', $request) ->get() ->pluck('id') ->toArray(); } }
-
Modules/Category/Http/Controllers/api/v1/CategoryController.php
Open in GitHubuse App\Http\Controllers\Controller; use Module\Category\Http\Resources\v1\CategoryCollection; use Module\Category\Models\Category; use Module\Category\Repository\v1\CategoryRepository; use Module\Share\Contracts\Response\ResponseGenerator; class CategoryController extends Controller implements ResponseGenerator { public function repo() { return resolve(CategoryRepository::class); } // public function index() { $categories = $this->repo()->take(Category::query()); return new CategoryCollection($categories); } // }