【Laravel】プロジェクト:TEST6 カレンダーページの作成 動作編
本日はカレンダーページ作成の動作編
のNextToDoから
①カレンダー作成記事の読み込み
一通り読み確認。
②動作確認
テーブル設定の処理を入れたら動くようになった。
テストデータを登録できるようになった。
しかし削除ができない。
原因は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');
}
}
追加したところ無事削除できた。
③画面遷移させず、右側部分に表示
こちらはNextTodoへ。
NextTodo
- 画面遷移させず、右側部分に表示
- Laravel画面遷移時のサイドメニュー(アコーディング)状態保持の方法
- マスタ設定画面
- ファイルアップロード
- ファイルダウンロード
- google Calendarとの同期
- ログイン画面
- トップページ
- 注文データ登録