I have no idea where to start now. I m just getting started with Laravel and trying to seed a database with random data, using Carbon & Faker. I got this error message :
[InvalidArgumentException]
Unexpected data found.
Unexpected data found.
Unexpected data found.
Data missing
I read several topics that speak of that on SO but nothing that can help me figure out what happening. Im actually following a tutorial so everything should be ok but since I may not be on the same version of Laravel I am not sure (minors changes here and there). Here is my code for the table I try to seed (utilisateursTableSeed.php) :
<?php
use Illuminate\Database\Seeder;
use Carbon\Carbon;
class utilisateursTableSeeder extends Seeder
{
private function datealeatoire(){
return Carbon::createFromDate('null', rand(1,12), rand(1,28));
}
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('utilisateurs')->delete();
$faker = Faker\Factory::create();
for ($i=0; $i<20; $i++){
$date=$this->datealeatoire();
DB:table('utilisateurs')->insert([
'titre'=> text(50),
'texte'=>text(),
'created_at'=>$date,
'updated_at'=>$date
]);
}
}
}
My function up() looks like this :
public function up()
{
Schema::create('utilisateurs', function (Blueprint $table) {
$table->increments('id');
$table->string('titre');
$table->text('texte');
$table->timestamps();
});
}
I tried to change the date format but its just getting me some other errors. I have no idea what to do... please tell me if you need more info. I would appreciate any help on this
Edit: also, when im changing the 'null' value in my createFromDFate to a plain date (i.e 2017 ) I get an error saying :
[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to undefined function table()'
but that should not throw an error right? I mean, am I not supposed to insert any kind of date here?