jgraffite/snake2camel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jgraffite/snake2camel

最新稳定版本:2.1.0

Composer 安装命令:

composer require jgraffite/snake2camel

包简介

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

README 文档

README

Latest Version on Packagist Software License

Package to Laravel Framework able getting and setting model fields in snakeCase through camelCase

--

Pacote para o Framework Laravel que permite setar e obter os campos de um modelo snakeCase em camelCase

Installation

Via Composer

To install this package, you only have to run this command:

$ composer require jgraffite/snake2camel
  • If you are using Laravel 5.4 or lower
$ 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:

/*
 * Package Service Providers...
 */
 [...]
 Jgraffite\Snake2camel\Snake2camelServiceProvider::class,

Usage

If you use the Laravel Command Line to create a model, you will get something like this:

<?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:

<?php
namespace App;

use Illuminate\Auth\Authenticatable;

class SomeModel extends \Model
{
...
}

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

$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:

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

Security

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

License

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

统计信息

  • 总下载量: 37
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-05