Owl\Repositories\Fluent\ItemRepository::getByOpenItemIdWithComment PHP Method

getByOpenItemIdWithComment() public method

Get a item by open item id with comments.
public getByOpenItemIdWithComment ( integer $open_item_id ) : stdClass | null
$open_item_id integer
return stdClass | null
    public function getByOpenItemIdWithComment($open_item_id)
    {
        // @FIXME
        $item = \DB::table('items')->where('open_item_id', $open_item_id)->first();
        if (is_null($item)) {
            return null;
        }
        $item->user = \DB::table('users')->where('id', $item->user_id)->first();
        $comments = \DB::table('comments')->where('item_id', $item->id)->get();
        $i = 0;
        foreach ($comments as $comment) {
            $comments[$i]->user = \DB::table('users')->where('id', $comment->user_id)->first();
            $i++;
        }
        $item->comment = $comments;
        return $item;
    }