I want to create a grand total which will calculate the whole total and return a total result.Like there are 2 rows and both rows have 2 total amount so i want to calculate the whole result and want to show it to a page
i created a total controller here is my code
class TotalController extends Controller
{
public function showTotal(){
$total = Total::all();
$sales = Sale::all();
return view('sale.index',compact('total', 'sales'));
}
public function getTotal(){
$sale = Sale::all();
$total = DB::table('sales')->where('id' , $id)->sum('total');
return view('sale.index', compact('total'));
}
}
enter code here
Here is my databases:
public function up()
{
Schema::create('totals', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('full_total');
});
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire