【Laravel】プロジェクト:TEST6 カレンダーページの作成 動作編

本日はカレンダーページ作成の動作編

 

tk49.hatenablog.com

のNextToDoから

 

①カレンダー作成記事の読み込み

www.itsolutionstuff.com

一通り読み確認。

②動作確認

テーブル設定の処理を入れたら動くようになった。

テストデータを登録できるようになった。

f:id:tk49:20210907035200p:plain

 

しかし削除ができない。

原因はmodelにてsoftDeleteを定義していたため。

 

物理削除はどうしても抵抗があるので、基本ソフトデリートにしていた。

Event.phpは下記のような感じ。

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; //追加

class Event extends Model
{
    use HasFactory;
    use SoftDeletes;

    protected $fillable = [
        'title', 'start', 'end'
    ];
}

 

Model側に追加しているので、テーブル側(2021_09_06_013546_create_events_table.php)も

softDelete設定を入れてやる必要がある。

<?php
  
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
  
class CreateEventsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('events', function (Blueprint $table) {
            $table->id();
            $table->string('title');
            $table->date('start');
            $table->date('end');
            $table->timestamps();
            $table->softDeletes(); // 追加
        });
    }  
  
    /** 
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('events');
    }
}

 

追加したところ無事削除できた。

f:id:tk49:20210907041733p:plain

 

 

③画面遷移させず、右側部分に表示

こちらはNextTodoへ。

 

NextTodo

  1. 画面遷移させず、右側部分に表示
  2. Laravel画面遷移時のサイドメニュー(アコーディング)状態保持の方法
  3. マスタ設定画面
  4. ファイルアップロード
  5. ファイルダウンロード
  6. google Calendarとの同期
  7. ログイン画面
  8. トップページ
  9. 注文データ登録