Laravel
-
API Validation (API 유효성 검사 하는법) #validation #유효성 #APILaravel 2024. 2. 19. 12:13
public function checkDuplicate(Request $request) { $validator = Validator::make($request->all(), [ "email" => "required|string|max:500" ]); if($validator->fails()) return $this->respondInvalid($validator->errors()); $user = User::where("email", $request->email)->first(); if($user) return $this->respondForbidden("이미 사용중인 이메일입니다."); return $this->respondSuccessfully("사용 가능한 이메일입니다."); }
-
laravel media library로 다른 사이트 이미지 활용법 (A사이트에서 B사이트 이미지 사용하기)Laravel 2023. 7. 16. 17:13
@ filesystems.php (public 디스크 사용한다 가정) 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), 'url' => env('APP_IMG_URL').'/storage', 'visibility' => 'public', ], @ .env (APP_IMG_URL에 B사이트 URL 적기) APP_IMG_URL=https://naver.com
-
초성검색 (ㄱ,ㄴ,ㄷ,ㅁ,ㅂ...)Laravel 2023. 4. 4. 15:13
# What? 컬럼에 ㄱ, ㄴ같은 초성 포함여부 검색하기 # How? if($char == "ㄱ") $items = Community::whereBetween("title", ["가", "깋"]); if($char == "ㄴ") $items = Community::whereBetween("title", ["나", "닣"]); if($char == "ㄷ") $items = Community::whereBetween("title", ["다", "딯"]); if($char == "ㄹ") $items = Community::whereBetween("title", ["라", "맇"]); if($char == "ㅁ") $items = Community::whereBetween("title", ["마", "밓"]);..