私はlaravel 5.1の初心者ですので、簡単に問題があります。ユーザーとuser_infoテーブルの間のlaravelの関係
私はuserテーブルとuser_infoテーブルを持っています。私はユーザーを作成する場合、私はuser_infoテーブルの別のレコードを作成したいと私はuser_infoレコードを取得したいが、私はこれをしないユーザーを取得します。
コードは以下のとおりです。
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
protected $fillable = [
'name', 'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
public function profile()
{
return $this->hasOne('Http\Models\userInfo');
}
}
これは
<?php
namespace App\Http\Models;
use Illuminate\Database\Eloquent\Model;
class userInfo extends Model
{
protected $table = 'user_info';
}
のUserInfoクラスですこれは私がこのエラーに私が間違っているの
FatalErrorException in Model.php line 740:
Class 'Http\Models\userInfo' not found
を得た
@extends('master')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-heading">Welcome</div>
<div class="panel-body">
<pre>{{ dd(Auth::user()->profile) }}</pre>
</div>
</div>
</div>
</div>
</div>
@endsection
ウェルカムページですか?
変更 '返します$ this-> hasOneの( 'のHttp \モデル\ USERINFO')によって
;' 'へ戻るます$ this-> hasOneの(のUserInfo ::クラス) ; ' – ishadif
@ishadifそれは仕事です:)。どうもありがとうございます 。私はそれらの1つのようなものを学びたいと思っています。私はユーザーモデルを作りたいのですが、どうすればいいのですか? – Hanik
あなたはユーザーモデルを作りたいと思っていますか?あなたが雄弁なモデルを扱っている場合、https://laravel.com/docs/5.2/eloquentがこれを開始します。雄弁なモデル関係のためhttps://laravel.com/docs/5.2/eloquent-relationships – ishadif