foreachの内容が反映されない
解決したいこと
二つ目の画像のように反映させたいのですが反映されず、
原因はforeachの構文が違うと思うのですが、ソースコードは
合っていますか?それとも他のところが違うのでしょうか?
あとデータはデータベースのworldcupでテーブルはplayersのデータです。
index.blade.php
<table>
<tr>
<th>ID</th>
<th>背番号</th>
<th>ポジション</th>
<th>所属</th>
<th>名前</th>
<th>誕生日</th>
<th>身長</th>
<th>体重</th>
</tr>
@foreach($players as $player)
<tr>
<td>{{ $player->id }}</td>
<td>{{ $player->uniform_num }}</td>
<td>{{ $player->position }}</td>
<td>{{ $player->club }}</td>
<td>{{ $player->name }}</td>
<td>{{ $player->birth }}</td>
<td>{{ $player->height }}</td>
<td>{{ $player->weight }}</td>
</tr>
@endforeach
</table>
web.php
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
//Route::get('/', function () {
//return view('welcome');
//});
Route::get('/','PlayersController@index');
Route::get('/index','PlayersController@index');
PlayersController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Player;
class PlayersController extends Controller
{
public function index() {
$players = Player::all();
return view('players.index', compact('players'));
}
}
.env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:nz5OCaTAuJwpu/1OnyRD6M4sAcMM02UYxWtikiFZLD4=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=worldcup
DB_USERNAME=root
DB_PASSWORD=Vagrant@000
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
0