如何获取给定的Type = Car品牌的Makes名称? [Laravel]

时间:2018-07-22 09:45:22

标签: php mysql laravel join laravel-5

我在Laravel中有以下表格。

品牌

id  name
1   honda
2   suzuki

类型

id  name
1   cars
2   bikes

制造

id name               type_id
1  honda amaze        1
2  honda shine        2
3  suzuki baleno      1
4  suzuki racing      2

brand_make

id  brand_id   make_id
1    1         1
2    1         2
3    2         3
4    2         4

brand_type

id  brand_id   type_id
1    1         1
2    1         2
3    2         1
4    2         2

现在从上表中如何获取所有具有type_id = 1的品牌商标?例如。给我所有的本田汽车

2 个答案:

答案 0 :(得分:0)

var clientContext;
var website;

// Make sure the SharePoint script file 'sp.js' is loaded before your
// code runs.
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);

// Create an instance of the current context and get the website.
function sharePointReady() {
    clientContext = SP.ClientContext.get_current();
    website = clientContext.get_web();

    clientContext.load(website);
    clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
}
function onRequestSucceeded() {
    alert('URL of the website: ' + website.get_url());
}
function onRequestFailed(sender, args) {
    alert('Error: ' + args.get_message());
}

答案 1 :(得分:0)

DB::table('brands')->join('brand_makes')->on('brands.id', '=, 'brand_makes.brand_id')
->join('makes')->on('makes.id', '=', 'brand_makes.make_id')
->join('types')->on('types.id', '=', 'makes.type_id)
->select('makes.name')
->where('types.name', 'cars')
->where('brands.name', 'yourRequiredBrand')
->get()