HomeController.php 681 B

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