Quando eu salvo a serie ele salva assim no front inclusive {"id":2,"nome":"Opa","created_at":null,"updated_at":null} em vez só o nome
meu codigo:<?php
namespace App\Http\Controllers;
use App\Models\Serie; use Illuminate\Http\Request;
class SeriesController extends Controller { public function index() { $series = Serie::query()->orderBy('nome')->get();
return view('series.index')->with('series', $series);
}
public function create()
{
return view('series.create');
}
public function store(Request $request)
{
$nomeSerie = $request->input('nome');
$serie = new Serie();
$serie->nome = $nomeSerie;
$serie->save();
return redirect('/series');
}
} Series.php: <?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model;
class Serie extends Model { use HasFactory; protected $fillable = ['nome']; public $timestamps = false; } 2024_07_01_223423_create_series_table.php:<?php
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema;
return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('series', function (Blueprint $table) { $table->id(); $table->string('nome', 128); $table->timestamps(); }); }
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('series');
}
};