Thursday, February 7, 2019

Camel case model relationship is returned as snake case property

Put following code in to your model class

/**
* Indicates whether attributes are snake cased on arrays.
*
* @var bool
*/
public static $snakeAttributes = false;


Sample code as follows,

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
use Carbon\Carbon;

class BaseModel extends Model {

/**     
* Indicates whether attributes are snake cased on arrays.     
*     
* @var bool     
*/    
public static $snakeAttributes = false;

}