changes
This commit is contained in:
@ -30,10 +30,13 @@ class WebsiteController extends Controller
|
||||
->where('status',1)
|
||||
->get();
|
||||
|
||||
|
||||
$data['sports'] = Newscategories::with('sportNews')->get();
|
||||
$data['cultural'] = Newscategories::with('culturalNews')->get();
|
||||
$data['technology'] = Newscategories::with('technologyNews')->get();
|
||||
$data['entertainment'] = Newscategories::with('entertainmentNews')->get();
|
||||
$data['branches'] = Newscategories::with('branchesNews')->get();
|
||||
|
||||
// dd($data['entertainment']);
|
||||
|
||||
$data['internationalNews'] = News_type::with('news')->get();
|
||||
|
@ -27,7 +27,6 @@ class Newscategories extends Model
|
||||
'updatedby',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
];
|
||||
|
||||
protected $appends = ['status_name'];
|
||||
@ -53,33 +52,45 @@ class Newscategories extends Model
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(Newscategories::class, 'parent_category')->where('status',1);
|
||||
return $this->belongsTo(Newscategories::class, 'parent_category')->where('status', 1);
|
||||
}
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(Newscategories::class, 'parent_category')->where('status',1);
|
||||
return $this->hasMany(Newscategories::class, 'parent_category')->where('status', 1);
|
||||
}
|
||||
|
||||
public function news(){
|
||||
public function news()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->orderBy('display_order');
|
||||
}
|
||||
public function entertainmentNews(){
|
||||
public function entertainmentNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function technologyNews(){
|
||||
public function technologyNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function culturalNews(){
|
||||
public function culturalNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function sportNews(){
|
||||
public function sportNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(9)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function interviewNews(){
|
||||
public function interviewNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
|
||||
public function politicNews(){
|
||||
public function politicNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(5)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
public function branchesNews()
|
||||
{
|
||||
return $this->hasMany(News::class, 'newscategories_id', 'category_id')->limit(6)->inRandomOrder()->orderBy('display_order');
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user