Search code examples
phparrayslaravellaravel-5.3

How to convert array to the result of `dd($variable)` (laravel)?


My array is like this :

$data = array(
            'number'            => '395364128', 
            'user'              => 'becks',
            'store'             => 'becks store', 
            'total_amount'      => 11000000, 
            'total_product'     => 2,
            'status'            => '92000000', 
            'delivery_address'  => 'spain',
            'email'             => '[email protected]'
        );

I want to convert the array to the result of dd($variable) on the laravel like this :

enter image description here

How can I do it?


Solution

  • You can try like this:

    $user = new User();
    $user->fill($data);
    dd($user);
    

    Illuminate/Database/Eloquent/Model.html#method_fill