Exemple #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $posts = Post::all(['slug', 'updated_at']);
     $works = Work::all(['slug', 'updated_at']);
     $this->sitemap = new Sitemap(public_path('sitemap.xml'));
     $this->comment('Starting generating the Sitemap...');
     // Home
     $this->addItem(config('app.url') . '/', 0.9);
     // Resume
     $this->addItem(config('app.url') . '/resume', 0.8);
     // Blog index
     $this->addItem(config('app.url') . '/blog', 0.8);
     // Works index
     $this->addItem(config('app.url') . '/works', 0.8);
     // @codeCoverageIgnoreStart
     // Blog posts
     foreach ($posts as $post) {
         $this->addItem(config('app.url') . '/blog/' . $post->slug, 0.7);
     }
     // Works items
     foreach ($works as $work) {
         $this->addItem(config('app.url') . '/works/' . $work->slug, 0.7);
     }
     // @codeCoverageIgnoreEnd
     $this->sitemap->write();
     $this->comment('Sitemap generated successfully!');
 }
Exemple #2
0
 public function getWorks($parCategory)
 {
     // Retrieve offset param
     $offset = Input::get('offset');
     // Try to get current category by slug
     $category = Category::where('slug', $parCategory)->get()->first();
     // If not found try by id
     if (is_null($category)) {
         $category = Category::find($parCategory);
     }
     // Retrieve all works
     $works = is_null($category) ? Work::all() : $category->works;
     // Return the view
     return view('front.works', compact('works'));
 }
Exemple #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('tags')->truncate();
     factory(App\Tag::class, 10)->create();
     $posts = Post::all();
     foreach ($posts as $post) {
         $tags = Tag::orderByRaw('RAND()')->take(rand(1, 5))->get(['id']);
         $post->tags()->sync($tags);
     }
     $works = Work::all();
     foreach ($works as $work) {
         $tags = Tag::orderByRaw('RAND()')->take(rand(1, 5))->get(['id']);
         $work->tags()->sync($tags);
     }
 }
Exemple #4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\View\View
  */
 public function index() : \Illuminate\View\View
 {
     $works = Work::all()->sortBy('created_at');
     return View::make('back.work.index', compact('works'));
 }
 /**
  *  Displays table of the resources for admin
  *
  * @return Response
  */
 public function manage()
 {
     $works = Work::all();
     return view('works.manage', compact('works'));
 }