HomeController.php 753 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\UsefulLink;
  4. use Illuminate\Contracts\Support\Renderable;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Facades\Auth;
  7. use Illuminate\Support\Facades\DB;
  8. class HomeController extends Controller
  9. {
  10. public function __construct()
  11. {
  12. $this->middleware('auth');
  13. }
  14. /** Show the application dashboard. */
  15. public function index(Request $request)
  16. {
  17. $usage = 0;
  18. foreach (Auth::user()->Servers as $server){
  19. $usage += $server->product->price;
  20. }
  21. $useful_links = DB::table('useful_links')->get();
  22. return view('home')->with([
  23. 'useage' => $usage,
  24. 'useful_links' => $useful_links
  25. ]);
  26. }
  27. }