고요빛물결
PHP프레임워크

[라라벨] laravel-enso에도 Comments가 있네요

· 2019-01-14 (월) 00:15:12 · 1903

라라벨의 package를 사용해서 만든 것 같습니다.

 

https://github.com/laravel-enso/CommentsManager

 

vendor로 등록되는 구조이니..  라라벨에서 메인 코어는 나눠도 각각 패키지별로 업그레이드가 편하게 

 

할 수 있을 것 같습니다.

 

morphs를 잘 이해해야 되네요

 

CommentsTable

 

public function up()

{

  Schema::create('comments', function (Blueprint $table) {

    $table->increments('id');

 

    $table->morphs('commentable');

 

    $table->text('body');

 

    $table->integer('created_by')->unsigned()->nullable();

    $table->foreign('created_by')->references('id')->on('users');

 

    $table->integer('updated_by')->unsigned()->nullable();

    $table->foreign('updated_by')->references('id')->on('users');

 

    $table->timestamps();

  });

}

 

CommentUserPivotTable

public function up()

{

    Schema::create('comment_user', function (Blueprint $table) {

        $table->integer('comment_id')->unsigned()->index();

        $table->foreign('comment_id')->references('id')->on('comments')

            ->onDelete('cascade');

 

        $table->integer('user_id')->unsigned()->index();

        $table->foreign('user_id')->references('id')->on('users')

            ->onDelete('cascade');

 

        $table->primary(['comment_id', 'user_id']);

    });

}

 

댓글을 작성하시려면 로그인이 필요합니다.

소모임

23,243건
+
분류 제목 글쓴이 날짜 조회
서버관리자 19-01-14 조회 1,483
PHP프레임워크
[PHP프레임워크]
19-01-14 조회 2,677
PHP프레임워크
[PHP프레임워크]
19-01-14 조회 1,904
PHP프레임워크
[PHP프레임워크]
19-01-14 조회 2,501
앱개발 19-01-13 조회 1,967
PHP프레임워크
[PHP프레임워크]
19-01-13 조회 2,617
PHP프레임워크 19-01-13 조회 6,035
써글모 19-01-13 조회 2,704
PHP프레임워크
[PHP프레임워크]
19-01-13 조회 7,438
해외사용자 19-01-13 조회 6,448
자동차 19-01-13 조회 1,700
PHP프레임워크 19-01-12 조회 1,915
PHP프레임워크 19-01-12 조회 1,816
서버관리자 19-01-12 조회 2,447
서버관리자 19-01-12 조회 1,923
자동차 19-01-12 조회 1,018
서버관리자 19-01-11 조회 2,901
오늘뭐먹지? 19-01-11 조회 1,913
앱개발 19-01-11 조회 2,459
JS프레임워크
[JS프레임워크]
19-01-11 조회 2,809
자동차 19-01-11 조회 1,159
PHP프레임워크 19-01-11 조회 1,815
PHP프레임워크 19-01-11 조회 1,846
PHP프레임워크 19-01-11 조회 2,258
앱개발 19-01-10 조회 4,640
개발자 메모장 19-01-10 조회 2,522
자동차 19-01-10 조회 1,454
서버관리자
[서버관리자]
19-01-10 조회 1,893
서버관리자 19-01-10 조회 2,186
PHP프레임워크 19-01-10 조회 1,753