In my app I have a users table and a profiles table. When a user goes to their dashboard, they should be able to click a link to view their profile page. Here s the link:
<a href=”{路边(简介,show ,$profiles->id>>link to You Profile page</a>
然而,我正在发现错误:Route [profiles.show]没有界定。
I m a novice and is not clear on how tolink a signed upuser with his/her Profile page. 所有用户都应有一个插图页。
我赞赏一些指导! 这就是我迄今为止所做的事情:
www.un.org/Depts/DGACM/index_spanish.htm 链接
<a href=”{路边(简介,show ,$profiles->id>>link to You Profile page</a>
<>ProfilesController.php
namespace AppHttpControllers;
use AppProfile;
use IlluminateHttpRequest;
class ProfilesController extends Controller
{
public function show($id)
{
$profile = Profile::find($id);
return view( profiles.show , compact( profile ));
}
}
www.un.org/Depts/DGACM/index_spanish.htm Profile.php
namespace App;
use IlluminateDatabaseEloquentModel;
class Profile extends Model
{
public function user()
{
return $this->belongsTo( User );
}
}
routes/web.php
Route:get( pages/profiles , ProfilesController@show );
profiles.blade.php
www.un.org/Depts/DGACM/index_spanish.htm 现在,这只是一个非常简单的网页。
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>{{ $user->user_id }}</h1>
<p>{{ $user->about_me }}</p>
</body>
</html>
<>Solution
I found an easy solution and I wanted to post it here to help others who might be struggling with creating a user profile page. The below assumes you already have a users table in your database and now you want to create a profiles table and connect user ID to their profile page. Adding Laravel User Profiles
http://www.you Programme.com/watch?v=yAVvOW64c0g”rel=“nofollow noreferer” 帮助我的视频。
<><>>>>
php artisan make:migration create_profiles_table
This creates a migration file:
2019_09_22_213316_create_profiles_table
www.un.org/Depts/DGACM/index_spanish.htm 开放式移民档案和增加以下几栏:
$table->integer( user_id )->unsigned()->nullable();
$table->string( about_me )->nullable();
www.un.org/Depts/DGACM/index_spanish.htm 将这些数据输入数据库
php artisan migrate
www.un.org/Depts/DGACM/index_spanish.htm 现在,我们的数据库已经分类,我们需要建立一个控制器,控制我们的实验室如何运作。
ProfilesController.php
<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
class ProfilesController extends Controller
{
public function show($user_id)
{
$user = User::find(1);
$user_profile = Profile::info($user_id)->first();
return view( profiles.show , compact( profile , user ));
}
public function profile()
{
return $this->hasOne( Profile );
}
}
routes/web.php
Route::get( dashboard/profile , ProfilesController@show );
www.un.org/Depts/DGACM/index_spanish.htm Profile.php
<?php
namespace App;
use IlluminateDatabaseEloquentModel;
class Profile extends Model
{
public function user()
{
return $this->belongsTo( User );
}
}
Add this to User.php
public function profile()
{
return $this->hasOne( Profile );
}
.blade.php
创造你们想要的任何设计。 如果你想用用户名称,包括<代码>{> Auth:user()->name