Muchammad Adam
Muchammad Adam

Reputation: 1

Laravel - Data is not being displayed using a all

Using the code below resulting in an empty array

$data = M_Obat::all();

While using the code below resulting in an array containing 2 data

$data = DB::table('master.ruangan')->get();

Attached images: [1]: https://i.sstatic.net/KSc9Z.png [2]: https://i.sstatic.net/wBylo.png

Upvotes: 0

Views: 60

Answers (3)

Paos
Paos

Reputation: 673

$data = M_Obat::all()
Data that you want it exists in #attributes

Upvotes: 0

yadu siva das
yadu siva das

Reputation: 628

check your model for 'hidden'

if a variable called $hidden is declared in model, fields added in it will not be shown.

protected $hidden = [
    'password',
    'remember_token',
];

Upvotes: 0

Gicu Aftene
Gicu Aftene

Reputation: 532

probably your model (M_Obat) is not correctly related to the right table:

try to specify it in your model class:

protected $table = 'master.ruangan';

Upvotes: 2

Related Questions