I am learning Laravel 8 and I know a lot about it. It doesn't show me any errors. Every time I submit the form it just refreshes the site and it doesn't redirect me anywhere. The data isn't saved to the table. I also used hasMany and belongs to in the user and product model. My controller looks like this
public function store(Request $request)
{
$this->validate($request, [
'name' => 'required',
'brand' => 'nullable',
'price' => 'required',
'quantity' => 'required',
'description' => 'required',
'category' => 'required',
'condition' => 'required'
]);
$request->user()->products()->create([
'name' => $request->name,
'brand' => $request->brand,
'price' => $request->price,
'quantity' => $request->quantity,
'description' => $request->description,
'category' => $request->category,
'condition' => $request->condition,
]);
return redirect()->route('products.index');
}
My Product model looks like this:
protected $fillable = [
'name',
'brand',
'description',
'price',
'category',
'quantity',
'condition',
];
public $primaryKey = 'id';
public $timestamps = true;
protected $table = 'products';
public function user() {
return $this->belongsTo(Business::class);
}