1
0

More than 1 year has passed since last update.

Laravelでアプリを作成してみた【ミニ受注入力システム】

Last updated at Posted at 2023-01-25

環境

① project の表すデータベースを『phpMyAdmin』で作成する。

② コマンドプロントでlaravelプロジェクト project を作成する

※ project をc:¥xampp¥laravel デレクトリ下に作成するものとする。

composer create-project laravel/laravel <project> --prefer-dist
<プロジェクト名>
cd <プロジェクト名>

//バージョンを確認する

php artisan -v

//開発用のサーバーを立ち上げる

php artisan serve

③.envファイルを編集する

.env
DB_DATABASE=bunbougu_db

④ bunbougus の情報を保存する bunbougus テーブルを作成する

php artisan make:migration create_bunbougus_table

⑤ コードを加えて編集する

databese/migrations/table.php
{
        Schema::create('bunbougus', function (Blueprint $table) {
            $table->id();
            $table->string("name");
            $table->integer("kakaku");
            $table->integer("bunrui");
            $table->text("shosai");
            $table->timestamps();
        });
    }
php artisan migrate

⑥文房具の分類を識別するテーブル bunruis を作成する(マイグレーションファイルを作成する)

php artisan make:migration create_bunruis_table
create_bunruis_table.php
Schema::create('bunruis', function (Blueprint $table) {
            $table->id();
            $table->string("str"); //追加
            $table->timestamps();
        });
php artisan migrate
php artisan make:seeder BunruisSeeder
php artisan make:seeder BunbougusSeeder 
seeder/BunruisSeeder.php

 public function down()
    {
        DB::table('bunruis')->insert([
    [
        'create_at' => date('Y-m-d H:i:s'),
        'updated_at' => null,
        'str'=> '鉛筆',
    ],
    [
        'create_at' => date('Y-m-d H:i:s'),
        'updated_at' => null,
        'str'=> 'ボールペン',
    ],
    [
        'create_at' => date('Y-m-d H:i:s'),
        'updated_at' => null,
        'str'=> '消しゴム',
    ],
    
        ]);
    }
};
php artisan db:seed --class=BunruisSeeder

参考サイト

Laravel9でミニ受注入力システムを作成(前編)。文房具マスター一覧表示・登録・編集・削除、まずはWEBアプリを作ってLaravelを学習。基本的なCRUD

1
0
0

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
0