예제 #1
0
 public function search(Request $request)
 {
     $search = $request->search;
     $contacts = [];
     if (!empty($search)) {
         $contacts = Contact::where('name', 'like', "%{$search}%")->orWhere('nickname', 'like', "%{$search}%")->get();
     }
     return view('agenda', compact('contacts'));
 }
 public static function getContacts($type = null, $optionalChoice = false)
 {
     $contacts = Contact::where('contacts.company_id', Auth::user()['company_id']);
     if (!empty($type)) {
         $contacts = $contacts->join('types', 'contacts.contact_type_id', '=', 'types.id')->where('types.name', $type);
     }
     $contacts = $contacts->lists('contacts.name', 'contacts.id');
     if ($optionalChoice) {
         $contacts->prepend("", "");
     }
     return $contacts;
 }