php - laravel parent relationship belongsTo -


I'm having trouble outputing the relational data, I'm trying to get the title from the productive sections non- Object property, I have tried many ways, but I can not find the desired result

  extends category product \ supernatural {public function producttype () {return $ this-> ; BelongTo ('product type', 'producttype_id'); }} Category Product Type Extended \ Supernatural {Public Function Products () {Return $ this- & gt; Hamind ("product", 'id'); }} $ Product- & gt; Product-type- & gt; The title of the title   

update

  are expanded \ Eloquent {protected $ fillable = ['keywords',' description ',' title ',' Slug ']; Protected $ table = "producttypes"; Public Function Products () {Return $ this- & gt; Has many ("product", 'product_id', 'id'); }} Expanding Class Productization \ Eloquent {protected $ table = "productvariations"; $ Fillable protected = ['product_id', 'producttype_id', 'price', 'quantity', 'discount', 'image']; Public Function Products () {Return $ this- & gt; Affiliation ('product'); }} Public Function Show ($ ID) {$ product = product :: with ('product type') - & gt; Searchoff file ($ ID) - & gt; get receive (); See Return: Creating ('products.show') - & gt; Products with ($ product); }   

Show the page

  $ product-> Product-type- & gt; Title   

You should ensure that the query object returns and not the archive. If you are using a query as long as you do not get the collection of objects, as long as you get your query - & gt; Firstorfail () If you are using 'Model :: Search,' then you get the object so that you can use the method, look at the red note at the end of that section.

You should try

  public function show ($ id) {$ product = Product :: Find ($ id); See Return: Creating ('products.show', ['product' => $ product]); }   

will then be accessible to your visual product methods

  $ product-> producttype; $ Product- & gt; Productivity // You must add this method to the product category    

Comments

Post a Comment

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -