本文整理汇总了PHP中app\Contact::setSearchable方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::setSearchable方法的具体用法?PHP Contact::setSearchable怎么用?PHP Contact::setSearchable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Contact
的用法示例。
在下文中一共展示了Contact::setSearchable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchablecontact
public function searchablecontact(Request $request)
{
$type = 1;
$tri = 'none';
$actif = 'contact';
$contact = new Contact();
if (isset($request->nom) && !empty($request->nom)) {
$contact = new Contact();
$contact->setSearchable(['columns' => ['nom_contact' => 10, 'prenoms_contact' => 10]]);
$query = $request->nom;
$mode = 'nom';
$tri = 'none';
$contact = $contact->search($query)->where('etat', 1)->orderBy('nom_contact', 'asc')->get();
} elseif ($request->tel && !empty($request->tel)) {
$contact->setSearchable(['columns' => ['tel_contact' => 10]]);
$query = $request->tel;
$mode = 'tel';
$tri = 'none';
$contact = $contact->search($query)->where('etat', 1)->orderBy('nom_contact', 'asc')->get();
} elseif ($request->adresse && !empty($request->adresse)) {
$contact->setSearchable(['columns' => ['adresse_contact' => 30]]);
$query = $request->adresse;
$mode = 'adresse';
$tri = 'none';
$contact = $contact->search($query)->where('etat', 1)->orderBy('nom_contact', 'asc')->get();
}
// Tri des résultats de la recherche contact
if (isset($_GET['sort'])) {
$query = $_GET['query'];
// Tri sur recherche par nom
if ($_GET['mode'] == 'nom') {
$mode = 'nom';
if ($_GET['sort'] == 'pays_clt') {
$tri = 'pays';
$contact->setSearchable(['columns' => ['nom_contact' => 10, 'prenoms_contact' => 10]]);
$contact = $contact->search($query)->where('etat', 1)->get();
foreach ($contact as $key => $value) {
var_dump($value->nom_contact . ' ' . $value->prenoms_contact);
}
dd();
return view('contact.contact', compact('actif', 'contact', 'type', 'tri', 'query', 'mode'));
} elseif ($_GET['sort'] == 'ville_siege_clt') {
$tri = "ville";
} elseif ($_GET['sort'] == 'statut') {
$tri = "client";
} elseif ($_GET['sort'] == 'nom_clt') {
$tri = "alpha";
} elseif ($_GET['sort'] == 'created_at') {
$tri = "ajout";
} elseif ($_GET['sort'] == 'updated_at') {
$tri = "modif";
} elseif ($_GET['sort'] == 'notes') {
$note = DB::table('societes')->join('contacts', 'societes.id', '=', 'contacts.societe_id')->join('notes', 'contacts.id', '=', 'notes.contact_id')->select('societes.*', 'notes.*')->where('societes.etat', 1)->get();
$societe = $societe->search($query)->sortable()->where('etat', 1)->get();
$tri = 'notes';
// Tri des contacts sans note
foreach ($societes as $key => $value) {
$exist = 0;
foreach ($note as $keyn => $valuen) {
if ($value->nom_clt == $valuen->nom_clt) {
$exist = 1;
}
}
if ($exist == 0) {
$societe[] = $value;
}
}
}
$contact->setSearchable(['columns' => ['nom_contact' => 10, 'prenoms_contact' => 10]]);
$contact = $contact->search($query)->sortable()->where('etat', 1)->get();
}
// Tri sur recherche par adresse
if ($_GET['mode'] == 'adresse') {
$mode = 'adresse';
if ($_GET['sort'] == 'pays_clt') {
$tri = 'pays';
} elseif ($_GET['sort'] == 'ville_siege_clt') {
$tri = "ville";
} elseif ($_GET['sort'] == 'statut') {
$tri = "client";
} elseif ($_GET['sort'] == 'nom_clt') {
$tri = "alpha";
} elseif ($_GET['sort'] == 'created_at') {
$tri = "ajout";
} elseif ($_GET['sort'] == 'updated_at') {
$tri = "modif";
} elseif ($_GET['sort'] == 'notes') {
$tri = "notes";
}
$societe->setSearchable(['columns' => ['adresse_siege_clt' => 10]]);
$contact = $contact->search($query)->sortable()->where('etat', 1)->get();
}
}
return view('contact.contact', compact('actif', 'contact', 'type', 'tri', 'query', 'mode'));
}