Skip to content

Instantly share code, notes, and snippets.

@chuprik
Last active August 29, 2015 14:06
Show Gist options
  • Save chuprik/9f035bb33bf4d33ec9bf to your computer and use it in GitHub Desktop.
Save chuprik/9f035bb33bf4d33ec9bf to your computer and use it in GitHub Desktop.
camelCase in where magic of the Laravel.
<?php
abstract class Base extends \Eloquent
{
/**
* Get a new query builder instance for the connection.
*
* @return Builder
*/
protected function newBaseQueryBuilder()
{
$connection = $this->getConnection();
$grammar = $conn->getQueryGrammar();
return new Builder($connection, $grammar, $conn->getPostProcessor());
}
}
<?php
class Builder extends \Illuminate\Database\Query\Builder
{
/**
* Add a single dynamic where clause statement to the query.
*
* @param string $segment
* @param string $connector
* @param array $parameters
* @param int $index
*
* @return void
*/
protected function addDynamic($segment, $connector, $parameters, $index)
{
$bool = strtolower($connector);
$this->where(camel_case($segment), '=', $parameters[$index], $bool);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment