-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from dbarzin/dev
Add /api/users
- Loading branch information
Showing
6 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\API; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\User; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Response; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class UserController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$users = User::all(); | ||
|
||
return response()->json($users); | ||
} | ||
|
||
public function store(Request $request) | ||
{ | ||
abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$user = Document::create($user->all()); | ||
|
||
return response()->json($user, 201); | ||
} | ||
|
||
public function show(User $user) | ||
{ | ||
abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
return response()->json($user); | ||
} | ||
|
||
public function update(Request $request, User $user) | ||
{ | ||
abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$user->update($request->all()); | ||
|
||
return response()->json(); | ||
} | ||
|
||
public function destroy(User $user) | ||
{ | ||
abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$user->delete(); | ||
|
||
return response()->json(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters