Ejemplo n.º 1
0
 public function generateSlug($title, $i = 0)
 {
     try {
         $slugged = \Illuminate\Support\Str::slug($title . ($i ? '-' . $i : ''), '-');
         $article = Article::withDrafts()->slug($slugged);
         return $this->generateSlug($title, ++$i);
     } catch (\Exception $e) {
         return $slugged;
     }
 }
Ejemplo n.º 2
0
 public function post()
 {
     $articles = Article::all();
     $groupByDate = $articles->groupBy(function ($article) {
         return $article->date->format('Y-m-d');
     });
     $countingByDate = $groupByDate->map(function ($articles, $date) {
         return [$this->gd($date), $articles->count()];
     });
     $this->output->set_content_type('application/json')->set_output(json_encode($countingByDate->values()));
 }
Ejemplo n.º 3
0
 public function getPostPopular()
 {
     return Article::popular()->get();
 }