mercredi 28 juin 2017

eloquent relation not working on live server

I have two tables one is user and other is profile. one user can have one profile. This relation works perfectly on local server but when i upload it on live server the relations are not working not just user and profile but other relations also. here is my laravel model code for profile and user.

class Profile extends Model
{
  protected $fillable = ['user_id','fname','mname','lname',
    'birthdate','country','address','phone', 'image'];

  protected $hidden = ['user_id'];

  public $timestamps = false;

  public function users() {
    return $this->belongsTo('App\User', 'id');
  }
}

User model

class User extends Authenticatable
{
  protected $fillable = [
    'name', 'email', 'password', 'email_token'
  ];

  protected $hidden = [
    'password', 'remember_token', 'email_token'
  ];

  public function users(){
    return $this->hasOne('App\Profile', 'user_id');
  }
}

Here how i am trying to get profile data from login user in controller

Auth::user()->users->image



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2sTGY3X
via IFTTT

Aucun commentaire:

Enregistrer un commentaire