vergil-lai / node-categoires Goto Github PK
View Code? Open in Web Editor NEWNode categories model and observer for laravel 5
License: MIT License
Node categories model and observer for laravel 5
License: MIT License
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
))
:(
第一个:
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(); }
讲道理这样的效率会高很多吧。
再来个
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(); }
吧
[Symfony\Component\Debug\Exception\FatalErrorException]
Cannot redeclare class CreateCategoriesTable
使用getTree方法,处理原始数据的map方法,我想按order字段排序
看了看源码$collection->keyBy('id')->toArray();这里改成我的字段就读不出数据了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.