public static function namaCalon($id) { $cc = CalonCustomer::find($id); if (!$cc) { return false; } return $cc->nama; }
public function calonCustomerJson() { $term = Input::get('term'); $data = CalonCustomer::distinct()->select('nama', 'id')->where('nama', 'LIKE', '%' . $term . '%')->groupBy('id')->take(15)->get(); $result = []; foreach ($data as $d) { if (strpos(Str::lower($d), $term) !== false) { $result[] = ['value' => $d->nama, 'id' => $d->id]; } } return Response::json($result); }
public function search() { $keyword = Input::get('keyword'); if (!$keyword) { return false; } $matches = ['alamat' => '%' . $keyword . '%', 'telp' => '%' . $keyword . '%']; $barangs = Barang::where('nama', 'LIKE', '%' . $keyword . '%')->paginate(10); $customers = Customer::where('nama', 'LIKE', '%' . $keyword . '%')->orWhere('alamat', 'LIKE', '%' . $keyword . '%')->orWhere('telp', 'LIKE', '%' . $keyword . '%')->paginate(10); $penjualans = Penjualan::where('nama', 'LIKE', '%' . $keyword . '%')->orWhere('alamat', 'LIKE', '%' . $keyword . '%')->orWhere('telp', 'LIKE', '%' . $keyword . '%')->orWhere('id', 'LIKE', '%' . $keyword . '%')->get(); $calonCustomer = CalonCustomer::where('nama', '%' . $keyword . '%')->orWhere('alamat', 'LIKE', '%' . $keyword . '%')->orWhere('telp', 'LIKE', '%' . $keyword . '%')->get(); return View::make('search', compact(array('keyword', 'barangs', 'customers', 'penjualans', 'calonCustomer'))); }
/** * Remove the specified caloncustomer from storage. * * @param int $id * @return Response */ public function destroy($id) { CalonCustomer::destroy($id); Followup::where('calon_customer_id', '=', $id)->delete(); return Redirect::route('admin.calon_customer.index')->with('message', 'berhasil hapus calon customer'); }