samedi 5 août 2017

Laravel seeder retrieve date column with proper format

I've managed to set up a seeder for seeding data that needs to be in the database at launch. Everything was working well until I needed to seed a DATE field with value retrieved from Users table,

The factory is

$user = App\User::all();
return [
          'signup_date' => $User->random()->pluck('signup_date'),
];

I tried passing only one column of retrieved data to new variable to avoid data type mismatch

    $user = App\User::all();
    $user_signup = $user->pluck('signup_date');
    return [
              'signup_date' => $user_signup->random(),
    ];

Or inline date format php methods with no luck, Any Idea about formatting date? or doesn't retrieved column return proper date format?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2vAoGqj
via IFTTT

Aucun commentaire:

Enregistrer un commentaire