Giter Club home page Giter Club logo

node-categoires's Issues

php artisan node-categories:migration

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 3072 bytes (SQL: alter table categories add index categories_node_index(node))

:(

trait NodeCategoryTrait问题

再来个
public function childrens() { return $this->where('node', 'like', $this->node.'%')->get(); }

这个忘了把自己去除掉吧,应该是
public function childrens() { return $this->where('node', 'like', $this->node.'%')->->where('id', '!=', $this->id)->get(); }

提两个trait NodeCategoryTrait的问题

第一个:
public function parent() { return $this->belongsTo(self::class, 'parent_id', 'id'); }
这里的self 应该不能这么用吧 应该改成static吧,不然指向的是NodeCategoryTrait本身,而不是model本身。
第二个:
public function parents() { return $this->where(DB::raw("LOCATE(node, '{$this->node}')"), '>', 0) ->where('id', '<>', $this->id)->get(); }
这个的实现方式没有必要吧
public function parents() { $node_array = explode(',',$this->node); return $this->whereIn("id",$node_array)->where('id', '<>', $this->id)->get(); }
讲道理这样的效率会高很多吧。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.