mgsmus Sorunu buldum bende soyleki bi kac yerde kullanilan data lar icin bir composer isimli class kurdum. `class NewsComposer
{
private $latest_news;
private $latest_announce;
private $lang;
private $daily_term;
private $daily_aphorism;
private $news_categories;
private $side_gallery;
private $professors;
private $events;
public function __construct(NewsRepositoryInterface $news,
AnnouncementRepositoryInterface $announcement,
GeneralRepositoryInterface $general,
GalleryRepositoryInterface $gallery,
ProfessorsRepositoryInterface $professors,
App\Http\Repository\EventRepositoryInterface $events)
{
$this->lang=Language::where('display_name', App::getLocale())->first();
$this->latest_news = $news->getTopNews($this->lang->id,3);
$this->latest_announce = $announcement->getTopAnnouncement($this->lang->id,3);
$this->daily_term=$general->getDailyTerm($this->lang->id);
$this->daily_aphorism=$general->getDailyAphorism($this->lang->id);
$this->news_categories=$news->getNewsCategories($this->lang->id);
$this->side_gallery=$gallery->GetPhotoGallery($this->lang->id,'',9);
$this->professors=$professors->getTopProfessors($this->lang->id,3);
$this->events=$events->getEvents($this->lang->id,'upcoming');
}
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$view->with('latest_news', end($this->latest_news))
->with('latest_announce', end($this->latest_announce))
->with('daily_term', $this->daily_term)
->with('daily_aphorism', $this->daily_aphorism)
->with('side_gallery', $this->side_gallery)
->with('news_categories',$this->news_categories)
->with('professors',$this->professors)
->with('events',$this->events);
}
}`
ve sunu composerserviceprovider da
public function boot()
{
view()->composer(
['components.sidebar','home'],
'App\Http\ViewComposers\NewsComposer'
);
}
su sekilde cagiriyorum. Mesele 2 sayfadada olunca mesele haberler hem sidebarda hem ana sayfada olunca 2 kere ayni seyi cagirmis oluyor o yuzden duplicate ler olusuyor. Ne yapa bilirim?