You have the following:
$product = Product::with('images', 'brand') ->select($fields) ->where('display', 1) ->find($id);
You get null for brand , and this may be because you have certain fields and most likely you did not select foreing_key from the products table, which creates a link to brand , so if your products table contains a foreign_key table (maybe brand_id ) of the brand table, then you must select this foreign_key from the products table. Therefore, add only foreign_key/brand_id to the $fields variable. Without a relationship linker ( FK ) key, the brand will not be loaded.
source share