Accessing attribute from different model in LaravelAdd a custom attribute to a Laravel / Eloquent model on load?Laravel/Ardent - on save(), error: Relationship method must return an object of type IlluminateLaravel joining two models to User modelRelation with pivot tableHow can I establish a relationship a Model class with another model class of folder in laravel eloquent??Get Nested json array of data Laravel Eloquent model with RelationshipHow do I obtain who posted a productIn laravel i can show the product name, how to show it in vue.jsneed help in laravel Im using many many-to-many relationship ,eager laoading larvelGet SUM of a related column filtered by a field in the parent model in Laravel Eloquent
Managing heat dissipation in a magic wand
Simple Arithmetic Puzzle 7. Or is it?
List of lists elementwise greater/smaller than
Eigenvalues of the Laplace-Beltrami operator on a compact Riemannnian manifold
How can I use 400 ASA film in a Leica IIIf, which does not have options higher than 100?
How can sister protect herself from impulse purchases with a credit card?
Why does an injection from a set to a countable set imply that set is countable?
What should I wear to go and sign an employment contract?
Is there a realtime, uncut video of Saturn V ignition through tower clear?
Vehemently against code formatting
How to become an Editorial board member?
Germany rejected my entry to Schengen countries
Can dirty bird feeders make birds sick?
Why "strap-on" boosters, and how do other people say it?
Why is this python script running in background consuming 100 % CPU?
Does the fact that we can only measure the two-way speed of light undermine the axiom of invariance?
why "American-born", not "America-born"?
What quantum phenomena violate the superposition principle in electromagnetism?
Which one of these Isp's for the Dawn spacecraft is wrong?
How could Dwarves prevent sand from filling up their settlements
What does it mean for a program to be 32 or 64 bit?
Separate the element after every 2nd ',' and push into next row in bash
Ribbon Cable Cross Talk - Is there a fix after the fact?
How does the +1 Keen Composite Longbow (+2 Str) work?
Accessing attribute from different model in Laravel
Add a custom attribute to a Laravel / Eloquent model on load?Laravel/Ardent - on save(), error: Relationship method must return an object of type IlluminateLaravel joining two models to User modelRelation with pivot tableHow can I establish a relationship a Model class with another model class of folder in laravel eloquent??Get Nested json array of data Laravel Eloquent model with RelationshipHow do I obtain who posted a productIn laravel i can show the product name, how to show it in vue.jsneed help in laravel Im using many many-to-many relationship ,eager laoading larvelGet SUM of a related column filtered by a field in the parent model in Laravel Eloquent
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Please take a look at this screenshot
that is the result from this
salesItem product_id = $salesItem->product_id
and this
wh2summary =$salesItem->wh2sum
How can I access the qty_in in the long result from wh2sum? I can see the qty_in but if i do this $salesItem->wh2sum->qty_in
i get this error
my Salesitems model
protected $table = 'sales_items';
protected $fillable = [
'product_id',
'sales_id',
'product_name',
'product_code',
'price',
'rate',
'quantity',
'total_price',
];
public function wh2sum()
return $this->hasMany('AppWarehouse2StockSummaries', 'product_id', 'product_id');
my wh2sum model
class Warehouse2StockSummaries extends Model
protected $table = 'warehouse2_summary';
protected $fillable = [
'product_id',
'qty_in',
'qty_out'
];
public function product()
return $this->hasOne('AppProducts', 'id','product_id');
for my products model
class Products extends Model
{
// use SoftDeletes;
protected $fillable = [
'product_code',
'name',
'categories_id',
'wh1_limit_warning',
'wh2_limit_warning',
'price',
'selling_price',
'user_id'
];
public function warehouse2StockSummary()
return $this->hasMany('AppWarehouse2StockSummaries', 'id', 'product_id');
public function salesItem()
return $this->hasMany('AppPurchaseitems');
please help and thank you in advance!
laravel eloquent
add a comment |
Please take a look at this screenshot
that is the result from this
salesItem product_id = $salesItem->product_id
and this
wh2summary =$salesItem->wh2sum
How can I access the qty_in in the long result from wh2sum? I can see the qty_in but if i do this $salesItem->wh2sum->qty_in
i get this error
my Salesitems model
protected $table = 'sales_items';
protected $fillable = [
'product_id',
'sales_id',
'product_name',
'product_code',
'price',
'rate',
'quantity',
'total_price',
];
public function wh2sum()
return $this->hasMany('AppWarehouse2StockSummaries', 'product_id', 'product_id');
my wh2sum model
class Warehouse2StockSummaries extends Model
protected $table = 'warehouse2_summary';
protected $fillable = [
'product_id',
'qty_in',
'qty_out'
];
public function product()
return $this->hasOne('AppProducts', 'id','product_id');
for my products model
class Products extends Model
{
// use SoftDeletes;
protected $fillable = [
'product_code',
'name',
'categories_id',
'wh1_limit_warning',
'wh2_limit_warning',
'price',
'selling_price',
'user_id'
];
public function warehouse2StockSummary()
return $this->hasMany('AppWarehouse2StockSummaries', 'id', 'product_id');
public function salesItem()
return $this->hasMany('AppPurchaseitems');
please help and thank you in advance!
laravel eloquent
1
You get the error because it's$salesItem->wh2sum
collection. Does$salesItem->wh2sum[0]->qty_in
return you something?
– senty
Mar 23 at 21:48
yes it does @senty :) Thanks a lot!
– Lito
Mar 24 at 6:56
add a comment |
Please take a look at this screenshot
that is the result from this
salesItem product_id = $salesItem->product_id
and this
wh2summary =$salesItem->wh2sum
How can I access the qty_in in the long result from wh2sum? I can see the qty_in but if i do this $salesItem->wh2sum->qty_in
i get this error
my Salesitems model
protected $table = 'sales_items';
protected $fillable = [
'product_id',
'sales_id',
'product_name',
'product_code',
'price',
'rate',
'quantity',
'total_price',
];
public function wh2sum()
return $this->hasMany('AppWarehouse2StockSummaries', 'product_id', 'product_id');
my wh2sum model
class Warehouse2StockSummaries extends Model
protected $table = 'warehouse2_summary';
protected $fillable = [
'product_id',
'qty_in',
'qty_out'
];
public function product()
return $this->hasOne('AppProducts', 'id','product_id');
for my products model
class Products extends Model
{
// use SoftDeletes;
protected $fillable = [
'product_code',
'name',
'categories_id',
'wh1_limit_warning',
'wh2_limit_warning',
'price',
'selling_price',
'user_id'
];
public function warehouse2StockSummary()
return $this->hasMany('AppWarehouse2StockSummaries', 'id', 'product_id');
public function salesItem()
return $this->hasMany('AppPurchaseitems');
please help and thank you in advance!
laravel eloquent
Please take a look at this screenshot
that is the result from this
salesItem product_id = $salesItem->product_id
and this
wh2summary =$salesItem->wh2sum
How can I access the qty_in in the long result from wh2sum? I can see the qty_in but if i do this $salesItem->wh2sum->qty_in
i get this error
my Salesitems model
protected $table = 'sales_items';
protected $fillable = [
'product_id',
'sales_id',
'product_name',
'product_code',
'price',
'rate',
'quantity',
'total_price',
];
public function wh2sum()
return $this->hasMany('AppWarehouse2StockSummaries', 'product_id', 'product_id');
my wh2sum model
class Warehouse2StockSummaries extends Model
protected $table = 'warehouse2_summary';
protected $fillable = [
'product_id',
'qty_in',
'qty_out'
];
public function product()
return $this->hasOne('AppProducts', 'id','product_id');
for my products model
class Products extends Model
{
// use SoftDeletes;
protected $fillable = [
'product_code',
'name',
'categories_id',
'wh1_limit_warning',
'wh2_limit_warning',
'price',
'selling_price',
'user_id'
];
public function warehouse2StockSummary()
return $this->hasMany('AppWarehouse2StockSummaries', 'id', 'product_id');
public function salesItem()
return $this->hasMany('AppPurchaseitems');
please help and thank you in advance!
laravel eloquent
laravel eloquent
edited Mar 23 at 19:50
Lito
asked Mar 23 at 19:25
LitoLito
124110
124110
1
You get the error because it's$salesItem->wh2sum
collection. Does$salesItem->wh2sum[0]->qty_in
return you something?
– senty
Mar 23 at 21:48
yes it does @senty :) Thanks a lot!
– Lito
Mar 24 at 6:56
add a comment |
1
You get the error because it's$salesItem->wh2sum
collection. Does$salesItem->wh2sum[0]->qty_in
return you something?
– senty
Mar 23 at 21:48
yes it does @senty :) Thanks a lot!
– Lito
Mar 24 at 6:56
1
1
You get the error because it's
$salesItem->wh2sum
collection. Does $salesItem->wh2sum[0]->qty_in
return you something?– senty
Mar 23 at 21:48
You get the error because it's
$salesItem->wh2sum
collection. Does $salesItem->wh2sum[0]->qty_in
return you something?– senty
Mar 23 at 21:48
yes it does @senty :) Thanks a lot!
– Lito
Mar 24 at 6:56
yes it does @senty :) Thanks a lot!
– Lito
Mar 24 at 6:56
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317527%2faccessing-attribute-from-different-model-in-laravel%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317527%2faccessing-attribute-from-different-model-in-laravel%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You get the error because it's
$salesItem->wh2sum
collection. Does$salesItem->wh2sum[0]->qty_in
return you something?– senty
Mar 23 at 21:48
yes it does @senty :) Thanks a lot!
– Lito
Mar 24 at 6:56