dimanche 12 février 2017

laravel datatable new custom column of count

trying to make in datatable with custom column which counts matches of types and models my datatable php code looks like this:

$table1= DB::table('table1')
    ->select([
        'table1.*',
        'table2.name as model',
    ])
    ->join('table2', 'table1.model_id', '=', 'table2.id')
    ->whereNull('trades.deleted_at');

return Datatables::of($trades)
->addColumn('matches', function($trade){

}       
->make(true);

table1 have collumn type (offer/request) and model_id which is coming from table2.. I have all data and datatable working..

just now want to add one more column like matches which would return count of matches in this case:

if table1.type = offer and table1.model_id = 3 need to search all type requests where same model_id

any suggestions?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2kgHmH1
via IFTTT

Aucun commentaire:

Enregistrer un commentaire