src/Http/Response/Format/Json.php
public function formatEloquentCollection($collection)
    {
        if ($collection->isEmpty()) {
            return $this->encode([]);
        }

        $model = $collection->first();
        $key = Str::plural($model->getTable());

        if (! $model::$snakeAttributes) {
            $key = Str::camel($key);
        }

        return $this->encode([$key => $collection->toArray()]);
    }
public function formatEloquentCollection($collection)
    {
        if ($collection->isEmpty()) {
            return $this->encode([]);
        }

        $model = $collection->first();
        $key = Str::plural($model->getTable());

        if (! $model::$snakeAttributes) {
            $key = Str::camel($key);
        }

        return $this->encode([$key => $collection->toArray()]);
    }
public function formatEloquentCollection ( $ collection ) { if ( $ collection -> isEmpty ( ) ) { return $ this -> encode ( [ ] ) ; } $ model = $ collection -> first ( ) ; $ key = Str :: plural ( $ model -> getTable ( ) ) ; if ( ! $ model :: $ snakeAttributes ) { $ key = Str :: camel ( $ key ) ; } return $ this -> encode ( [ $ key => $ collection -> toArray ( ) ] ) ; }
Format an Eloquent collection.

@param \Illuminate\Database\Eloquent\Collection $collection

@return string
Format an Eloquent collection .