$purchases = DB::table('transactions') ->join('categories', 'transactions.category_id', '=', 'categories.id') ->where('categories.kind', '=', 1) ->sum('transactions.amount');