I just installed a fresh copy of the starter kit for Metronic Laravel (v8.3.2)
Attempt to read property "profile_photo_url" on null
detailed error message is there
Any help?
Hi Eladl Eltanahy
The issue is that the routes are not protected by authentication middleware, allowing unauthenticated users to access views that expect a logged-in user. Here are the steps to fix this:
The main issue is in routes/web.php file. The authentication middleware is currently commented out. Uncomment and properly configure it:
// In routes/web.php, change this:
// Route::middleware(["auth", "verified"])->group(function () {
// Route::get("/", [DashboardController::class, "index"]);
// Route::get("/dashboard", [DashboardController::class, "index"])->name("dashboard");
// // ... other routes
// });
// To this:
Route::middleware(["auth", "verified"])->group(function () {
Route::get("/", [DashboardController::class, "index"]);
Route::get("/dashboard", [DashboardController::class, "index"])->name("dashboard");
Route::name("user-management.")->group(function () {
Route::resource("/user-management/users", UserManagementController::class);
Route::resource("/user-management/roles", RoleManagementController::class);
Route::resource("/user-management/permissions", PermissionManagementController::class);
});
});@if(Auth::check() && Auth::user()->profile_photo_url)
<img src="{{ \Auth::user()->profile_photo_url }}" class="rounded-3" alt="user" />
@else
<div class="symbol-label fs-3 {{ app(\App\Actions\GetThemeType::class)->handle("bg-light-? text-?", Auth::user()->name ?? "U") }}">
{{ substr(Auth::user()->name ?? "User", 0, 1) }}
</div>
@endifC:\Laravel\starterkit\resources\views\layout\partials\sidebar-layout\header\_navbar.blade
.php : 43
@if(Auth::user()->profile_photo_url)
<img src="{{ \Auth::user()->profile_photo_url }}" class="rounded-3" alt="user" />
@else
<div class="symbol-label fs-3 {{ app(\App\Actions\GetThemeType::class)->handle('bg-light-? text-?', Auth::user()->name) }}">
{{ substr(Auth::user()->name, 0, 1) }}
</div>
@endif