고요빛물결

laravel-enso에도 Comments가 있네요

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

라라벨의 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']);

    });

}

 

댓글을 작성하시려면 로그인이 필요합니다.
+
분류 제목 글쓴이 날짜 조회
라라벨
[라라벨]
19-03-12 조회 2,811
기타 19-03-12 조회 2,447
기타 19-02-28 조회 3,192
라라벨 19-02-27 조회 2,612
기타 19-02-27 조회 2,581
라라벨 19-02-21 조회 3,027
라라벨 19-02-19 조회 2,280
라라벨 19-01-20 조회 2,684
라라벨 19-01-19 조회 3,789
라라벨 19-01-16 조회 2,271
기타 19-01-16 조회 2,016
라라벨 19-01-15 조회 2,695
라라벨 19-01-15 조회 3,613
라라벨 19-01-15 조회 2,698
라라벨 19-01-14 조회 2,658
라라벨 19-01-14 조회 1,886
라라벨 19-01-14 조회 2,484
라라벨 19-01-13 조회 2,601
라라벨 19-01-13 조회 6,020
코드이그나이터 19-01-13 조회 7,414
라라벨 19-01-12 조회 1,897
라라벨 19-01-12 조회 1,800
라라벨 19-01-11 조회 1,798
라라벨 19-01-11 조회 1,828
라라벨 19-01-11 조회 2,242
라라벨 19-01-10 조회 1,734
라라벨 19-01-10 조회 1,873
라라벨 19-01-10 조회 2,026
기타 19-01-09 조회 1,686
라라벨 19-01-09 조회 2,136