Laravel Tips

今回も、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



アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム