LoginSignup
1
2

More than 3 years have passed since last update.

リポジトリパターンの説明とLaravelでのフォルダ構成

Posted at

ビジネスロジックとは

アプリケーション固有の処理。
アプリケーション固有の状態遷移を記述した部分。

リポジトリパターンについて

データの操作に関連するロジックをビジネスロジックから切り離し、抽象化したレイヤに任せることで保守や拡張性を高めるパターン。

ヒラマサでは、Controllerとかの処理の中(ビジネスロジック)で、DB関連の処理を別ファイルに記述し、その処理ファイルをapp/Logicディレクトリ中に入れていく。

Modelもディレクトリを作って実装していく。例えば、TaskController内の処理をLogicの方に格納すると下記のような構成になる。

app-・
    |-Console
    |-Exceptions
    |-Http
    |-Logic
     |-Task
      |-TaskLogic.php
      |-TaskLogicInterface.php
    |-Mail
    |-Model
    |-Policies
    |-Providers

具体的なリポジトリパターンの実装については下記を参照。
リポジトリパターンの実装

1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2