0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

現在のルート名やipを取得する

Posted at

業務中にipアドレスやルートの名前によって処理を分ける必要があり、調べたのでメモ。

route()

  • 現在のルートに関する情報を返す

getName()

  • 現在のルートの名前を取得する

ip()

  • クライアントのIPアドレスを取得する

使用例

Route::get('/example', [ExampleController::class, 'show'])->name('example.route');

// メソッド内で$requestを使えるようにする
public function showDetail(Request $request){
    $request->route()->getName()
    $request->ip()
}


0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?