I make many database applications, in my database have the same table name and the same file. how can i display all the data
this is my model
this ins my model users
class Users extends Model
{
// protected $connection = 'mysql4';
protected $table = ('ilkom_akbar.table_users');
protected $primaryKey = 'ID';
protected $fillable = [
'ID',
'user_login',
'user_pass',
'user_nicename',
'user_email',
'url',
'user_registered',
'user_activation_key',
'user_status',
'display_name'
];
public function posts()
{
return $this->hasMany(Posts::class,'post_author');
}
}
this ins my model users1
class Users1 extends Model
{
protected $table = 'ilkom_adeputra.table_users';
protected $primaryKey = 'ID';
protected $fillable = [
'ID',
'user_login',
'user_pass',
'user_nicename',
'user_email',
'url',
'user_registered',
'user_activation_key',
'user_status',
'display_name'
];
public function posts()
{
return $this->hasMany(Posts1::class,'post_author');
}
}
this ins my model posts
class Posts extends Model
{
protected $table = 'ilkom_akbar.table_posts';
protected $primaryKey = 'ID';
protected $fillable = [
'ID',
'post_author',
'post_date',
'post_date_gmt',
'post_content',
'post_title',
'post_excerpt',
'post_status',
'comment_status',
'ping_status',
'post_password',
'post_name',
'to_ping',
'pinged',
'post_modified',
'post_modified_gmt',
'post_content_filtered',
'post_parent',
'guid',
'menu_order',
'post_type',
'post_mime_type',
'comment_count'
];
public function users()
{
return $this->belongsTo(Users::class,'ID');
}
}
this ins my model posts1
class Posts1 extends Model
{
protected $table = 'ilkom_adeputra.table_posts';
protected $primaryKey = 'ID';
protected $fillable = [
'ID',
'post_author',
'post_date',
'post_date_gmt',
'post_content',
'post_title',
'post_excerpt',
'post_status',
'comment_status',
'ping_status',
'post_password',
'post_name',
'to_ping',
'pinged',
'post_modified',
'post_modified_gmt',
'post_content_filtered',
'post_parent',
'guid',
'menu_order',
'post_type',
'post_mime_type',
'comment_count'
];
public function users()
{
return $this->belongsTo(Users1::class,'ID');
}
}
this is get data
@foreach ($karyawan1->posts as $data)
<tr>
<td>{{ $no++}}</td>
<td>{{ $data->post_title}}</td>
<td>{{ $data->post_name}}</td>
<td>{{ $data->post_modified}}</td>
<td>{{ $data->post_modified_gmt}}</td>
@endforeach