고요빛물결

PHP Infinite Multi Level Comments

· 2017-10-28 (토) 07:17:32 · 1913

[code]

CREATE TABLE IF NOT EXISTS `comment` (

    `cid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,

    `sid` smallint(5) unsigned NOT NULL,

    `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,

    `message` varchar(255) NOT NULL,

    `parent` smallint(5) unsigned DEFAULT NULL,

    `children` tinyint(1) unsigned NOT NULL DEFAULT '0',

    `author_name` varchar(40) NOT NULL,

    `author_email` varchar(255) NOT NULL,

    PRIMARY KEY (`cid`),

    KEY `parent` (`parent`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;

--

-- Constraints for dumped tables

--

-- Constraints for table `comment`

--

ALTER TABLE `comment`

    ADD CONSTRAINT `comment_ibfk_2` FOREIGN KEY (`parent`) REFERENCES `comment` (`cid`);

[/code]

 

parent, child를 넣어서 무한 커멘트를 만들 수 있는 것 같습니다.

 

링크2의 데모를 보면 무한 Reply로....

 

대략적인 구현은 스택오버플로우에서 참조로..

https://stackoverflow.com/questions/35884548/laravel-query-or-function-for-nested-infinite-sub-category

 

이 방식을 이용하면 무한 카테고리도 가능하겠네요..

 

morph는 Post(또는 Article)이나 다른 Product등에 커멘트를 달수 있게 해주는 것 같습니다.

 

multi-level은 parent_id와 child_id로 해서 만들어 지는 것 같습니다.

 

https://stackoverflow.com/questions/35073613/multi-tiered-comment-system-laravel/35074401

댓글을 작성하시려면 로그인이 필요합니다.
+
분류 제목 글쓴이 날짜 조회
라라벨 19-01-09 조회 1,764
라라벨 19-01-08 조회 2,027
라라벨 19-01-08 조회 1,594
라라벨 19-01-08 조회 1,607
라라벨 19-01-07 조회 2,264
라라벨 19-01-06 조회 2,136
기타 19-01-05 조회 2,281
라라벨 19-01-04 조회 1,783
라라벨 19-01-04 조회 1,675
라라벨 19-01-04 조회 4,508
라라벨 19-01-03 조회 1,806
라라벨 19-01-03 조회 2,991
라라벨 19-01-02 조회 1,832
라라벨 19-01-01 조회 2,153
라라벨 18-12-31 조회 2,131
라라벨
[라라벨]
18-12-30 조회 1,609
라라벨 18-12-30 조회 2,605
기타 18-12-30 조회 1,574
라라벨 18-12-29 조회 1,951
코드이그나이터 18-12-28 조회 1,723
일반 18-12-28 조회 1,695
라라벨 18-12-27 조회 1,803
라라벨 18-12-26 조회 2,584
라라벨 18-12-25 조회 1,736
라라벨 18-12-23 조회 1,721
라라벨 18-12-20 조회 2,306
기타 18-10-07 조회 2,202
라라벨 18-10-05 조회 1,948
기타 18-10-04 조회 2,500
기타 18-10-03 조회 2,339