Hello everyone,
I've a stupid issue and I'm crazing.
I've a Model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Campionato extends Model
{
use HasFactory;
protected $table = 'campionati';
}
Controller:
<?php
namespace App\Http\Controllers;
use App\Models\Campionato;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
class CampionatoController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$campionati = Campionato::all();
return view('campionati.index', compact('campionati'));
}
/**
* Display the specified resource.
*/
public function show(Campionato $campionato)
{
return dd($campionato);
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Campionato $campionato) :View
{
return dd($campionato);
}
}
Route:
Route::get('/', function () {
return view('welcome');
});
Route::get('/dashboard', function () {
return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');
Route::middleware('auth')->group(function () {
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
Route::resource('campionati', CampionatoController::class);
});
require __DIR__.'/auth.php';
The index works fine, but when I open the "edit" or the "show" I see:
App\Models\Campionato {#1304 ▼ // app/Http/Controllers/CampionatoController.php:50
#connection: null
#table: "campionati"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
+preventsLazyLoading: false
#perPage: 15
+exists: false
+wasRecentlyCreated: false
#escapeWhenCastingToString: false
#attributes: []
#original: []
#changes: []
#casts: []
#classCastCache: []
#attributeCastCache: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
+timestamps: true
+usesUniqueIds: false
#hidden: []
#visible: []
#fillable: []
#guarded: array:1 [▶]
}
So I've not data. The data is null.
I created a new project for testing. I started from scratch, thinking I was making a stupid mistake, I followed an elementary CRUD tutorial, but nothing.
Where am I doing wrong?