Laravel Tips
- 2022年8月05日
- 技術情報
今回も、laravelのTipsをいくつか紹介します。
①別のカラムの後にカラムを追加したい場合は、after
メソッドを使用することができます。
<?php
Schema::table('users', function(Blueprint $table){
$table->after('email', function($table){
$table->integer('status');
$table->string('address');
$table->string('city');
$table->string('state');
});
});
②与えられた値がfilledかblankかを判断したい場合は、 empty()
や is_null()
などの代わりに、ヘルパー関数 filled()
を使うことができます。
filled(0);
filled(true);
filled(false);
//return true
filled('');
filled(' ');
filled(null);
filled(collection());
//return false
ということで、今回はこれで終わります。
金曜担当 – Ami
asahi at 2022年08月05日 10:00:00