-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
56 lines (47 loc) · 2.32 KB
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
use App\Http\Controllers\AuthController;
use App\Http\Controllers\CommentController;
use App\Http\Controllers\PostController;
use App\Http\Controllers\TagController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:sanctum')->group(function () {
Route::get('/me', [AuthController::class, 'me']);
Route::post('/logout', [AuthController::class, 'logout']);
Route::post('/tags/{tag}/follow', [UserController::class, 'follow_tag']);
Route::post('/tags/{tag}/unfollow', [UserController::class, 'unfollow_tag']);
Route::post('/users/{user}/follow', [UserController::class, 'follow']);
Route::post('/users/{user}/unfollow', [UserController::class, 'unfollow']);
Route::get('/users/{user}/list', [UserController::class, 'listFollowers']);
});
Route::resource('/posts', PostController::class)->only(['index', 'show']);
Route::resource('/users', UserController::class)->only(['index', 'show', 'store']);
Route::controller(UserController::class)->group(function () {
Route::get('/users/{user}/posts', 'listPosts');
Route::get('/users/{user}/comments', 'listComments');
});
Route::controller(CommentController::class)->group(function () {
Route::get('/posts/{post}/comments', 'listComments');
Route::post('/posts/{post}/comments', 'postComment');
Route::patch('/posts/{post}/comments/{comment}', 'updateComment');
Route::delete('/posts/{post}/comments/{comment}', 'deleteComment');
});
Route::controller(PostController::class)->group(function () {
Route::post('/users/{user}/posts', 'postUsers');
Route::get('/posts/{post}/tags', 'tagsPost');
Route::patch('/users/{user}/posts/{post}', 'updatePost');
Route::delete('/users/{user}/posts/{post}', 'deletePost');
});
Route::resource('/tags', TagController::class)->only(['show']);
Route::post('/register', [AuthController::class, 'register']);
Route::post('/login', [AuthController::class, 'login'])->name('login');