亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Laravel association model problem
PHP中文網(wǎng)
PHP中文網(wǎng) 2017-05-16 16:49:25
0
2
787

Laravel association model problem

PHP中文網(wǎng)
PHP中文網(wǎng)

認(rèn)證高級(jí)PHP講師

reply all(2)
某草草

Loop

foreach ($posts as $post) {
    foreach ($post->comments as $c) {
         //do something
    }
}

As long as the relationship is set correctly, it will be looped like this, similar to nested arrays, and paging usually does not need to be written by yourself.

If you want to get the result of join, just use join instead of with.

劉奇

laravel can also directly perform joint query, for example

DB::table('orders')->join('order_items', 'order_items.order_id', '=', 'orders.id')->select('orders.id', 'orders.type', 'orders.created_at', 'order_items.amount', order_items.status')->paginate();

These are actually included in the document, please read the document carefully before using it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template