Auth::user() null ketika di dd

halo gan saya mau nanya kenapa ya ketika Auth::user() di diedump hasil nya null ketika route nya saya simpan di web.php semua normal tapi ketika di simpan di api.php hasilnya malah null, apa ada teknik nya atau script tambahan agar tetap bisa menampilkan user credentials di api?terima kasih

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Auth;

class testController extends Controller
{
    public function show()
    {
        dd(Auth::user());
    }
}

ini api nya

<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| 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('api');
});

    Route::get('testphp', 'testController@show');

avatar VanJava31
@VanJava31

15 Kontribusi 0 Poin

Dipost 5 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban