Hi
I am currently working on creating a user table/model to a user however because i have been following laravel 4 tutorials i have become stuck. (i have only just started using laravel recently)
below is my code
class CreateProfilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::Create('profiles', function(Blueprint $table) {
$table->integer('user_id')->unsigned()->nullable();
$table->foreign('user_id')->references('id')->on('users');
$table->date('birthday');
$table->string('image');
$table->string('housenumber')->nullable();
$table->string('addressline1')->nullable();
$table->string('addressline2')->nullable();
$table->string('postcode')->nullable();
$table->string('county')->nullable();
$table->string('country')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::drop('profiles');
}
}
routes.php
//Load User Profile
Route::get('dashboard/profile', 'ProfilesController@show');
profilesController.php
public function show($id)
{
//
$user = User::whereId($id)->
return view('dashboard.profiles.show')->with(['user' => $user]);
// dd($user->toArray());
}
user.php
public function profile()
{
return $this->hasOne('Profile');
}
profile.php
public function user()
{
return $this->belongsTo('User');
}
}
user.php
public function profile()
{
return $this->hasOne('Profile');
}
how do i go about grabbing the profile for a particular used id and displaying it in the a view? Basically I am not sure what to do when in the pages controller to show a profile for a particular user or if i have even set it up correctly.
Any help or guidance appreciated
Thanks