HomeController.php 758 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\Egg;
  4. use App\Models\Product;
  5. use App\Models\UsefulLink;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Support\Facades\Auth;
  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. dd(Product::first()->nodes()->get() , Product::first()->eggs()->get());
  18. $usage = 0;
  19. foreach (Auth::user()->servers as $server){
  20. $usage += $server->product->price;
  21. }
  22. return view('home')->with([
  23. 'useage' => $usage,
  24. 'useful_links' => UsefulLink::all()->sortBy('id')
  25. ]);
  26. }
  27. }