Esempio n. 1
0
 /**
  * Save the changes.
  *
  * @param Issue $issue
  *
  * @return bool
  */
 public function persist(Issue $issue)
 {
     $issue->user_id = $issue->exists ? $issue->user_id : Auth::id();
     $issue->title = $this->input('title', $issue->title);
     $issue->description = $this->input('description', $issue->description);
     $issue->occurred_at = $this->input('occurred_at', $issue->occurred_at);
     if ($issue->save()) {
         // Check if we have any files to upload and attach.
         if (count($this->files) > 0) {
             foreach ($this->file('files') as $file) {
                 if (!is_null($file)) {
                     $issue->uploadFile($file);
                 }
             }
         }
         // Sync the issues labels.
         $labels = $this->input('labels', []);
         if (is_array($labels)) {
             $issue->labels()->sync($labels);
         }
         // Sync the issues users.
         $users = $this->input('users', []);
         if (is_array($users)) {
             $issue->users()->sync($users);
         }
         return true;
     }
     return false;
 }
Esempio n. 2
0
 /**
  * Creates a new Issue model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Issue();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 3
0
 /**
  * Save the changes.
  *
  * @param Issue $issue
  *
  * @return bool
  */
 public function persist(Issue $issue)
 {
     if ($issue->isOpen()) {
         $issue->closed = true;
         $issue->closed_at = $issue->freshTimestamp();
         $issue->closed_by_user_id = auth()->id();
         return $issue->save();
     }
     return false;
 }
Esempio n. 4
0
 /**
  * Save the changes.
  *
  * @param Issue $issue
  *
  * @return bool
  */
 public function persist(Issue $issue)
 {
     if ($issue->isClosed()) {
         $issue->closed = false;
         $issue->closed_at = null;
         $issue->closed_by_user_id = null;
         return $issue->save();
     }
     return false;
 }
Esempio n. 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $rules = array('receivers_name' => 'required', 'quantity_issued' => 'required|integer', 'batch_no' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return redirect()->to('issue.index')->withErrors($validator);
     } else {
         // store
         $issue = new Issue();
         $issue->receipt_id = Input::get('batch_no');
         $issue->topup_request_id = Input::get('topup_request_id');
         $issue->quantity_issued = Input::get('quantity_issued');
         $issue->issued_to = Input::get('receivers_name');
         $issue->user_id = Auth::user()->id;
         $issue->remarks = Input::get('remarks');
         try {
             $issue->save();
             return redirect()->to('issue.index')->with('message', trans('messages.commodity-succesfully-added'));
         } catch (QueryException $e) {
             Log::error($e);
         }
     }
 }
Esempio n. 6
0
 public function actionCreateEmpty()
 {
     $model = new Issue();
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         $this->saveChecklist($model);
         $this->sendMessage($model);
         return $this->redirect(['/issue/index', 'id' => $model->project_id]);
     }
     $checklistItems[] = new IssueChecklist();
     return $this->render('createEmpty', ['model' => $model, 'checklistItems' => $checklistItems]);
 }