@if(Auth::user()->id == $user_id)
<form method="POST" action="">
<button class="btn btn-danger">Delete</button>
@csrf
@method('DELETE')
</form>
@endif
выдает ошибку: Undefined variable: user_id (View: C:\OpenServer\OSPanel\domains\project\resources\views\edit.blade.php)
в контроллере прописал
public function showUserAd($user)
{
$user = User::where('username', $user)->first();
if(empty($user)){
abort(404);
}
return redirect()->route('adShow', [$oneAd]);
}
роут
Route::get('/{id}', 'AdController@showUserAd');
миграция таблицы users
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('username')->unique();
$table->string('password');
$table->timestamps();
});