SHARE
TWEET

blogcomposer

crushetblack Nov 14th, 2019 (edited) 119 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4. namespace App\Http\View\Composers;
  5.  
  6.  
  7. use Illuminate\View\View;
  8.  
  9. use App\Setting;
  10. use App\Category;
  11. use App\Post;
  12. use App\Tag;
  13.  
  14. class BlogComposer
  15. {
  16.     public function compose(View $view){
  17.  
  18.         $view->with('site_setting', $this->site_setting());
  19.         $view->with('categories', $this->categories());
  20.         $view->with('popular_post', $this->popular_post());
  21.         $view->with('tags', $this->tags());
  22.         $view->with('archives', $this->archives());
  23.         $view->with('meta', $this->meta());
  24.  
  25.     }
  26.    
  27.     private function site_setting(){
  28.         return Setting::first();
  29.     }
  30.  
  31.     private function categories(){
  32.         return Category::all();
  33.     }
  34.  
  35.     private function popular_post(){
  36.         return Post::with('user','category')->where('status', 1)->orderby('view','desc')->take(5)->get();
  37.     }
  38.  
  39.     private function tags(){
  40.         return Tag::all();
  41.     }
  42.  
  43.     private function archives()
  44.     {
  45.         $archives = Post::archives();
  46.         return $archives;
  47.  
  48.     }
  49.  
  50.     private function meta(){
  51.  
  52.         $site_setting = Setting::take(1)->get();
  53.         $data = array();
  54.         foreach($site_setting as $key => $setting){
  55.            
  56.                 $data[$key] = array(
  57.                     'meta_d' => $setting->meta_description,
  58.                     'meta_r' => $setting->meta_keywords,               
  59.                 );
  60.                            
  61.         }
  62.  
  63.         dd($data) ;
  64.         return $data;
  65.     }
  66.  
  67.  
  68. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top