Coder Social home page Coder Social logo

laravel-camelcase-json's People

Contributors

grohiro avatar mix5003 avatar nunar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

laravel-camelcase-json's Issues

Deprecated function camel_case in Laravel 5.7+

Since global string and array helpers are deprecated (Laravel news) this package isn't working anymore with newest versions of Laravel.

Proposed solution

use Illuminate\Support\Str;

public function encodeArray($array)
{
	$newArray = [];
	foreach ($array as $key => $val) {
		// Deprecated
		// $newArray[\camel_case($key)] = $this->encodeJson($val);

		// Use this directly
		$newArray[Str::camel($key)] = $this->encodeJson($val);
	}
	return $newArray;
}

Another workaround since pull request is still open:

app/Http/Helpers.php

use Illuminate\Support\Str;

if (!function_exists('camel_case')) {
    function camel_case($input)
    {
        return Str::camel($input);
    }
}

Unable to convert json from DB facade result

Hi there,

Really love this package. However I am facing an issue where there is a condition that force me to use Laravel's DB facade instead of Eloquent Model. Please refer to following code:

$users = DB::table('users')->select('name AS some_cool_name')->get()
return response()->json($users);

The result shows "some_cool_name" instead of "someCoolName"
I am using Laravel 5.4

Allowed memory size exhausted

This is the error i get sometimes

[Sun Apr 28 15:41:49 2019] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in C:\Projects\Hospital\Prototype\laravel-hospital-man-sys\vendor\grohiro\laravel-camelcase-json\src\CamelCaseJsonResponseFactory.php on line 33
[Sun Apr 28 15:41:49 2019] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

The package doesnt work!

How I can use your package? After install the JSON the same as Laravel original.
What I need to do to activate your package?
P.S. I use Laravel 5.7

response()->json($model)
returns the original json

{
"created_at": "..."
"updated_at": "..."
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.