I have a table of fabrics that is associated with one brand and one season. The launch App\fabrics::with('brand', 'season')->get()will deliver me all the fabrics and their brand and season information, which is in order (see below).
I want to get fabrics based on the season identifier. I tried:
App\fabrics::with('brand', 'season')->where('season.id', '1')->get()
but it does not work.
Column not found: 1054 Unknown column 'season.id' in 'where clause' (SQL: select * from `fabrics` where `season`.`id` = 1)'
Is it possible to get tissues and filter according to one of my relationships?
Obviously, I can get fabrics from the App :: season seasonal model, but I was wondering if it could be reached from her parent model.
All information from App \ fabrics :: with ('brand', 'season') → get ()
>>> App\fabrics::with('brand', 'season')->get()
=> Illuminate\Database\Eloquent\Collection {
all: [
App\Fabrics {
id: 1,
fabric_code: "GMAN01",
fabric_design: "ANODA",
fabric_price_group: "I",
fabric_retail_price: "27.00",
fabric_trade_price: null,
fabric_width: 141,
fabric_pattern_repeat: 1,
fabric_fiber: "48% POLYESTER 44% COTTON 8% VISCOSE",
fabric_online: 1,
fabric_available: 1,
fabric_meters_remaining: 256.78,
fabric_virutal_meters_remaining: 216.28,
created_at: "2016-12-02 10:52:09",
updated_at: "2016-12-02 13:08:07",
brand_id: 1,
season_id: 1,
brand: App\Brands {
id: 1,
brand_name: "*****",
created_at: "2016-12-02 11:36:10",
updated_at: "2016-12-02 11:36:10",
},
season: App\Seasons {
id: 1,
season_name: "Autumn/Winter 2016",
season_code: "AW16",
created_at: "2016-12-02 13:07:50",
updated_at: "2016-12-02 13:07:50",
},
},
App\Fabrics {
id: 2,
fabric_code: "GMAN02",
fabric_design: "ANODA",
fabric_price_group: "I",
fabric_retail_price: "27.00",
fabric_trade_price: null,
fabric_width: 141,
fabric_pattern_repeat: 1,
fabric_fiber: "48% POLYESTER 44% COTTON 8% VISCOSE",
fabric_online: 1,
fabric_available: 0,
fabric_meters_remaining: 20.0,
fabric_virutal_meters_remaining: 17.0,
created_at: "2016-12-02 10:52:09",
updated_at: "2016-12-02 13:14:56",
brand_id: 2,
season_id: 1,
brand: App\Brands {
id: 2,
brand_name: "*****",
created_at: "2016-12-02 11:36:10",
updated_at: "2016-12-02 11:36:10",
},
season: App\Seasons {
},
App\Fabrics {
id: 3,
fabric_code: "JBBU01",
fabric_design: "BURDOCK",
fabric_price_group: "D",
fabric_retail_price: "16.00",
fabric_trade_price: null,
fabric_width: 140,
fabric_pattern_repeat: 64,
fabric_fiber: "100% COTTON",
fabric_online: 0,
fabric_available: 1,
fabric_meters_remaining: 856.1,
fabric_virutal_meters_remaining: 856.1,
created_at: "2016-12-02 10:52:09",
updated_at: "2016-12-02 13:08:13",
brand_id: 3,
season_id: 4,
brand: App\Brands {
id: 3,
brand_name: "*****",
created_at: "2016-12-02 11:36:10",
updated_at: "2016-12-02 11:36:10",
},
season: App\Seasons {
id: 4,
season_name: "Spring/Summer 2015",
season_code: "SS15",
created_at: "2016-12-02 13:07:50",
updated_at: "2016-12-02 13:07:50",
},
},
],
}