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;








0















Please take a look at this screenshot



enter image description here



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



enter image description here



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!










share|improve this question



















  • 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

















0















Please take a look at this screenshot



enter image description here



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



enter image description here



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!










share|improve this question



















  • 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













0












0








0








Please take a look at this screenshot



enter image description here



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



enter image description here



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!










share|improve this question
















Please take a look at this screenshot



enter image description here



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



enter image description here



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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












  • 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












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
);



);













draft saved

draft discarded


















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















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현