Before
<?php
namespace App\Http\Controllers;
use App\Models\Hoge;
use App\Models\Fuga;
use App\Models\Foo;
use App\Models\Bar;
use App\Futaba\Chimaki as Chima;
use App\Futaba\Ribon as Bon;
use App\Futaba\Sakura as Saku;
class HogeController extends Controller
{
//
}
After (PHP 7 以降のコード)
<?php
namespace App\Http\Controllers;
use App\Models\{
Hoge, Fuga, Foo, Bar
};
use App\Futaba\{
Chimaki as Chima,
Ribon as Bon,
Sakura, as Saku
};
class HogeController extends Controller
{
//
}
- Tinkerでも有効
- as(エイリアス)も指定できる
途中まで同じパスが多い場合は、まとめてあげると見やすいですね!