<?php

use App\Http\Controllers\api\v1\OrderController;
use Illuminate\Http\Request;
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:api')->get('/user', function (Request $request) {
    return $request->user();
});

Route::get('/setup', function () {
    $credentials = ['name' => 'developer',
        'password' => '123456'];
    if (Auth::attempt($credentials)) {
        $user = Auth::user();
        $apiToken = $user->createToken('api-token', ['api:read', 'api:update']);
        dd($apiToken->plainTextToken);
    }
})->name('beallitas');

Route::get('/v1/status', [OrderController::class, 'status'])->name('status');

Route::prefix('/v1')->middleware('auth:sanctum')->group(function () {
    // Route::get('/',[OrderController::class,'unProcessed'])->name('x');
    app('debugbar')->disable();
    Route::prefix('/order')->name('order.')->group(function () {
        Route::get('unprocessed', [OrderController::class, 'unProcessed'])->name('unProcessed');
        Route::match(['put', 'patch'], 'setProcessed', [OrderController::class, 'setProcessed'])->name('setProcessed');
    });
});
