Download the PHP package medicivn/eloquent-nested-set without Composer
On this page you can find all versions of the php package medicivn/eloquent-nested-set. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package eloquent-nested-set
EloquentNestedSet
Tự động cập nhật lại cây khi tạo mới, cập nhật và xóa một node.
Cách sử dụng:
- Đầu tiên, một Root node với
parent_id=0, left=1, right=2, depth=0cần phải được khởi tạo ở table của bạn - Thêm
use NestedSetModel;vào trong Model tương ứng
Tính năng
-
getTree: lấy tất cả nodes và trả về dưới dạngnested array -
getFlatTree: lấy tất cả nodes và trả về dưới dạngflatten array, các nodes con sẽ được sắp xếp ngay sau nút cha -
getLeafNodes: lấy tất cả các nodes lá - các node không có con cháu -
getAncestors: lấy tất cả các nodes cha - ông (ancestor) của node hiện tại -
getAncestorsTree: lấy tất cả các nodes cha - ông (ancestor) của node hiện tại và trả về dưới dạngnested array -
getDescendants: lấy tất cả các nodes con cháu (descendant) của node hiện tại -
getDescendantsTree: lấy tất cả các nodes con cháu (descendant) của node hiện tại và trả về dưới dạngnested array -
parent: lấy node cha của node hiện tại -
children: lấy tất cả nodes con của node hiện tại -
buildNestedTree: build a nested tree base onparent_id fixTree: tính toán lại toàn bộ tree dựa trên parent_id
Query scopes
Root node sẽ dự động bị bỏ qua ở tất cả truy vấn bởi ignore_root global scope.
Để làm việc với root node, sử dụng withoutGlobalScope('ignore_root').
Các query scope khác:
ancestorsdescendantsflattenTreeleafNodes
Chú ý
-
Nếu bạn sử dụng
queuebạn sẽ cần phải sử dụng thêmSoftDelete, bởi vìqueuesẽ thất bại trong trường hợp 1 node bị xóa hoàn toàn, - Nếu bạn muốn sử dụng SQS-FIFO, hay tham khảo this package.
All versions of eloquent-nested-set with dependencies
illuminate/contracts Version ^9.21
illuminate/database Version ^9.21
illuminate/queue Version ^9.21
illuminate/bus Version ^9.21