Home > front end >  can't show data with all() but if query db thtas work
can't show data with all() but if query db thtas work

Time:07-15

i cant get the data with $data = M_Obat::all(); no data just empty array

but if i try to code like, its work $data = DB::table('master.ruangan')->get(); array with data

CodePudding user response:

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';

CodePudding user response:

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',
];

CodePudding user response:

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

  • Related