teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

api使用用途の追加

2018/02/02 02:58

投稿

SystemRyota
SystemRyota

スコア24

title CHANGED
File without changes
body CHANGED
@@ -32,4 +32,8 @@
32
32
  Route::post('***/***/***', '***@save');
33
33
  Route::post('***/***/***', '***@update');
34
34
  });
35
- ```
35
+ ```
36
+
37
+
38
+ ###### 追加
39
+ ログインフォームにてログインした後、apiを使用します。

1

ルーティングのソースを記載しました。

2018/02/02 02:57

投稿

SystemRyota
SystemRyota

スコア24

title CHANGED
File without changes
body CHANGED
@@ -4,4 +4,32 @@
4
4
  `Auth::user()`でも同様です。
5
5
 
6
6
  apiのコントローラにてユーザ情報を取得し、Modelに渡したいのですが、
7
- どうすれば良いのでしょうか。
7
+ どうすれば良いのでしょうか。
8
+
9
+ routes/api.php
10
+ ```
11
+ <?php
12
+
13
+ use Illuminate\Http\Request;
14
+ use Illuminate\Support\Facades\Auth;
15
+
16
+ /*
17
+ |--------------------------------------------------------------------------
18
+ | API Routes
19
+ |--------------------------------------------------------------------------
20
+ |
21
+ | Here is where you can register API routes for your application. These
22
+ | routes are loaded by the RouteServiceProvider within a group which
23
+ | is assigned the "api" middleware group. Enjoy building your API!
24
+ |
25
+ */
26
+
27
+ Route::group(['namespace' => 'API'], function() {
28
+ Route::get('***/***', '***@***');
29
+ Route::get('***/***', '***@***');
30
+
31
+ Route::post('***/***/***', '***@create');
32
+ Route::post('***/***/***', '***@save');
33
+ Route::post('***/***/***', '***@update');
34
+ });
35
+ ```