Exemplo n.º 1
0
 private function updateId()
 {
     $compcats = Compcat::all();
     foreach ($compcats as $compcat) {
         $new = Compcat::find($compcat->id);
         $new->id = Compcat::get_uid();
         $new->save();
     }
 }
Exemplo n.º 2
0
 public function search(Request $request)
 {
     $arr = [];
     if ($request->has('q')) {
         $q = $request->input('q');
         $branchid = $request->input('branchid');
         $components = Component::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($components as $component) {
             array_push($arr, ['table' => 'component', 'item' => $component->descriptor, 'id' => strtolower($component->id)]);
         }
         $compcats = Compcat::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($compcats as $compcat) {
             array_push($arr, ['table' => 'compcat', 'item' => $compcat->descriptor, 'id' => strtolower($compcat->id)]);
         }
         $expenses = Expense::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($expenses as $expense) {
             array_push($arr, ['table' => 'expense', 'item' => $expense->descriptor, 'id' => strtolower($expense->id)]);
         }
         $expscats = Expscat::where('descriptor', 'like', '%' . $q . '%')->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($expscats as $expscat) {
             array_push($arr, ['table' => 'expscat', 'item' => $expscat->descriptor, 'id' => strtolower($expscat->id)]);
         }
         $suppliers = Supplier::where('descriptor', 'like', '%' . $q . '%')->where('branchid', $branchid)->orderBy('descriptor')->get(['descriptor', 'id']);
         foreach ($suppliers as $supplier) {
             array_push($arr, ['table' => 'supplier', 'item' => $supplier->descriptor, 'id' => strtolower($supplier->id)]);
         }
         //$payments = ['110A573E855511E68FF47E841D02B37D'=>'cash', '19ADA60B855511E68FF47E841D02B37D'=>'check'];
         $payments = ['c' => 'cash', 'k' => 'check'];
         $s = preg_grep("/^" . strtolower($q) . "/", $payments);
         if ($s) {
             $k = key($s);
             array_push($arr, ['table' => 'payment', 'item' => ucwords($s[$k]), 'id' => strtolower($k)]);
         }
     }
     //return $arr;
     if ($request->ajax()) {
         return $arr;
     } else {
         return abort('404');
     }
 }