最近发表的话题
最近发表的评论
  • Laravel query when 的查询 at 1天前

    如果 $input 是 Illuminate\Http\Request 对象,可以尝试

    $query->when($input->exists('status'), function ($select, $status) {
        $select->where('status', $status);
    });
  • 关于 Laravel Conf China 2019 大会因故取消的说明 at 6天前

    第一眼见到大会取消的帖子, 我是很震惊的.

    • 深感遗憾;
    • 建议找大厂赞助.
  • 使用 Laravel IDE helper + Laravel plugin 提升开发效率 at 1周前

    VSCode 呢 :sob:

  • Laravel Conf China 2019 之 Albert Chen at 2周前

    错别字

    • 目前任职于 M17 ()下的举手电商
  • Coding Girls 第三年啦!诚邀新伙伴! at 2周前
    打扰了
  • Coding Girls 第三年啦!诚邀新伙伴! at 2周前

    汉子可以进么 不是女装大佬的那种 :flushed:

  • Laravel Conf China 2019 之 安正超 at 1个月前

    超牛b

  • 百度的这个接口一定是 PHP 写的 at 1个月前

    :joy: PHP写接口一时爽,一直写一直爽

  • 🎂 Laravel 深入浅出指南 —— 国庆献礼 at 2个月前

    @Hexor 先于请求执行还是后于请求执行不是在 pipeline 中控制的, 跟middleware的命名也无关.
    因为其是这行代码上下文所决定的

    $next($request);

    例如

    // 请求被处理前的逻辑
    $response = $next($request);
    // 请求被处理后的逻辑

    如果你想在业务中拿到请求时, 对请求进行利用, 那么就

    public function handle()
    {
        doSomethingHere($request);
        return $next($request);
    }

    如果你想对响应加工, 那么在这里处理

    public function handle()
    {
        $response = $next($request);
        doSomethingHere($response, $request);
        return $response;
    }

    二者区别在于 $next($request)doSomethingHere($response, $request) 的先后. 与 Pipeline 无一丝关系.

    我想你应该明白了吧?

  • 🎂 Laravel 深入浅出指南 —— 国庆献礼 at 2个月前

    @Hexor

    file

    再确认一下你说的是官网的这个文档吗?

  • 专为 Laravel 定制的 Visual Studio Code 编辑器 at 2个月前

    @gogoing 自己从ide_helper.php提取的

  • 专为 Laravel 定制的 Visual Studio Code 编辑器 at 2个月前

    @gogoing 你可以把你项目的基础模型加上这个

    <?php
    
    namespace App\Models;
    
    use Illuminate\Database\Eloquent\Model;
    
    /**
     * 基础模型
     *
     * @method static \Illuminate\Database\Eloquent\Model make($attributes = array())
     * @method static \Illuminate\Database\Eloquent\Builder withGlobalScope($identifier, $scope)
     * @method static \Illuminate\Database\Eloquent\Builder withoutGlobalScope($scope)
     * @method static \Illuminate\Database\Eloquent\Builder withoutGlobalScopes($scopes = null)
     * @method static array removedScopes()
     * @method static \Illuminate\Database\Eloquent\Builder whereKey($id)
     * @method static \Illuminate\Database\Eloquent\Builder whereKeyNot($id)
     * @method static \Illuminate\Database\Eloquent\Builder where($column, $operator = null, $value = null, $boolean = 'and')
     * @method static \Illuminate\Database\Eloquent\Builder|static orWhere($column, $operator = null, $value = null)
     * @method static \Illuminate\Database\Eloquent\Builder latest($column = null)
     * @method static \Illuminate\Database\Eloquent\Builder oldest($column = null)
     * @method static \Illuminate\Database\Eloquent\Collection hydrate($items)
     * @method static \Illuminate\Database\Eloquent\Collection fromQuery($query, $bindings = array())
     * @method static \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|static[]|static|null find($id, $columns = array())
     * @method static \Illuminate\Database\Eloquent\Collection findMany($ids, $columns = array())
     * @method static \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|static|static[] findOrFail($id, $columns = array())
     * @method static \Illuminate\Database\Eloquent\Model|static findOrNew($id, $columns = array())
     * @method static \Illuminate\Database\Eloquent\Model|static firstOrNew($attributes, $values = array())
     * @method static \Illuminate\Database\Eloquent\Model|static firstOrCreate($attributes, $values = array())
     * @method static \Illuminate\Database\Eloquent\Model|static updateOrCreate($attributes, $values = array())
     * @method static \Illuminate\Database\Eloquent\Model|static firstOrFail($columns = array())
     * @method static \Illuminate\Database\Eloquent\Model|static|mixed firstOr($columns = array(), $callback = null)
     * @method static mixed value($column)
     * @method static \Illuminate\Database\Eloquent\Collection|static[] get($columns = array())
     * @method static \Illuminate\Database\Eloquent\Model[]|static[] getModels($columns = array())
     * @method static array eagerLoadRelations($models)
     * @method static \Generator cursor()
     * @method static bool chunkById($count, $callback, $column = null, $alias = null)
     * @method static \Illuminate\Support\Collection pluck($column, $key = null)
     * @method static \Illuminate\Contracts\Pagination\LengthAwarePaginator paginate($perPage = null, $columns = array(), $pageName = 'page', $page = null)
     * @method static \Illuminate\Contracts\Pagination\Paginator simplePaginate($perPage = null, $columns = array(), $pageName = 'page', $page = null)
     * @method static \Illuminate\Database\Eloquent\Model|$this create($attributes = array())
     * @method static \Illuminate\Database\Eloquent\Model|$this forceCreate($attributes)
     * @method static void onDelete($callback)
     * @method static static|mixed scopes($scopes)
     * @method static static applyScopes()
     * @method static \Illuminate\Database\Eloquent\Builder without($relations)
     * @method static \Illuminate\Database\Eloquent\Model|static newModelInstance($attributes = array())
     * @method static \Illuminate\Database\Query\Builder getQuery()
     * @method static \Illuminate\Database\Eloquent\Builder setQuery($query)
     * @method static \Illuminate\Database\Query\Builder toBase()
     * @method static array getEagerLoads()
     * @method static \Illuminate\Database\Eloquent\Builder setEagerLoads($eagerLoad)
     * @method static \Illuminate\Database\Eloquent\Model|static getModel()
     * @method static \Illuminate\Database\Eloquent\Builder setModel($model)
     * @method static \Closure getMacro($name)
     * @method static bool chunk($count, $callback)
     * @method static bool each($callback, $count = 1000)
     * @method static \Illuminate\Database\Eloquent\Model|object|static|null first($columns = array())
     * @method static mixed|$this when($value, $callback, $default = null)
     * @method static \Illuminate\Database\Query\Builder tap($callback)
     * @method static mixed|$this unless($value, $callback, $default = null)
     * @method static \Illuminate\Database\Eloquent\Builder|static has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null)
     * @method static \Illuminate\Database\Eloquent\Builder|static orHas($relation, $operator = '>=', $count = 1)
     * @method static \Illuminate\Database\Eloquent\Builder|static doesntHave($relation, $boolean = 'and', $callback = null)
     * @method static \Illuminate\Database\Eloquent\Builder|static orDoesntHave($relation)
     * @method static \Illuminate\Database\Eloquent\Builder|static whereHas($relation, $callback = null, $operator = '>=', $count = 1)
     * @method static \Illuminate\Database\Eloquent\Builder|static orWhereHas($relation, $callback = null, $operator = '>=', $count = 1)
     * @method static \Illuminate\Database\Eloquent\Builder|static whereDoesntHave($relation, $callback = null)
     * @method static \Illuminate\Database\Eloquent\Builder|static orWhereDoesntHave($relation, $callback = null)
     * @method static \Illuminate\Database\Eloquent\Builder withCount($relations)
     * @method static \Illuminate\Database\Eloquent\Builder|static mergeConstraintsFrom($from)
     * @method static \Illuminate\Database\Query\Builder select($columns = array())
     * @method static \Illuminate\Database\Query\Builder|static selectSub($query, $as)
     * @method static \Illuminate\Database\Query\Builder|static selectRaw($expression, $bindings = array())
     * @method static \Illuminate\Database\Query\Builder|static fromSub($query, $as)
     * @method static \Illuminate\Database\Query\Builder|static fromRaw($expression, $bindings = array())
     * @method static \Illuminate\Database\Query\Builder addSelect($column)
     * @method static \Illuminate\Database\Query\Builder distinct()
     * @method static \Illuminate\Database\Query\Builder from($table)
     * @method static \Illuminate\Database\Query\Builder join($table, $first, $operator = null, $second = null, $type = 'inner', $where = false)
     * @method static \Illuminate\Database\Query\Builder|static joinWhere($table, $first, $operator, $second, $type = 'inner')
     * @method static \Illuminate\Database\Query\Builder|static joinSub($query, $as, $first, $operator = null, $second = null, $type = 'inner', $where = false)
     * @method static \Illuminate\Database\Query\Builder|static leftJoin($table, $first, $operator = null, $second = null)
     * @method static \Illuminate\Database\Query\Builder|static leftJoinWhere($table, $first, $operator, $second)
     * @method static \Illuminate\Database\Query\Builder|static leftJoinSub($query, $as, $first, $operator = null, $second = null)
     * @method static \Illuminate\Database\Query\Builder|static rightJoin($table, $first, $operator = null, $second = null)
     * @method static \Illuminate\Database\Query\Builder|static rightJoinWhere($table, $first, $operator, $second)
     * @method static \Illuminate\Database\Query\Builder|static rightJoinSub($query, $as, $first, $operator = null, $second = null)
     * @method static \Illuminate\Database\Query\Builder|static crossJoin($table, $first = null, $operator = null, $second = null)
     * @method static void mergeWheres($wheres, $bindings)
     * @method static array prepareValueAndOperator($value, $operator, $useDefault = false)
     * @method static \Illuminate\Database\Query\Builder|static whereColumn($first, $operator = null, $second = null, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orWhereColumn($first, $operator = null, $second = null)
     * @method static \Illuminate\Database\Query\Builder whereRaw($sql, $bindings = array(), $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orWhereRaw($sql, $bindings = array())
     * @method static \Illuminate\Database\Query\Builder whereIn($column, $values, $boolean = 'and', $not = false)
     * @method static \Illuminate\Database\Query\Builder|static orWhereIn($column, $values)
     * @method static \Illuminate\Database\Query\Builder|static whereNotIn($column, $values, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orWhereNotIn($column, $values)
     * @method static \Illuminate\Database\Query\Builder whereIntegerInRaw($column, $values, $boolean = 'and', $not = false)
     * @method static \Illuminate\Database\Query\Builder whereIntegerNotInRaw($column, $values, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder whereNull($column, $boolean = 'and', $not = false)
     * @method static \Illuminate\Database\Query\Builder|static orWhereNull($column)
     * @method static \Illuminate\Database\Query\Builder|static whereNotNull($column, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder whereBetween($column, $values, $boolean = 'and', $not = false)
     * @method static \Illuminate\Database\Query\Builder|static orWhereBetween($column, $values)
     * @method static \Illuminate\Database\Query\Builder|static whereNotBetween($column, $values, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orWhereNotBetween($column, $values)
     * @method static \Illuminate\Database\Query\Builder|static orWhereNotNull($column)
     * @method static \Illuminate\Database\Query\Builder|static whereDate($column, $operator, $value = null, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orWhereDate($column, $operator, $value = null)
     * @method static \Illuminate\Database\Query\Builder|static whereTime($column, $operator, $value = null, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orWhereTime($column, $operator, $value = null)
     * @method static \Illuminate\Database\Query\Builder|static whereDay($column, $operator, $value = null, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orWhereDay($column, $operator, $value = null)
     * @method static \Illuminate\Database\Query\Builder|static whereMonth($column, $operator, $value = null, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orWhereMonth($column, $operator, $value = null)
     * @method static \Illuminate\Database\Query\Builder|static whereYear($column, $operator, $value = null, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orWhereYear($column, $operator, $value = null)
     * @method static \Illuminate\Database\Query\Builder|static whereNested($callback, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder forNestedWhere()
     * @method static \Illuminate\Database\Query\Builder addNestedWhereQuery($query, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder whereExists($callback, $boolean = 'and', $not = false)
     * @method static \Illuminate\Database\Query\Builder|static orWhereExists($callback, $not = false)
     * @method static \Illuminate\Database\Query\Builder|static whereNotExists($callback, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orWhereNotExists($callback)
     * @method static \Illuminate\Database\Query\Builder addWhereExistsQuery($query, $boolean = 'and', $not = false)
     * @method static \Illuminate\Database\Query\Builder whereRowValues($columns, $operator, $values, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder orWhereRowValues($columns, $operator, $values)
     * @method static \Illuminate\Database\Query\Builder whereJsonContains($column, $value, $boolean = 'and', $not = false)
     * @method static \Illuminate\Database\Query\Builder orWhereJsonContains($column, $value)
     * @method static \Illuminate\Database\Query\Builder whereJsonDoesntContain($column, $value, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder orWhereJsonDoesntContain($column, $value)
     * @method static \Illuminate\Database\Query\Builder whereJsonLength($column, $operator, $value = null, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder orWhereJsonLength($column, $operator, $value = null)
     * @method static \Illuminate\Database\Query\Builder dynamicWhere($method, $parameters)
     * @method static \Illuminate\Database\Query\Builder groupBy($groups = null)
     * @method static \Illuminate\Database\Query\Builder having($column, $operator = null, $value = null, $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orHaving($column, $operator = null, $value = null)
     * @method static \Illuminate\Database\Query\Builder|static havingBetween($column, $values, $boolean = 'and', $not = false)
     * @method static \Illuminate\Database\Query\Builder havingRaw($sql, $bindings = array(), $boolean = 'and')
     * @method static \Illuminate\Database\Query\Builder|static orHavingRaw($sql, $bindings = array())
     * @method static \Illuminate\Database\Query\Builder orderBy($column, $direction = 'asc')
     * @method static \Illuminate\Database\Query\Builder orderByDesc($column)
     * @method static \Illuminate\Database\Query\Builder inRandomOrder($seed = '')
     * @method static \Illuminate\Database\Query\Builder orderByRaw($sql, $bindings = array())
     * @method static \Illuminate\Database\Query\Builder|static skip($value)
     * @method static \Illuminate\Database\Query\Builder offset($value)
     * @method static \Illuminate\Database\Query\Builder|static take($value)
     * @method static \Illuminate\Database\Query\Builder limit($value)
     * @method static \Illuminate\Database\Query\Builder|static forPage($page, $perPage = 15)
     * @method static \Illuminate\Database\Query\Builder|static forPageBeforeId($perPage = 15, $lastId = 0, $column = 'id')
     * @method static \Illuminate\Database\Query\Builder|static forPageAfterId($perPage = 15, $lastId = 0, $column = 'id')
     * @method static \Illuminate\Database\Query\Builder|static union($query, $all = false)
     * @method static \Illuminate\Database\Query\Builder|static unionAll($query)
     * @method static \Illuminate\Database\Query\Builder lock($value = true)
     * @method static \Illuminate\Database\Query\Builder lockForUpdate()
     * @method static \Illuminate\Database\Query\Builder sharedLock()
     * @method static string toSql()
     * @method static int getCountForPagination($columns = array())
     * @method static string implode($column, $glue = '')
     * @method static bool exists()
     * @method static bool doesntExist()
     * @method static int count($columns = '*')
     * @method static mixed min($column)
     * @method static mixed max($column)
     * @method static mixed sum($column)
     * @method static mixed avg($column)
     * @method static mixed average($column)
     * @method static mixed aggregate($function, $columns = array())
     * @method static float|int numericAggregate($function, $columns = array())
     * @method static bool insert($values)
     * @method static int insertGetId($values, $sequence = null)
     * @method static bool insertUsing($columns, $query)
     * @method static bool updateOrInsert($attributes, $values = array())
     * @method static void truncate()
     * @method static \Illuminate\Database\Query\Expression raw($value)
     * @method static array getBindings()
     * @method static array getRawBindings()
     * @method static \Illuminate\Database\Query\Builder setBindings($bindings, $type = 'where')
     * @method static \Illuminate\Database\Query\Builder addBinding($value, $type = 'where')
     * @method static \Illuminate\Database\Query\Builder mergeBindings($query)
     * @method static \Illuminate\Database\Query\Processors\Processor getProcessor()
     * @method static \Illuminate\Database\Query\Grammars\Grammar getGrammar()
     * @method static \Illuminate\Database\Query\Builder useWritePdo()
     * @method static static cloneWithout($properties)
     * @method static static cloneWithoutBindings($except)
     * @method static void macro($name, $macro)
     * @method static void mixin($mixin, $replace = true)
     * @method static mixed macroCall($method, $parameters)
     * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BaseModel newModelQuery()
     * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BaseModel newQuery()
     * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BaseModel query()
     * @mixin \Eloquent
     */
    abstract class BaseModel extends Model
    {
  • 专为 Laravel 定制的 Visual Studio Code 编辑器 at 2个月前

    @gogoing 装了intelephense还需要composer装一个laravel-ide-helper

  • 🎂 Laravel 深入浅出指南 —— 国庆献礼 at 2个月前

    @Hexor 这段时间没太多时间,还没哈。清明节我好好看看

  • VSCode `PHP` 插件 `felixfbecker.php-intellisense` 与 `bmewburn.vscode-intelephense-client` 补全评估 at 2个月前

    Crane 的插件很久没更新了

    bmewburn 的每周还在更新的

  • 🎂 Laravel 深入浅出指南 —— 国庆献礼 at 2个月前

    @Hexor
    我读下源码哈 😆

  • 🎂 Laravel 深入浅出指南 —— 国庆献礼 at 2个月前

    @Hexor 通过pipeline 的方式来一次性加载所有中间件 这句话其实应该纠正下,

    public function handle()
    {
        //...
        $response = $next($request);
        //...
        return $response;
    }

    一个中间件handle起作用的地方在上面我注释的两处位置。所谓before和after应该就是指请求处理完成前和处理完成后执行的区别吧?

  • 干货:构建复杂的 Eloquent 搜索过滤 at 2个月前

    Eloquent 的 ->when($condition, $closure) 方法也不错

  • Laravel 5.8 被曝安全漏洞(已修复) at 2个月前

    老版本有这bug么

  • 使用 Zephir 轻松构建 PHP 扩展 at 3个月前

    :relaxed:好想构建一个 laravel.so