Пример #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::user()->type === 'user') {
         return redirect('admin/patterns');
     }
     $users = User::all();
     // $date = $users->timestamp;
     $patterns = Pattern::all();
     $category = Category::all();
     $subcategory = SubCategory::all();
     $nielsen = RulesNielsen::all();
     $comments = Comment::all();
     return view('admin.dashboard', ['patternsCount' => $patterns->count(), 'patterns' => Pattern::where('active', 1)->orderBy('title', 'desc')->take(8)->get(), 'users' => $users, 'nielsen' => $nielsen, 'category' => $category, 'subcategory' => $subcategory, 'comments' => $comments, 'commentsCount' => $comments->count(), 'usersTime' => Carbon::now()->subDays(1)->diffForHumans(), 'usersCount' => $users->count(), 'usersNormals' => User::where('type', 'user')->orderBy('active', 'desc')->take(8)->get(), 'usersExperts' => User::where('type', 'expert')->orderBy('active', 'desc')->take(8)->get()]);
 }
Пример #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id, Request $request)
 {
     $comments = Comment::findOrFail($id);
     $comments->delete();
     $message = $comments->comment . ' fue eliminado de nuestros registros';
     if ($request->ajax()) {
         return response()->json(['id' => $comments->id, 'message' => $message]);
     }
     Session::flash('message', $message);
     return redirect()->route('admin.patterns-comments.index');
 }