lundi 1 août 2016

laravel relationship between user and user_info tables

i'm newbie on laravel 5.1 so i have an easy problem.

i have user table and user_info table. if i create a user, i want to create another record for user_info table and if i get user then i want to get user_info record but i don't do this.

codes are below.

<?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');
    }
}

this is userInfo class

<?php

namespace App\Http\Models;

use Illuminate\Database\Eloquent\Model;

class userInfo extends Model
{
    protected $table = 'user_info';
}

this is welcome page

@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></pre>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

i got this error

FatalErrorException in Model.php line 740:
Class 'Http\Models\userInfo' not found

where am I doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire