Ejemplo n.º 1
0
 /**
  * Check if name is not blacklisted.
  *
  * @param  string   $name
  * @return void
  * @throws \InvalidArgumentException
  */
 protected function checkNameIsNotBlacklisted($name)
 {
     foreach ($this->blacklisted as $character) {
         if (Str::contains($name, $character)) {
             throw new InvalidArgumentException("Invalid character in driver name [{$name}].");
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Execute the job.
  *
  * @param \Imagine\Image\ImagineInterface $imagine
  *
  * @return void
  */
 public function handle(ImagineInterface $imagine)
 {
     $data = $this->getFilteredOptions($this->options);
     $path = $data['path'];
     $source = Str::replace('{filename}.{extension}', $data);
     $destination = Str::replace($data['format'], $data);
     $this->handleImageManipulation($imagine->open("{$path}/{$source}"), $data)->save("{$path}/{$destination}");
 }
Ejemplo n.º 3
0
 /**
  * Create a new user.
  *
  * @param  \Orchestra\Contracts\Foundation\Listener\Account\ProfileCreator  $listener
  * @param  array  $input
  *
  * @return mixed
  */
 public function store(Listener $listener, array $input)
 {
     $password = Arr::get($input, 'password', Str::random(5));
     $validation = $this->validator->on('register')->with($input);
     // Validate user registration, if any errors is found redirect it
     // back to registration page with the errors
     if ($validation->fails()) {
         return $listener->createProfileFailedValidation($validation->getMessageBag());
     }
     $user = Foundation::make('orchestra.user');
     try {
         $this->saving($user, $input, $password);
     } catch (Exception $e) {
         return $listener->createProfileFailed(['error' => $e->getMessage()]);
     }
     return $this->notifyCreatedUser($listener, $user, $password);
 }
Ejemplo n.º 4
0
 /**
  * Get extension name (if available).
  *
  * @param  string  $name
  *
  * @return string
  */
 protected function getAuthorizationName($name)
 {
     $extension = $this->memory->get("extensions.available.{$name}.name");
     $title = $name === 'orchestra' ? 'Orchestra Platform' : $extension;
     return is_null($title) ? Str::title($name) : $title;
 }
Ejemplo n.º 5
0
 /**
  * Write the migration file to disk.
  *
  * @param  string  $driver
  * @param  string  $name
  * @param  string  $table
  * @param  bool    $create
  *
  * @return string
  */
 protected function writeMigration($driver, $name, $table, $create)
 {
     $migrator = $this->tenant->driver($driver);
     $files = $this->creator->getFilesystem();
     $path = $migrator->getMigrationPath();
     if (!$files->isDirectory($path)) {
         $files->makeDirectory($path, 0755, true);
     }
     $name = implode('_', [$driver, 'tenant', $name]);
     $table = Str::replace($migrator->getTablePrefix() . "_{$table}", ['id' => '{$id}']);
     $file = pathinfo($this->creator->create($name, $path, $table, $create), PATHINFO_FILENAME);
     $this->line("<info>Created Migration:</info> {$file}");
 }
Ejemplo n.º 6
0
 /**
  * Resolve table name.
  *
  * @param  \Illuminate\Database\Eloquent\Model  $entity
  * @param  string|null  $name
  *
  * @return string|null
  */
 protected function bindWithKey(Model $entity, $name)
 {
     if (is_null($name) || strpos($name, '{') === false && strpos($name, '}') === false) {
         return $name;
     }
     $id = $entity->getKey();
     if (!isset($this->data[$id])) {
         $data = array_merge(Arr::dot(['entity' => $entity->toArray()]), compact('id'));
         $this->data[$id] = $data;
     }
     return Str::replace($name, $this->data[$id]);
 }
Ejemplo n.º 7
0
 /**
  * Resolve table name.
  *
  * @param  \Illuminate\Database\Eloquent\Model  $entity
  * @param  string|null  $name
  *
  * @return string|null
  */
 protected function bindWithKey(Model $entity, $name)
 {
     if (is_null($name)) {
         return $name;
     }
     $id = $entity->getKey();
     if (!isset($this->data[$id])) {
         $data = Arr::dot(['entity' => $entity->toArray()]);
         $data['id'] = $id;
         $this->data[$id] = $data;
     }
     return Str::replace($name, $this->data[$id]);
 }
Ejemplo n.º 8
0
 /**
  * Register a custom driver creator Closure.
  *
  * @param  string   $name
  * @param  \Closure $callback
  *
  * @return $this
  */
 public function extend($name, Closure $callback)
 {
     $this->parsers[Str::camel($name)] = Str::title($name);
     return parent::extend($name, $callback);
 }
Ejemplo n.º 9
0
 /**
  * Get uploaded filename.
  *
  * @param  \Symfony\Component\HttpFoundation\File\UploadedFile  $file
  *
  * @return string
  */
 protected function getUploadedFilename(UploadedFile $file)
 {
     $extension = $file->getClientOriginalExtension();
     return sprintf('%s.%s', Str::random(10), $extension);
 }
Ejemplo n.º 10
0
 /**
  * Get status name.
  *
  * @return string
  */
 public function getStatusName()
 {
     return Str::upper($this->status);
 }
Ejemplo n.º 11
0
 /**
  * Get HTML::title() format for page.
  *
  * @param  array  $data
  *
  * @return mixed
  */
 protected function getHtmlTitleFormatForPage(array $data)
 {
     if (empty($data['page']['title'])) {
         return $data['site']['name'];
     }
     $format = get_meta('html::title.format.page', '{page.title} &mdash; {site.name}');
     return Str::replace($format, $data);
 }
Ejemplo n.º 12
0
 /**
  * Run rules bindings.
  *
  * @return array
  */
 protected function getBindedRules()
 {
     $rules = $this->getValidationRules();
     if (!empty($this->validationBindings)) {
         foreach ($rules as $key => $value) {
             $rules[$key] = Str::replace($value, $this->validationBindings);
         }
     }
     return $rules;
 }
Ejemplo n.º 13
0
 /**
  * Build wildcard query filters.
  *
  * @param  \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder  $query
  * @param  array  $fields
  * @param  array  $keyword
  * @param  string  $group
  *
  * @return void
  */
 protected function buildWildcardQueryFilters($query, array $fields, array $keyword = [])
 {
     foreach ($fields as $field) {
         if (Str::contains($field, '.') && $query instanceof Builder) {
             list($relation, $field) = explode('.', $field, 2);
             $query->orWhereHas($relation, function ($query) use($field, $keyword) {
                 $this->buildWildcardQueryFilterWithKeyword($query, $field, $keyword, 'where');
             });
         } else {
             $this->buildWildcardQueryFilterWithKeyword($query, $field, $keyword, 'orWhere');
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * Parse HTML/Content from string.
  *
  * @param  string  $content
  * @param  string  $version
  *
  * @return string
  */
 public function parseContent($content, $version)
 {
     $replacement = ['doc-url' => handles('app::docs') . "/{$version}"];
     return Str::replace($content, $replacement);
 }
Ejemplo n.º 15
0
 /**
  * Response when theme activation succeed.
  *
  * @param  string  $type
  * @param  string  $id
  *
  * @return mixed
  */
 public function themeHasActivated($type, $id)
 {
     $message = trans('orchestra/control::response.themes.update', ['type' => Str::title($type)]);
     return $this->redirectWithMessage(handles("orchestra::control/themes/{$type}"), $message);
 }