2017 © Pedro Peláez
 

library snake2camel

A Laravel Framework Package for getting and setting model fields in snakeCase through camelCase

image

jgraffite/snake2camel

A Laravel Framework Package for getting and setting model fields in snakeCase through camelCase

  • Wednesday, April 11, 2018
  • by jgraffite
  • Repository
  • 1 Watchers
  • 1 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel Snake2camel

Latest Version on Packagist ![Software License][ico-license], (*1)

Package to Laravel Framework able getting and setting model fields in snakeCase through camelCase, (*2)

--, (*3)

Pacote para o Framework Laravel que permite setar e obter os campos de um modelo snakeCase em camelCase, (*4)

Installation

Via Composer, (*5)

To install this package, you only have to run this command:, (*6)

``` bash $ composer require jgraffite/snake2camel, (*7)


* If you are using Laravel 5.4 or lower ``` bash $ composer require jgraffite/snake2camel:1.0-dev

Then, you need to add the provider that package, on the Laravel config/app.php file, like this:, (*8)

``` php /* * Package Service Providers... */ [...] Jgraffite\Snake2camel\Snake2camelServiceProvider::class,, (*9)


## Usage If you use the Laravel Command Line to create a model, you will get something like this: ``` php <?php namespace App; use Illuminate\Auth\Authenticatable; use Illuminate\Database\Eloquent\Model; class SomeModel extends Model { ... }

Simply, remove the line "use Illuminate\Database\Eloquent\Model;" and replace "extends Model" to "extends \Model", like this:, (*10)

``` php <?php namespace App;, (*11)

use Illuminate\Auth\Authenticatable;, (*12)

class SomeModel extends \Model { ... }, (*13)


Now, you are ready to use the package functions, for example: To set a model field, where its really name in table database is "some_column": ``` php <?php $modelObject = new SomeModel; $modelObject->someColumn = "any value"; $modelObject->save(); ---- $item = SomeModel::find(1, ['someColumn']); #Get a model and retrieve only one specific column echo $item->someColumn . PHP_EOL; echo $item->some_column; #This will print the same of the above code

You can also use a special function to make "where conditions" with FULL TEXT. See how do it:, (*14)

php <?php $item = Somemodel::whereFullTextMatch(['column1','column2'], 'query words')->get();, (*15)

Security

If you discover any security issues, please e-mail jorge@macrobol.com instead of using the issue tracker., (*16)

License

The MIT License (MIT). Please see License File for more information., (*17)

The Versions

11/04 2018

dev-master

9999999-dev https://github.com/jgraffite/snake2camel

A Laravel Framework Package for getting and setting model fields in snakeCase through camelCase

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jorge Luis Malaquias

laravel models jgraffite snake2case database fields

05/01 2018

1.1.0

1.1.0.0 https://github.com/jgraffite/snake2camel

A Laravel Framework Package for getting and setting model fields in snakeCase through camelCase

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jorge Luis Malaquias

laravel models jgraffite snake2case database fields