mirror of
https://github.com/Cybrarist/Discount-Bandit.git
synced 2026-11-24 19:49:54 +01:00
add reset link functionality if name and image were fetched as error don't replace link name and image if crawled already fix route cache add fetch action to single link fix issue where price history doesn't show all the time by parsing date first fix product delete when category exists fix currency error if user selects a currency without an api key
50 lines
1.8 KiB
PHP
50 lines
1.8 KiB
PHP
<?php
|
|
|
|
use App\Http\Controllers\Actions\GetChartForCurrentLinkAndItsRelatedLinksForTheUserProducts;
|
|
use App\Http\Controllers\Actions\GetOtherRelatedLinksController;
|
|
use App\Http\Controllers\AddLinkFromBrowserPluginAction;
|
|
use App\Http\Controllers\GetLinkUsingUrlController;
|
|
use App\Http\Controllers\ProductController;
|
|
use App\Http\Controllers\StoreController;
|
|
use App\Models\User;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
// Route::get('/user', function (Request $request) {
|
|
// return $request->user();
|
|
// })->middleware('auth:sanctum');
|
|
//
|
|
Route::middleware('auth:sanctum')
|
|
->name('api.')
|
|
->group(function () {
|
|
Route::post('/links/add', AddLinkFromBrowserPluginAction::class);
|
|
|
|
Route::apiResource('stores', StoreController::class);
|
|
Route::apiResource('products', ProductController::class);
|
|
// Route::get('/products/search', [ProductController::class, 'search']);
|
|
Route::get('/link/search-url', GetLinkUsingUrlController::class);
|
|
Route::get('/link/{link}/related', GetOtherRelatedLinksController::class);
|
|
Route::get('/link/{link}/history', GetChartForCurrentLinkAndItsRelatedLinksForTheUserProducts::class);
|
|
|
|
});
|
|
|
|
Route::post('/sanctum/token', function (Request $request) {
|
|
$request->validate([
|
|
'email' => 'required|email',
|
|
'password' => 'required',
|
|
'device_name' => 'required',
|
|
]);
|
|
|
|
$user = User::firstWhere('email', $request->email);
|
|
|
|
if (! $user || ! Hash::check($request->password, $user->password)) {
|
|
throw ValidationException::withMessages([
|
|
'email' => ['The provided credentials are incorrect.'],
|
|
]);
|
|
|
|
}
|
|
|
|
return $user->createToken($request->device_name)->toJson();
|
|
});
|