I got category_to_news and news_main table
category_to_news : news_id (int),name (varchar),title (timestamp)
news_main : id (int),title (varchar),image (int),created_at (varchar)
class Newsmain extends Eloquent {
protected $table = 'news_main';
}
class Categorytonews extends Eloquent {
protected $table = 'category_to_news';
public $uniquekey = 'title';
public function Newsmain()
{
return $this->belongsTo('Newsmain');
}
}
how to return by news_main's field and category_news's field ? I've tried this method and it's not work
$posts = Categorytonews::with(array(
'Newsmain' => function($query)
{
$query->orderBy('id', 'DESC')->select(array('title', 'id', 'created_at', 'image'));
}
))
->get( );
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community