You use firstOrCreate. If you posted a form where $request->produit_designation exists in the database it will be never inserted because it just return your product from database.
Byt the way use only English for everything when you write a code.
@michaloravec sorry if I was not clear enought, the problem is not that the record is not inserted in the database, all the records are inserted but without the date when :
dd($request->product_designation . ' ' . date ('d-m-Y'));
xxxxx 29-09-2020
but when inserting the record in the database, it only inserts xxxxx!
message: "SQLSTATE[HY000]: General error: 1364 Field 'produit_designation' doesn't have a default value (SQL: insert into `Produit` (`updated_at`, `created_at`) values (2020-09-29 08:32:06, 2020-09-29 08:32:06))"
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Produit extends Model
{
protected $fillable = [
'produit_id', 'produit_designation',
];
}
And do you have timestamps in migration for product?
If not, you have to say to model that you don't use it
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Produit extends Model
{
/**
* Indicates if the model should be timestamped.
*
* @var boolean
*/
public $timestamps = false;
protected $fillable = [
'produit_id', 'produit_designation',
];
}
The only issue is that the $request->production_designation . ' ' . date('d-m-Y') is running like $request->production_designation the date is not being inserted!