コード例 #1
0
ファイル: TicketsApi.php プロジェクト: ryankim07/testplanner
 /**
  * Update tickets from built plan
  *
  * @param $planId
  * @param $ticketsData
  * @return bool
  */
 public function updateBuiltTickets($planId, $ticketsData)
 {
     $redirect = false;
     $errorMsg = '';
     // Start transaction
     DB::beginTransaction();
     // Start tickets update
     try {
         $ticket = $this->model->where('plan_id', '=', $planId);
         $ticket->update(['tickets' => serialize($ticketsData)]);
     } catch (\Exception $e) {
         $errorMsg = $e->getMessage();
         $redirect = true;
     } catch (QueryException $e) {
         $errorMsg = $e->getErrors();
         $redirect = true;
     } catch (ModelNotFoundException $e) {
         $errorMsg = $e->getErrors();
         $redirect = true;
     }
     // Redirect if errors
     if ($redirect) {
         // Rollback
         DB::rollback();
         // Log to system
         Tools::log($errorMsg, $ticketsData);
         return false;
     }
     // Commit all changes
     DB::commit();
     return true;
 }
コード例 #2
0
ファイル: PlansApi.php プロジェクト: ryankim07/testplanner
 /**
  * Save new created plan
  *
  * @param $planData
  * @param $ticketsData
  * @param $testerData
  * @return $this|array
  */
 public function savePlan($planData, $ticketsData, $testerData)
 {
     $redirect = false;
     $errorMsg = '';
     // Start transaction
     DB::beginTransaction();
     // Start plan creation
     try {
         // Save new plan build
         $plan = $this->model->create($planData);
         $planId = $plan->id;
         if (isset($plan->id)) {
             // Save new tickets
             $this->ticketsModel->create(['plan_id' => $planId, 'tickets' => serialize($ticketsData)]);
             // Save new testers
             $assignedTesters = [];
             foreach ($testerData as $tester) {
                 if (count($tester['input-ids']) > 0 && !empty($tester['browsers'])) {
                     $this->testersModel->create(['plan_id' => $planId, 'user_id' => $tester['id'], 'browsers' => $tester['browsers']]);
                     $assignedTesters[] = $tester;
                 }
             }
         }
     } catch (\Exception $e) {
         $errorMsg = $e->getMessage();
         $redirect = true;
     } catch (QueryException $e) {
         $errorMsg = $e->getErrors();
         $redirect = true;
     } catch (ModelNotFoundException $e) {
         $errorMsg = $e->getErrors();
         $redirect = true;
     }
     // Redirect if errors
     if ($redirect) {
         // Rollback
         DB::rollback();
         // Log to system
         Tools::log($errorMsg, array_merge($planData, $ticketsData, $assignedTesters));
         return false;
     }
     // Commit all changes
     DB::commit();
     if (!$planId) {
         return false;
     }
     $planData += ['type' => 'plan', 'status' => 'new', 'plan_id' => $planId, 'testers' => $assignedTesters];
     return $planData;
 }
コード例 #3
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $ticket = Tickets::where('tk_id', $id)->first();
     return View('ticket.show', compact('ticket'));
 }