Download Laravel-xCRUD Integration Full Code that includes this full demo
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class xSubselectController extends Controller
{
public function index()
{
$xcrud = Xcrud_get_instance();
$xcrud->table('customers');
$xcrud->columns('customerName,city,creditLimit,Paid,Profit'); // specify only some columns
$xcrud->subselect('Paid','SELECT SUM(amount) FROM payments WHERE customerNumber = {customerNumber}'); // other table
$xcrud->subselect('Profit','{Paid}-{creditLimit}'); // current table
$xcrud->sum('creditLimit,Paid,Profit'); // sum row(), receives data from full table (ignores pagination)
$xcrud->change_type('Profit','price','0',array('prefix'=>'$')); // number format
$render = $xcrud->render();
return view('xcrud_simple', ['render' => $render]);
}
}
# | Customername | City | Creditlimit | Paid | Profit | |
---|---|---|---|---|---|---|
1 | Signal Gift Stores | Las Vegas | 71800 | $0.00 | View Edit Remove | |
2 | Australian Collectors, Co.343434 | Melbourne | 117300334 | $0.00 | View Edit Remove | |
3 | La Rochelle Gifts mzgs | Nantes | 118200 | $0.00 | View Edit Remove | |
4 | Baane Mini Imports | Stavern | 81700 | $0.00 | View Edit Remove | |
5 | Mini Gifts Distributors Ltd. | San Rafael | 210500 | $0.00 | View Edit Remove | |
6 | Zbyszek Zbyszek Piestrzeniewicz | Warszawa | 1230 | $0.00 | View Edit Remove | |
7 | Blauer See Auto, Co. | Frankfurt | 59700 | $0.00 | View Edit Remove | |
8 | Mini Wheels Co. | San Francisco | 64600 | $0.00 | View Edit Remove | |
9 | Land of Toys Inc. | NYC | 114900 | $0.00 | View Edit Remove | |
10 | Euro+ Shopping Channel | Madrid | 227600 | 24625124284.39 | $24,624,896,684.39 | View Edit Remove |
Σ | 125417664.12 | 24631781137.2534 | $24,624,386,437.13 |