Laravel
-
한 컨트롤러에서 여러 모델에 대한 pagination 사용하고 싶을 때(페이지네이션)Laravel 2021. 11. 16. 14:22
# What? 한 컨트롤러에서 Post, Category 모델에 대해 페이지네이션 다중처리하기 # Why? page=2로 파라미터 넘어오면 Post, Category 둘 다의 2페이지 값들이 넘어감 # How? paginate(30, [*], "custom_page_name")과 같이 이름 변경 가능 $categories = Category::orderBy("order", "asc")->paginate(30, ["*"], "categories_page"); $workers = $workers->where("worker", true)->orderBy($orderBy, $align)->paginate(1);
-
Shared DataLaravel/Inertia.js 2021. 9. 21. 21:39
# What? - 전역변수처럼 프론트단 어떤 페이지에서나 가져다 쓸 수 있게 공유되는 데이터 # Why? - User나 Flash 메시지같은거 공유 필요 # How? @HandleInertiaRequests public function share(Request $request) { return array_merge(parent::share($request), [ "user" => auth()->user(), "flash" => function() use ($request){ return [ "success" => $request->session()->get("success"), "error" => $request->session()->get("error"), ]; }, // 기타 공유하고픈 데이터 ]);..
-
레이아웃 설정법Laravel/Inertia.js 2021. 9. 21. 18:35
# What? 기본틀 잡는법 # Why? 헤더, 푸터같은건 공통으로 가져가야 편함(매번 작성 x) # How? @ Pages/Layout.vue header // 공통부분 // 이 자리에 페이지 내용이 들어감 footer // 공통부분 @app.js(내가 만든 Layout.vue를 default Layout으로 사용하게 하기) import Layout from "./Pages/Layout"; createInertiaApp({ resolve: name => { // 해당 페이지에서 layout를 따로 설정안했다면 기본으로 내가 만든 Layout 컴포넌트 사용 const page = require(`./Pages/${name}`).default; page.layout = page.layout || Layou..
-
초기세팅Laravel/Inertia.js 2021. 9. 7. 17:07
# What? laravel mpa 구조 그대로 spa 구현 가능하게 도와주는 라이브러리 (후원자는 ssr까지 제공) # How? 1. Back-end 세팅 composer require inertiajs/inertia-laravel - welcome.blade.php => app.blade.php로 변경 @ app.blade.php @inertia php artisan inertia:middleware @ Kernel.php 'web' => [ // ... \App\Http\Middleware\HandleInertiaRequests::class, ], @ UserController.php
-
패키지 실제로 배포해보기Laravel/Package 2021. 9. 3. 22:32
- 본인 github에 올리기 @ gitignore build vendor composer.lock - packgist에 등록하기 1. https://packagist.org/ =7.4"" data-og-host="packagist.org" data-og-source-url="https://packagist.org/" data-og-url="https://packagist.org/" data-og-image=""> Packagist Define Your Package Put a file named composer.json at the root of your package's repository, containing this information: { "name": "your-vendor-name/pack..
-
만든 패키지 사용해보기(로컬, 퍼블리싱 전)Laravel/Package 2021. 9. 2. 00:11
- 테스트할 라라벨 프로젝트 생성 laravel new chunknorris - 로컬에 있는 패키지 경로 직접 명시해주기 @composer.json { ... "repositories": [ { "type" : "path", "url" : "../chunk-norris-jokes" } ] } - 패키지 설치하기 composer require june/chunk-norris-jokes composer dump-autoload - 패키지 사용해보기 @ web.php