Thursday, April 26, 2018

Unable to do laravel relationships using laravel 5.5 - development

Unable to do laravel relationships using laravel 5.5

I am facing issue regarding storing ids and display their values from two different table i have 1 table business_master and other table is page_master i have combine business_name column with page_url column which are available on page_master table if i add my business and page first time its successfully combine these two values as one business can have many pages and if i only add page 2nd time i am unable to see business_url with page_url column.

My Page Model:

class PageList extends Model
      {
protected $table = 'page_master';


protected $fillable = ['business_id', 'page_url', 'page_name'];


public function business()
{
    return $this->hasOne('AppBusiness','business_id');
}

   }

and in my view:

 <td>.spikesales.io/</td>

This is my first time out if i add business_url and page_url

    hussain.spikesales.io/house

and then if i add only page the out put is something like that

   .spikesales.io/hello

one business can have many page it should attach business_ url also but i am unable to find solution:

Any help will be highly appreciated!

    public function pageListHere()
{
    $list = PageList::all();
    return view('page-list',compact('list'));
}



from Laravel Questions and Answers https://laravelquestions.com/php/unable-to-do-laravel-relationships-using-laravel-5-5/
via Lzo Media

No comments:

Post a Comment