增加 applications 功能
This commit is contained in:
parent
401a13d3dc
commit
58f7a4a7ad
@ -8,23 +8,16 @@
|
|||||||
|
|
||||||
class ModuleController extends Controller
|
class ModuleController extends Controller
|
||||||
{
|
{
|
||||||
//
|
public function index()
|
||||||
|
{
|
||||||
|
$modules = (new Module)->all()->makeVisible('api_token');
|
||||||
|
|
||||||
// public function index() {
|
return $this->success($modules);
|
||||||
// $modules = Module::all();
|
}
|
||||||
//
|
|
||||||
// return $this->success($modules);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
public function show(Module $module): JsonResponse
|
public function show(Module $module): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
return $this->success($module);
|
return $this->success($module);
|
||||||
|
|
||||||
// $module = Module::find(request()->route('module'));
|
|
||||||
//
|
|
||||||
// return $this->success($module);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
app/Http/Controllers/Application/UserController.php
Normal file
33
app/Http/Controllers/Application/UserController.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Application;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\PersonalAccessToken;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
|
class UserController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$users = (new User)->paginate(10);
|
||||||
|
|
||||||
|
return $this->success($users);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(User $user): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->success($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function auth($token): JsonResponse
|
||||||
|
{
|
||||||
|
$token = PersonalAccessToken::findToken($token);
|
||||||
|
|
||||||
|
return $token ? $this->success($token->tokenable) : $this->notFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
use App\Http\Controllers\Application\ModuleController;
|
use App\Http\Controllers\Application\ModuleController;
|
||||||
use App\Http\Controllers\Application\MqttAuthController;
|
use App\Http\Controllers\Application\MqttAuthController;
|
||||||
|
use App\Http\Controllers\Application\UserController;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
|
||||||
// MQTT Auth
|
// MQTT Auth
|
||||||
@ -15,3 +17,8 @@
|
|||||||
// Modules
|
// Modules
|
||||||
Route::get('modules', [ModuleController::class, 'index'])->name('modules.index');
|
Route::get('modules', [ModuleController::class, 'index'])->name('modules.index');
|
||||||
Route::get('modules/{module}', [ModuleController::class, 'show'])->name('modules.show');
|
Route::get('modules/{module}', [ModuleController::class, 'show'])->name('modules.show');
|
||||||
|
|
||||||
|
|
||||||
|
Route::resource('users', UserController::class)->only(['index', 'show']);
|
||||||
|
Route::get('token/{token}', [UserController::class, 'auth']);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user