Exemplo n.º 1
0
 /**
  * Store a newly created snippet in storage.
  *
  * @param SnippetsRequest $request
  * @return Response
  */
 public function store(SnippetsRequest $request)
 {
     $this->auth->basic('username');
     $data = ['title' => $request->input('title') ?: null, 'user_id' => $this->auth->user() ? $this->auth->id() : null, 'password' => $request->input('password') ?: null, 'mode' => $request->input('mode') ?: 'markdown'];
     $snippet = $this->dispatchFrom(StoreNewSnippetCommand::class, $request, $data);
     return 'http://drk.sh/s/' . $snippet->slug->slug . PHP_EOL;
 }
 /**
  * Handle the command.
  *
  * @param Guard $auth
  */
 public function handle(Guard $auth)
 {
     if ($this->entry->created_at) {
         $this->entry->updated_at = time();
         $this->entry->updated_by = $auth->id();
     }
     if (!$this->entry->created_at) {
         $this->entry->created_at = time();
         $this->entry->created_by = $auth->id();
     }
     if (!$this->entry->sort_order) {
         /* @var Builder $query */
         $query = $this->entry->newQuery();
         $this->entry->sort_order = $query->count('id') + 1;
     }
 }
 public function submit($id, Request $request, Guard $auth)
 {
     $this->validate($request, ['comment' => 'required|max:250', 'link' => 'url']);
     $comment = new TicketComments($request->only('comment', 'link'));
     $comment->user_id = $auth->id();
     $ticket = Ticket::findOrFail($id);
     $ticket->comments()->save($comment);
     session()->flash('success', 'Tu comentario fue guardado exitosamente');
     return redirect()->back();
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function nuevo($id, Request $request, Guard $auth)
 {
     $this->validate($request, ['comentario' => 'required|max:250', 'link' => 'url']);
     $comentario = new TicketComentario($request->all());
     $comentario->user_id = $auth->id();
     $ticket = Ticket::findOrFail($id);
     $ticket->comentarios()->save($comentario);
     session()->flash('success', 'Comentario guardado correctamente');
     return redirect()->back();
     //$comentario = new TicketComentario($request->only(['comentario', 'link']));
 }
 /**
  * Get Import Job by User
  *
  * @return array
  */
 public function getImportJobByUser()
 {
     $dirs = $this->filesystem->directories($this->getFilePath());
     $user_key = [];
     if (empty($dirs)) {
         return $user_key;
     }
     foreach ($dirs as $dir) {
         $key = last(explode('/', $dir));
         $json = $this->getJsonData($key, false);
         if (empty($json)) {
             continue;
         }
         $contracts = $json->contracts;
         if (isset($contracts[0]->user_id) && $contracts[0]->user_id == $this->auth->id()) {
             $user_key[] = ['step' => $json->step, 'key' => $key, 'is_completed' => $this->isImportCompleted($key), 'file' => $this->getOriginalFileName($key)];
         }
     }
     return $user_key;
 }
 /**
  * Set a preference value.
  *
  * @param $key
  * @param $value
  * @return $this
  */
 public function set($key, $value)
 {
     $preference = $this->model->where('user_id', $this->auth->id())->where('key', $key)->first();
     if (!$preference) {
         $preference = $this->model->newInstance();
         $preference->user_id = $this->auth->id();
         $preference->key = $key;
     }
     if (!($field = config(str_replace('::', '::preferences/preferences.', $key)))) {
         $field = config(str_replace('::', '::preferences.', $key));
     }
     if (is_string($field)) {
         $field = ['type' => $field];
     }
     $type = app(array_get($field, 'type'));
     $modifier = $type->getModifier();
     if ($modifier instanceof FieldTypeModifier) {
         $value = $modifier->modify($value);
     }
     $preference->value = $value;
     $preference->save();
     return $this;
 }
Exemplo n.º 7
0
 /**
  * Get the ID for the currently authenticated user.
  *
  * @return int|null 
  * @static 
  */
 public static function id()
 {
     return \Illuminate\Auth\Guard::id();
 }
Exemplo n.º 8
0
 /**
  * Handle the form fields.
  *
  * @param Guard           $auth
  * @param PostFormBuilder $builder
  */
 public function handle(Guard $auth, PostFormBuilder $builder)
 {
     $builder->setFields(['*', 'author' => ['config' => ['default_value' => $auth->id()]], 'publish_at' => ['config' => ['default_value' => 'now']]]);
 }
 /**
  * @param        $activityLog
  * @param string $user_id
  * @return bool
  */
 public function save($activityLog, $user_id = null)
 {
     $activityLog['user_id'] = is_null($user_id) ? $this->auth->id() : $user_id;
     return $this->activityLog->create($activityLog) ? true : false;
 }