继承重写的代码
<?php
/**
* User: aogg
* Date: 2019/10/11
*/
namespace App\Facades\Vendor;
/** @noinspection PhpHierarchyChecksInspection */
/**
* Class Storage
* @package App\Facades\Vendor
* @mixin \Illuminate\Filesystem\FilesystemAdapter
*/
class Storage extends \Illuminate\Support\Facades\Storage
{
}
<?php
/**
* User: aozhuochao
* Date: 2019/8/31
*/
namespace App\Library\Vendor\Laravel;
/**
* Class DB
* @package App\Library\Vendor\Laravel
* @method static void beginTransaction() 开始事务
* @method static void commit() 提交事务
* @method static \Illuminate\Database\Query\Expression raw($value)
* @mixin \Illuminate\Database\DatabaseManager
* @mixin \Illuminate\Database\Connection
*/
class DB extends \Illuminate\Support\Facades\DB
{
}
<?php
/**
* User: aozhuochao
* Date: 2019/9/17
*/
namespace App\Library\Vendor\Laravel;
use Illuminate\Database\Query\Builder;
/**
* 不给别名添加前缀,其实是DB::raw('FROM_UNIXTIME(o.pay_time, "%Y%m%d")')的时候添加前缀就可以了
*/
class MySqlGrammar extends \Illuminate\Database\Query\Grammars\MySqlGrammar
{
/**
* Compile the "from" portion of the query.
*
* @param Builder $query
* @param string $table
* @return string
*/
protected function compileFrom(Builder $query, $table)
{
return 'from '.$this->wrapTable($table, false);
}
/**
* Compile the "join" portions of the query.
*
* @param Builder $query
* @param array $joins
* @return string
*/
protected function compileJoins(Builder $query, $joins)
{
return collect($joins)->map(function ($join) {
$table = $this->wrapTable($join->table, false);
return trim("{$join->type} join {$table} {$this->compileWheres($join)}");
})->implode(' ');
}
protected function compileGroups(Builder $query, $groups)
{
return parent::compileGroups($query, $groups);
}
/**
* Wrap a table in keyword identifiers.
*
* @param \Illuminate\Database\Query\Expression|string $table
* @param bool $bool 是否自动给别名添加前缀
* @return string
*/
public function wrapTable($table, $bool = true)
{
if (! $this->isExpression($table)) {
return $this->wrap($this->tablePrefix.$table, $bool);
}
return $this->getValue($table);
}
/**
* Wrap the given value segments.
*
* @param array $segments
* @return string
*/
protected function wrapSegments($segments)
{
return collect($segments)->map(function ($segment, $key) use ($segments) {
return $this->wrapValue($segment); // 不需要给表别名添加前缀,对于字段
})->implode('.');
}
}