Exemplo n.º 1
0
 public function index()
 {
     $userCount = User::count();
     $articleCount = Article::count();
     $tagCount = Tag::count();
     $imageCount = Image::count();
     return view('admin.index', compact('userCount', 'articleCount', 'imageCount', 'tagCount'));
 }
Exemplo n.º 2
0
 public function index()
 {
     $article_count = Article::count();
     $category_count = Category::count();
     $tag_count = Tag::count();
     $user_count = User::count();
     return view('admin.console', compact('article_count', 'category_count', 'tag_count', 'user_count'));
 }
Exemplo n.º 3
0
 /**
  * About us page
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function about(Request $request)
 {
     $data['designer_number'] = Designer::count();
     $data['design_number'] = Design::count();
     $data['place_number'] = Place::count();
     $data['story_number'] = Story::count();
     $data['tag_number'] = Tag::count();
     $data['user_number'] = User::count();
     $data['city_number'] = City::has('places')->orHas('designers')->count();
     return view('pages.about', $data);
 }
 private function composeDashboard()
 {
     view()->composer('admin.index', function ($view) {
         $numArticle = \App\Article::count();
         $numCategory = \App\Category::count();
         $numTag = \App\Tag::count();
         $numProject = \App\Project::count();
         $numMessage = \App\Message::count();
         $view->with(compact('numArticle', 'numCategory', 'numTag', 'numProject', 'numMessage'));
     });
 }
 /**
  * Assert that emails are sent using the command send:email
  *
  * @return void
  */
 public function testItSendsEmailToInterestedSubscribers()
 {
     $totalSubscribers = Subscription::count();
     $subscriber = factory(Subscription::class)->create(['confirmed' => true, 'active' => true]);
     $this->assertTrue($totalSubscribers < Subscription::count());
     $subscriber->topics()->detach();
     foreach (Tag::all() as $tag) {
         $subscriber->topics()->save($tag);
     }
     $this->assertTrue($subscriber->topics()->get()->count() == Tag::count());
     // $this->expectsJobs(SendNewsletter::class);
     Artisan::call("emails:send", ['timestamp' => 1]);
     $logFile = file_get_contents(storage_path() . '/logs/laravel.log');
     $this->assertTrue(strpos($logFile, $subscriber->email) !== false);
 }
Exemplo n.º 6
0
 public function run()
 {
     $shuffle = function ($tags, $num) {
         $s = [];
         while ($num > 0) {
             $s[] = $tags[$num];
             $num--;
         }
         return $s;
     };
     $max = Tag::count();
     $tags = Tag::lists('id');
     factory(App\Product::class, 15)->create()->each(function ($product) use($max, $tags, $shuffle) {
         $product->tags()->attach($shuffle($tags, rand(1, $max - 1)));
     });
 }
Exemplo n.º 7
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['title' => 'required|max:255', 'category_id' => 'required|numeric']);
     $tag = new Tag();
     $count = $tag->count();
     if ($request->sort_id > 0) {
         $tag->sort_id = $request->sort_id;
     } else {
         $tag->sort_id = ++$count;
     }
     $tag->category_id = $request->category_id;
     $tag->slug = str_slug($request->title);
     $tag->title = $request->title;
     if ($request->status == 'on') {
         $tag->status = 1;
     } else {
         $tag->status = 0;
     }
     $tag->save();
     return redirect()->back()->with('status', 'Тег создан!');
 }