Example #1
0
 /**
  * Create a user
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  * @throws \Illuminate\Foundation\Validation\ValidationException
  */
 public function postCreate(Request $request)
 {
     $data = $request->all();
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     $role = Role::where('name', config('laradmin.register_user_role'))->first();
     if ($role) {
         $user->roles()->attach($role->id);
     }
     $this->userRepository->clearCache();
     return redirect()->route('laradmin.users.index')->with('success', 'User was created!');
 }
 /**
  * Saves all the image attachments to the DB
  */
 public function saveImageAttachments(Request $request)
 {
     //get array of all types('context') of attachments for this model
     $this->attachmentNames = $this->getImageAttachmentNames();
     //first of all create the index of all input attachments
     foreach ($request->all() as $key => $input) {
         $this->addToInputIndex($key);
     }
     //go through index and save them to database
     foreach ($this->attachmentNames as $context) {
         if (isset($this->inputIndex[$context])) {
             $priority = 0;
             foreach ($this->inputIndex[$context]['identifiers'] as $attachmentID) {
                 $field = $context . '_' . $attachmentID . '_';
                 //if no id feild, then create a new attachment
                 if ($request->get($field . 'id') == null) {
                     Attachment::create(['context' => $context, 'url' => $request->get($field . 'url'), 'alt' => $request->get($field . 'alt'), 'caption' => $request->get($field . 'caption'), 'status' => 'active', 'model' => get_class(), 'model_id' => $this->id, 'priority' => $priority]);
                 } else {
                     if ($request->get($field . 'url') == '' && $request->get($field . 'caption') == '' && $request->get($field . 'alt') == '') {
                         Attachment::destroy($request->get($field . 'id'));
                     } else {
                         $attachment = Attachment::find($request->get($field . 'id'));
                         $attachment->update(['context' => $context, 'url' => $request->get($field . 'url'), 'alt' => $request->get($field . 'alt'), 'caption' => $request->get($field . 'caption'), 'status' => 'active', 'priority' => $priority], ['id' => $request->get($field . 'id')]);
                     }
                 }
                 $priority++;
             }
         }
     }
 }
 /**
  * @param Request $request
  * @param null $id if not null id it will update the records TODO
  */
 public function save(Request $request, $id = null)
 {
     $validator = Validator::make($request->all(), ['name' => 'required', 'gender' => 'required', 'phone' => ['required', 'regex:/^([0-9]{3})-([0-9]{4})-([0-9]{6})$/'], 'email' => 'required|email', 'address' => 'required', 'nationality' => 'required', 'dob' => 'required', 'education' => 'required', 'preffered' => 'required']);
     if ($validator->fails()) {
         return redirect('clients/create')->withErrors($validator)->withInput();
     }
     $csvPath = resource_path('bjsmasth/client/csv/clients.csv');
     $reader = Reader::open($csvPath);
     $records = $reader->readAll();
     $count = count($records);
     $writer = CsvWriter::create($csvPath);
     $input = Input::except('_token', 'submitBtn');
     $data = implode('/', $input);
     $writer->writeLine([$count + 1, $data]);
     $writer->writeAll($records);
     $writer->flush();
     $writer->close();
     Log::info('Client was successfully');
     $request->session()->flash('flash_message', 'Client has been successful added!');
     return redirect('clients/create');
 }
Example #4
0
 /**
  * Check the authorization code request parameters
  * 
  * @throws \OAuth2\Exception\ClientException
  * @return array Authorize request parameters
  */
 public function checkAuthorizeParams()
 {
     $input = $this->request->all();
     return $this->getOAuth()->getAuthServer()->getGrantType('authorization_code')->checkAuthoriseParams($input);
 }
Example #5
0
 public function updateChecklist(Request $request)
 {
     $checklists = $request->all();
     unset($checklists['_token']);
     // Update each submitted checklist to 1
     foreach ($checklists as $index => $value) {
         $temp = explode("_", $index);
         Checklist::where('id', $temp[1])->update(array('value' => $value));
     }
     return redirect()->back()->with('message', 'Checklist successfully updated')->with('msg_type', 'success');
 }
 public function update($id, Request $request)
 {
     $article = Article::findOrFail($id);
     $article->update($request->all());
 }