Example #1
0
 public function saveCredit($files, $user)
 {
     $data = $this->prepareData($this->data);
     if ($user) {
         $priority = Role::where('id', '=', $user->roles_id)->first();
         $priority = $priority->priority;
         $this->entity->responsible = $user->id;
         $credit = CreditRequest::where('user_id', '=', $user->id)->first();
         if ($credit) {
             return ["message" => "no puedes solicitar mas creditos"] + ["role" => false];
         }
     } else {
         $priority = 0;
     }
     $user = new User($data);
     $user->roles_id = 4;
     $user->save();
     $this->entity->priority = $priority;
     $this->entity->files = $files;
     $this->entity->fill($this->prepareData($this->data));
     $user->CreditRequest()->save($this->entity);
     return ["message" => "la solicitud de credito fue enviada"] + ["role" => true];
 }
Example #2
0
 public function createUser()
 {
     $data = $this->prepareData($this->data);
     $user = new User($data);
     $user->save();
 }