public function crearPlanilla($viaje_id, $conductor_id) { $central = Conductor::find($conductor_id)->first(); $planilla = new Planilla(); $planilla->viaje_id = $viaje_id; $planilla->central_id = $central->central_id; $planilla->numero_planilla = $this->generarNumeroPlanilla($conductor_id); if ($planilla->save()) { return JsonResponse::create('Se creo la planilla correctamente'); } else { return JsonResponse::create('Error al crear la planilla'); } }
public function crearPlanillaNormal($viaje_id, $central_id, $total) { $planilla = new Planilla(); $planilla->viaje_id = $viaje_id; $planilla->central_id = $central_id; $planilla->total = $total; $planilla->numero_planilla = $this->generarNumeroPlanillaNormal($central_id); if ($planilla->save()) { $planilla['tipo'] = 'normal'; return $planilla; } else { $planilla->delete(); return JsonResponse::create('Error al crear la planilla'); } }