【Laravel入門】データベースに接続する方法と解説

今回はデータベースに接続する方法と解説の紹介です。 データベースに接続する方法 Laravelでデータベースへ接続するには以下のことを行います。 DBの接続情報の入力 config/database.phpの確認 Modelの作成 マイグレーションの記述 Servic ...
【Laravel入門】interfaceとimplementsについて理解と実装を行う

今回はinterfaceとimplementsについて理解と実装の紹介です。 Interfaceとは? Interface(Interface)とは、クラスが実装すべきメソッドの宣言だけを含む型です。具体的な実装は含まれておらず、メソッドのシグネチャ(名前、引数、返り値の型)だけ ...
【Laravel入門】Modelの作成と書き方

今回はLaravelのModelの作成と書き方の紹介です。 Modelとは? Model(モデル)は、MVC(Model-View-Controller)アーキテクチャの一部であり、アプリケーションのデータを扱う部分を指します。モデルは、データの取得、変更、保存、削除などのデータ ...
【Laravel入門】MVC + S Serviceクラスの書き方!

今回は【Laravel入門】サービスモデルの書き方!MVC + S 居ついての紹介です。 MVC + Sとは? LaravelのMVC(Model-View-Controller) + Serviceの構成のアーキテクチャです。 各項目について説明していきますね。 M:Model ...
【Laravel入門】Laravelのディレクトリ構造を理解する【完全保存版】

application -app -bootstrap -config -database -public -resources -routes -storage -tests -vendor -.env app Laravelアプリケーションの中核部分が含まれるディレクトリです ...
【Laravel入門】middleware(ミドルウェア)とは

middleware(ミドルウェア)とは middlewareとは、HTTPリクエストが送られたタイミングで、受信されてからレスポンスが返されるまでの間に実行される処理をカプセル化したものです。 ミドルウェアはコントローラークラスの前後で処理を行えます。 URL(リクエスト) ↓ ...
SQLSTATE[HY000] [1044] Access denied for user ‘sail’@’%’ to database ‘laravel’

今回は「SQLSTATE Access denied for user 'sail'@'%' to database 'laravel'」についての紹介です。 runするとエラーに Laravel sailのアプリケーションでrun実行時にエラーが発生。 npm run dev ...
【Laravel sailでDB接続エラー】SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘laravel.sessions’ doesn’t exist

エラー文 「run」を実行したときにエラーが発生しました。その原因と解決方法を見ていきましょう。 SQLSTATE: Base table or view not found: 1146 Table 'laravel.sessions' doesn't e ...
【Laravel Sail】Inertia.jsを使ってReactとTypeScript環境構築

今回はLaravel sailを使ってReactとTypeScriptの環境構築の紹介です。 Inertiaとは? Inertia.jsは、クライアントサイドとサーバーサイドの間でデータを非同期的に交換することで、SPAの利点を活用しつつ、従来のサーバーサイドレンダリングの利点を ...
【Laravel入門】Request $requestとは?inputデータをの受信と取得

Request とは? ブラウザから送られるリクエストデータ全部を含むオブジェクトのことです。 「フォームから入力したデータを受け取る」という意味でもあります。 $name = $request->input('name'); $age = $request->input('ag ...