Level 73
You can use whereBetween and provide the two dates:
$stockSummary1=\DB::table('stocks')
->select('products.name','stocks.pid','stocks.qty as stockin','loadings.qty as issued')
->join('products','products.id', '=', 'stocks.pid')
->join('loadings','loadings.pid','=','products.id')
->whereBetween('stocks.created_at', [ today()->subDay(), today()] )
->groupby('products.name','stocks.pid','stockin','issued')
->groupby('products.name','pid','stockin')
->get();
If that's the only difference that you have between the queries.