How do I add the following filter when searching through the datatable?
How do I add the following filter when searching through the datatable?
thatduderm
Posts: 2Questions: 2Answers: 0
if ($request->first_name) {
$qb->andWhere($qb->expr()->like('`First Name`', ':first_name'))
->setParameter('first_name', '%' . str_replace('%', '', $request->first_name) . '%');
}
if ($request->middle_name) {
$qb->andWhere($qb->expr()->like('`Middle Name`', ':middle_name'))
->setParameter('middle_name', '%' . str_replace('%', '', $request->middle_name) . '%');
}
if ($request->last_name) {
$qb->andWhere($qb->expr()->like('`Last Name`', ':last_name'))
->setParameter('last_name', '%' . str_replace('%', '', $request->last_name) . '%');
}
if ($request->section) {
$qb->andWhere('`Section` = :section')
->setParameter('section', $request->section);
}
if ($request->lot_num) {
$qb->andWhere('`Lot Number` = :lot_num')
->setParameter('lot_num', $request->lot_num);
}
if ($request->dod) {
$qb->andWhere('year(`Date of Death`) = :dod')
->setParameter('dod', $request->dod);
}
if ($request->dob) {
$qb->andWhere('year(`Date of Birth`) = :dob')
->setParameter('dob', $request->dob);
}
Answers
You are going to need to elaborate on your question for me. Are you looking to replicate the code you have there with our Editor PHP libraries, or something else? If you are, then:
Would do it. See the documentation here.
Allan