I need to show information of checkout_pages table that has two foreign keys that needs to be validated.
users
- id
products
- id
- user_id
checkout_pages
- id
- user_id
- product_id
The product has an owner (products.user_id), the checkout_pages has relationships between users and products. I need to show the information about checkout_pages for the specific user and specific product (not necessarily the product owner).
I make some code, but it only validate the checkout_pages.product_id and I can't make it validate the checkout_pages.user_id.
Model Product
public function checkout_pages(){
return $this->hasMany('App\CheckoutPage');
}
ProductController
public function index()
{
$products = Product::all()->where('user_id', \Auth::user()->id);
return view('products.index', compact('products'));
}
Edit
- User can have multiple checkout_pages, but of different products
- This is the code I have now, I know it isn't validating the checkout_pages table, but looking through the Laravel Doc I couldn't find an answer
- I need to get this infos from checkout_pages in the ProductController.