Answers for "toarray in laravel 8"

PHP
4

laravel collection toArray

$collection = collect(['name' => 'Desk', 'price' => 200]);

$collection->toArray();

/*
    [
        ['name' => 'Desk', 'price' => 200],
    ]
*/
Posted by: Guest on July-24-2021
1

laravel array to js

var app = @json($array);
Posted by: Guest on May-25-2020
0

laravel array cast

use Illuminate\Database\Eloquent\Casts\AsCollection;

/**
 * The attributes that should be cast.
 *
 * @var array
 */
protected $casts = [
    'options' => AsCollection::class,
];
Posted by: Guest on December-31-2021

Browse Popular Code Answers by Language