Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [inny]przekazanie zmiennej w laravel 7
kmpl
post
Post #1





Grupa: Zarejestrowani
Postów: 92
Pomógł: 0
Dołączył: 4.06.2006

Ostrzeżenie: (0%)
-----


Witam,


Próbuję w Laravelu przekazać zmienną $computerCount z modelu Comp do widoku strony głównej welcome.blade.php.
Model:

  1. public function count()
  2. {
  3.  
  4. Comp::count()
  5. $compCount = Comp::count();


W routes/web.php

  1. Route::get('/', function () {
  2. $compCount = Comp::count();
  3. return view('welcome')->with('compCount', App\Comp::count());
  4.  
  5. });



welcome.blade.php:

  1. {{ $compCount }}


Jest jednak komunikat: Non-static method App\Comp::count() should not be called statically.
Coś robię źle, ale nie mam pomysłu co.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.08.2025 - 14:43