monteecristoo’s blog

https://twitter.com/irakaarozo

Laravel_DB

Laravel & redis 接続テスト

Installation composer require predis/predis @web.php Route::get('/redis_test', function() { print_r(app()->make('redis')); } // Illuminate\Redis\RedisManager Object ( [driver:protected] => predis [config:protected] => Array ( [default] => …

Laravel Database Seed

create a Seed file php artisan make:seeder UsersSeeder register Seed file @DatabaseSeeder.php use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder{ public function run() { $this->call(UsersSeeder::class); }} define UsersSeed…

Laravel Migration file 操作

// php artisan make:migration create_messages_table --create="messages" Schema::create付きのmigration fileが生成される。 function up → php artisan migrate した時の動作 funciton down → php artisan migrate:rollback した時の動作 migrateをやり…

Laravel 5.4 Database Structure

Relationships model A: User protected $fillable = [ DBのカラム] public function messages) { return $this->hasMany(Message::class); } model B: Message protected $fillable = [ DBのカラム] foreign_key は登録しなくてOK public function users() …