RouteServiceProvider
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CustomerApi;
|
||||
namespace App\Http\Controllers\APIS\CustomerApi;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CustomerApi;
|
||||
namespace App\Http\Controllers\APIS\CustomerApi;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -8,4 +8,4 @@ use Illuminate\Http\Request;
|
||||
class DeviceController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CustomerApi;
|
||||
namespace App\Http\Controllers\APIS\CustomerApi;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use App\Models\UserAssetLink;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -10,8 +11,9 @@ class UserAssetLinkController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$userAssetLinks = User::id('a5daeb60-f36c-11ef-a9dc-45dd276e4cd5');
|
||||
$userAssetLinks = UserAssetLink::with(['user', 'asset.devices'])->get();
|
||||
|
||||
return response()->json($userAssetLinks);
|
||||
}
|
||||
}
|
||||
}
|
||||
61
app/Providers/RouteServiceProvider.php
Normal file
61
app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register services.
|
||||
*/
|
||||
/**
|
||||
* The path to your application's "home" route.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*/
|
||||
// public function register(): void
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
//Created by : Chandan Yadav; Created at : 28 Jan 2025; Use : API;
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
|
||||
Route::middleware('api')
|
||||
->prefix('apia')
|
||||
->group(base_path('routes/admin_api.php'));
|
||||
|
||||
Route::middleware('api')
|
||||
->prefix('apic')
|
||||
->group(base_path('routes/customer_api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,5 @@
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
];
|
||||
|
||||
9
routes/admin_api.php
Normal file
9
routes/admin_api.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
||||
Route::get('/adminapi', function () {
|
||||
return ('Welcome to admin api routes.');
|
||||
});
|
||||
14
routes/customer_api.php
Normal file
14
routes/customer_api.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\APIS\CustomerApi\UserAssetLinkController;
|
||||
|
||||
|
||||
Route::get('/customerapi', function () {
|
||||
return ('Welcome to admin api routes.');
|
||||
});
|
||||
|
||||
|
||||
|
||||
Route::get('/user-assets', [UserAssetLinkController::class, 'index']);
|
||||
Reference in New Issue
Block a user