php - Laravel5: Receiving empty result for select on second database -
i'll try create small application in laravel5 , have 2 databases.
i did set second connection in config/databases.php
file , specified protected $connection = 'blog'
in category
model.
i try select categories $categories = category::all();
in query log blog
connection, i'll receive empty set while table holding 6 datasets. can't find reason, why doesn't return them.
// model class category extends model { protected $connection = 'blog'; protected $visible = ['id', 'name']; } // controller class categorycontroller extends controller { public function list() { db::connection('blog')->enablequerylog(); $categories = category::all(); // $categories = db::connection('blog')->table('categories')->select('*')->get(); log::info(db::connection('blog')->getquerylog()); return view('category.list')->with(compact('categories')); } }
as can see tried method , tried manual way, both doesn't return datasets of table.
my log of storage/logs/laravel.log
:
[2016-06-01 21:28:46] local.info: array ( 0 => array ( 'query' => 'select * `categories`', 'bindings' => array ( ), 'time' => 0.45000000000000001, ), )
can me out?
regards
you're using eloquent see, did declare protected $visible fields in model?
try too
return view('view')->with(compact('name_of_your_variable');