I Have two table named products and product_images. I want to upload multiple image for a particular product. My table structure are below
products :
p_id
name
.....
product_images :
img_id
name
url
p_id
is there any way to do it with Grocery CRUD ???
Related
I have a cartitem table I where there are two field named vendor_id and cookie_identifier I want to retrieve a specific cookie identifiers records group by vendor id..how can it possible. I write a query which is given bellow it does not work
$addTocartItems = CartItem::groupBy('vendor_id')
->where('cookie_identifier', $getCookieIdentifier)
->get();
I have 3 tables name like "product" , "user", "product_type" so in my case user and product_type having many to many relationship and user and product having one to many relationship and product and product_type having one to one relationship.
I create one pivot table for user and product_type. inside that pivot table, I added one more column for description. so in product listing page I need to display description from that pivot table.
My code look like this:
Product::with('user)->with('product_type')->get();
To get extra fields from pivot table you need to use withPivot in function of your model Like this:
public function product_type() {
return $this->belongsToMany('App\Product','product_type','product_id','user_id')->withPivot('column1', 'column2');
}
you may also refer laravel docs for it:
https://laravel.com/docs/5.7/eloquent-relationships
I have some relations on my db and I'm very confused how I can do this with eloquent. I have three tables that I want to connect eachother.
Users table - Contains users and these users have 3 roles (customers, managers, employee etc.) And users with manager role have more than one customers or employes.
Comps table - Contains company infos, (customers company, manager company, employee company etc.) employes can have same company.
Images table- this table contains user profile images, comp logo images etc.
I want to take a user's customers informations with images. I made the following relation between comp table and user table in User model. But I can't take comp image with this relation.
public function customers() {
return $this->belongsToMany('App\Comp', 'user_customers', 'user_id', 'comp_id');
}
user_customers table is a relation table which shows which user is a customer of which user.
user_customers table:
id,
user_id,
customer_user_id,
comp_id,
How can I get comp's logo image?
Hi I have 3 tables "temp_quotes", "quotes" and "quote_items"
Every quote generated goes to the "temp_quotes" table at first.
At the end of my multi-step form I need the following:
1- Receive all the quotes from the "temp_quotes" table, send it to the "quote_items" table and delete it from the "temp_quotes" table
2- Generate a new entry in the "quotes" table referencing the "users" table and
the "quote_items" table
Here is all the data and how needs to be save/removed on the tables:
temp_quotes Table
ID
BRAND
MODEL
YEAR
quotes Table:
ID
USER_ID
QUOTE_ID
quote_items Table:
ID
QUOTE_ID
BRAND
MODEL
YEAR
Any help will be appreciated.
I have 3 tables
categories
id
name
categories_product
id
category_id
product_id
and a product table
products
id
name
I want products based on catergori_id, how kan i do that with laravel Eloquent?
Simple as this:
Product::whereCategori_id($category)->get();