public function getIndex() { if (session('level') > 3) { $cargas = Cargas::where('procesado', '=', true)->orderBy('created_at')->get(); } else { $cargas = Cargas::where('procesado', '=', true)->where('user_id', '=', session('id'))->orderBy('created_at')->get(); } return view('cargas.todos', compact('cargas')); }
public function postFecha(Request $request) { $mes = $request->mes; $anio = $request->anio; $id = Auth::user()->id; $carga = Cargas::where('user_id', '=', $id)->where('procesado', '=', false)->first(); if ($carga->sat()->count() > 0 || $carga->empresa()->count() > 0) { return response()->json(['mes' => $carga->mes, 'anio' => $carga->anio], 200); } if ($mes || $mes == 0) { $carga->mes = $mes; } if ($anio) { $carga->anio = $anio; } $carga->save(); return response()->json(['mes' => $carga->mes, 'anio' => $carga->anio], 200); }