= Thanks For Help
= Hello friends Why hasMany doesn't work after i uploaded project in production with user my code
= Everything Works In local
= Note = I created these tables in production manually without migration what i forget
// User.php
public function ocazioncart()
{
return $this->hasMany('App\Models\OcazionCart', 'user_id', 'id');
}
// OcazionCart.php
public function user()
{
return $this->belongsTo('App\User');
}
// table fields
$table->increments('id');
$table->unsignedInteger('user_id'); // auth user id
$table->morphs('cartable'); // with product model
$table->timestamps();
// NOTES
1- auth()->user()->ocazioncart->count(); // Work in local Only
2- auth()->user()->ocazioncart // In production return Null so with ->count blowup page
3- OcazionCart::where('user_id',auth()->user()->id)->get(); // Works In production
4 - I created OcazionCart table Manually in host what i missed
// Thanks For Help
Why do not you structure the migration in your local environment and define the relationship in your migration file and then update your repository in production?
This way you keep your changes versioned and tested.
@EDWARDPALEN - Hello mr edwardpalen thanks for trying help . i local environment everything works 100% but in production code same structure same but dosent work
Only This Syntax works
OcazionCart::where('user_id',auth()->user()->id)->get(); // Works In production
I created these tables in production manually without migration what i forget
@respect editing code directly in production is a terrible idea. I suggest you write the code in your local environment and test it before moving/deploying it to production.
@EDWARDPALEN - Hell0 Mr. edwardpalen I using godaddy and already finsihed the rest of application but this realthionsip only do the error i dont know why
@TOKOIWESLEY - Hello MR.tokoiwesley there are many data in production version and finsihed model no need to run migration there may be lose the table data
@RESPECT - Then maybe you are using migrations the wrong way. They are meant exactly for this type of job in the first place - easily modifying tables in production.