My DatabaseSeeder is like this :
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder
{
public function run()
{
Model::unguard();
$this->call('MasterLookupsTableSeeder')
}
}
My MasterLookupsTableSeeder is like this :
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class MasterLookupsTableSeeder extends Seeder
{
public function run()
{
DB::table('master_lookups')->insert([
'id' => '17',
'code' => '002',
'name' => 'sample data',
'information' => NULL,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
]);
}
}
When I run php artisan db:seed --class=MasterLookupsTableSeeder
, it will insert into to table master_lookups. It is still static. I want to create a dynamic where the data is inserted into master_lookups table taken from another table, for example akuns table. akuns table have field id, code, name, code_shopping.
I want like this :
code data from akuns table insert to field code in table master_lookups
name data from akuns table insert to field name in table master_lookups
code_shopping data from akuns table insert to field information in table master_lookups in the form of json. data type of field information is json.
Is there any people who can help me?