Laravel yajra-datatable select 在数据表中

Laravel yajra-datatable select where in datatable

我想 select 数据表中 inst_id = ? 的所有行, 这是我的代码

if(request()->ajax()) {
        return datatables()->of(Domain::select([
            'id', 'domain', 'logo', 'description', 'created_at'
        ]))
        ->addIndexColumn()
        ->addColumn('action', function($data){

               $btn = '<a href="" data-toggle="tooltip" data-original-title="Edit" class="edit btn btn-primary btn-sm">Edit</a>';

               $btn = $btn.' <a href="javascript:void(0)" data-toggle="tooltip"  data-id="" data-original-title="Delete" class="btn btn-danger btn-sm deleteTodo">Delete</a>';

                return $btn;
        })
        ->rawColumns(['action'])
        ->make(true);
    }
    return view('functions/study/domain');

您可以使用基本查询添加任何您想要的查询

$id = 1;
if(request()->ajax()) {
        return datatables()->of(
            Domain::select([
                'id', 'domain', 'logo', 'description', 'created_at'
            ])
            ->where('inst_id', $id)
        )
        ->addIndexColumn()
        ->addColumn('action', function($data){

               $btn = '<a href="" data-toggle="tooltip" data-original-title="Edit" class="edit btn btn-primary btn-sm">Edit</a>';

               $btn = $btn.' <a href="javascript:void(0)" data-toggle="tooltip"  data-id="" data-original-title="Delete" class="btn btn-danger btn-sm deleteTodo">Delete</a>';

                return $btn;
        })
        ->rawColumns(['action'])
        ->make(true);
    }
    return view('functions/study/domain');