Example #1
4
 /**
  * Call Module action
  *
  * @param $name
  * @param $action
  * @return \Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function anyModule($name, $action)
 {
     global $app;
     $name = strtolower($name);
     if (isset($app['arxmin.modules.' . $name])) {
         $model = $app['arxmin.modules.' . $name];
     } else {
         $model = "\\Arxmin\\" . ucfirst($name);
     }
     # force format action
     $method = studly_case($action);
     if ((class_exists($model, false) || is_object($model)) && method_exists($model, $method)) {
         $params = Request::segments();
         for ($i = 0; $i <= array_search($action, $params); $i++) {
             unset($params[$i]);
         }
         if (count(Input::all())) {
             $params[] = Input::all();
         }
         $response = call_user_func_array(array($model, $method), $params);
         if (is_object($response) && method_exists($response, 'toArray')) {
             $response = $response->toArray();
         }
         return Api::responseJson($response);
     }
     return Response::json(Api::response([], 400, "method not found"), 400);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $name = $this->argument('name');
     $studly_name = studly_case($name);
     $directive_name = strtolower(substr($studly_name, 0, 1)) . substr($studly_name, 1);
     $html = file_get_contents(__DIR__ . '/Stubs/AngularDirective/directive.html.stub');
     $js = file_get_contents(__DIR__ . '/Stubs/AngularDirective/directive.js.stub');
     $definition = file_get_contents(__DIR__ . '/Stubs/AngularDirective/definition.js.stub');
     $less = file_get_contents(__DIR__ . '/Stubs/AngularDirective/directive.less.stub');
     $js = str_replace('{{StudlyName}}', $studly_name, $js);
     $definition = str_replace('{{StudlyName}}', $studly_name, $definition);
     $definition = str_replace('{{name}}', $name, $definition);
     $definition = str_replace('{{directiveName}}', $directive_name, $definition);
     $folder = __DIR__ . '/../../../angular/directives/' . $name;
     if (is_dir($folder)) {
         $this->info('Folder already exists');
         return false;
     }
     //create folder
     File::makeDirectory($folder, 0775, true);
     //create view (.html)
     File::put($folder . '/' . $name . '.html', $html);
     //create definition (.js)
     File::put($folder . '/definition.js', $definition);
     //create controller (.js)
     File::put($folder . '/' . $name . '.js', $js);
     //create less file (.less)
     File::put($folder . '/' . $name . '.less', $less);
     $this->info('Directive created successfully.');
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $table_name = strtolower($this->argument('name'));
     $migration = "create_{$table_name}_table";
     // The template file is the migration that ships with the package
     $template_dir = __DIR__;
     $template_file = 'SchemaTemplate.php';
     $template_path = $template_dir . '/' . $template_file;
     // Make sure the template path exists
     if (!$this->fs->exists($template_path)) {
         return $this->error('Unable to find template: ' . $template_path);
     }
     // Set the Destination Directory
     $dest_dir = base_path() . '/database/migrations/';
     $dest_file = date("Y_m_d_His") . '_' . $migration . '.php';
     $dest_path = $dest_dir . $dest_file;
     // Make Sure the Destination Directory exists
     if (!$this->fs->isDirectory($dest_dir)) {
         return $this->error('Unable to find destination directory: ' . $dest_dir);
     }
     // Read Template File
     $template = $this->fs->get($template_path);
     // Replace what is necessary
     $classname = 'Create' . studly_case(ucfirst($table_name)) . 'Table';
     $contents = str_replace("'__meta__'", "'" . $table_name . "'", $template);
     $contents = str_replace('SchemaTemplate', $classname, $contents);
     // Write new Migration to destination
     $this->fs->put($dest_path, $contents);
     // Dump-Autoload
     //        $this->call('dump-autoload');
     $this->info($table_name . ' migration created. run "php artisan migrate" to create the table');
 }
Example #4
0
 /**
  * Separate rule name from parameters and pass to matcher class to evaluate.
  *
  * @return boolean
  */
 protected function handleRule($request, $rule)
 {
     $rule = explode(':', $rule);
     $params = isset($rule[1]) ? $rule[1] : null;
     $class = '\\PeterColes\\Themes\\Matchers\\' . studly_case($rule[0]);
     return (new $class())->handle($request, $params);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $name = $this->argument('name');
     $studly_name = studly_case($name);
     $js = file_get_contents(__DIR__ . '/Stubs/AngularService/service.js.stub');
     $spec = file_get_contents(__DIR__ . '/Stubs/AngularService/service.spec.js.stub');
     $js = str_replace('{{StudlyName}}', $studly_name, $js);
     $spec = str_replace('{{StudlyName}}', $studly_name, $spec);
     $folder = base_path(config('generators.source.root')) . '/' . config('generators.source.services');
     $spec_folder = base_path(config('generators.tests.source.root')) . '/' . config('generators.tests.source.services');
     //create service (.service.js)
     File::put($folder . '/' . $name . config('generators.suffix.service'), $js);
     if (!$this->option('no-spec') && config('generators.tests.enable.services')) {
         //create spec folder
         if (!File::exists($spec_folder)) {
             File::makeDirectory($spec_folder, 0775, true);
         }
         //create spec (.service.spec.js)
         File::put($spec_folder . '/' . $name . '.service.spec.js', $spec);
     }
     //import service
     $services_index = base_path(config('generators.source.root')) . '/index.services.js';
     if (config('generators.misc.auto_import') && !$this->option('no-import') && file_exists($services_index)) {
         $services = file_get_contents($services_index);
         $newService = "\r\n\t.service('{$studly_name}Service', {$studly_name}Service)";
         $module = "angular.module('app.services')";
         $services = str_replace($module, $module . $newService, $services);
         $services = 'import {' . $studly_name . "Service} from './services/{$name}.service';\n" . $services;
         file_put_contents($services_index, $services);
     }
     $this->info('Service created successfully.');
 }
 /**
  * Handle the command.
  *
  * Add a default Module route, language entries etc per Module
  *
  */
 public function handle()
 {
     $module = $this->module;
     $dest = $module->getPath();
     $data = ['config' => _config('builder', $module), 'vendor' => $module->getVendor(), 'module_name' => studly_case($module->getSlug())];
     $src = __DIR__ . '/../../resources/stubs/module';
     try {
         if (_config('builder.landing_page', $module)) {
             /* adding routes to the module service provider class
                (currently, just for the optional landing (home) page) */
             $this->processFile("{$dest}/src/" . $data['module_name'] . 'ModuleServiceProvider.php', ['routes' => $src . '/routes.php'], $data);
             /* adding sections to the module class
                (currently, just for the optional landing (home) page)*/
             $this->processFile("{$dest}/src/" . $data['module_name'] . 'Module.php', ['sections' => $src . '/sections.php'], $data, true);
         }
         /* generate sitemap for the module main stream */
         if ($stream_slug = _config('builder.sitemap.stream_slug', $module)) {
             $data['entity_name'] = studly_case(str_singular($stream_slug));
             $data['repository_name'] = str_plural($stream_slug);
             $this->files->parseDirectory("{$src}/config", "{$dest}/resources/config", $data);
         }
         /* adding module icon */
         $this->processVariable("{$dest}/src/" . $data['module_name'] . 'Module.php', ' "' . _config('builder.icon', $module) . '"', 'protected $icon =', ';');
     } catch (\PhpParser\Error $e) {
         die($e->getMessage());
     }
 }
 /**
  * Set table name
  *
  * @param  string  $table
  *
  * @return self
  */
 private function setTable($table)
 {
     $this->table = strtolower($table);
     $this->migrationName = snake_case($this->table);
     $this->className = studly_case($this->migrationName);
     return $this;
 }
Example #8
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     /** @var \Illuminate\Config\Repository $config */
     $config = $this->app->make('config');
     $this->app->singleton('Intervention\\Image\\ImageManager', function (Application $app) {
         return new ImageManager(array('driver' => $app->config->get('imager::driver', 'gd')));
     });
     $this->app->bind('TippingCanoe\\Imager\\Repository\\Image', 'TippingCanoe\\Imager\\Repository\\DbImage');
     $this->app->singleton('TippingCanoe\\Imager\\Service', function (Application $app) use($config) {
         //
         // Amazon S3
         //
         if ($s3Config = $config->get('imager::s3')) {
             $this->app->bind('Aws\\S3\\S3Client', function (Application $app) use($s3Config) {
                 return \Aws\S3\S3Client::factory($s3Config);
             });
         }
         // Run through and call each config option as a setter on the storage method.
         $storageDrivers = [];
         foreach ($config->get('imager::storage', []) as $abstract => $driverConfig) {
             /** @var \TippingCanoe\Imager\Storage\Driver $driver */
             $driver = $app->make($abstract);
             foreach ($driverConfig as $property => $value) {
                 $setter = studly_case('set_' . $property);
                 $driver->{$setter}($value);
             }
             $storageDrivers[$abstract] = $driver;
         }
         $service = new Service($app->make('TippingCanoe\\Imager\\Repository\\Image'), $app->make('Intervention\\Image\\ImageManager'), $app, $storageDrivers);
         return $service;
     });
 }
Example #9
0
 function camel_case($value)
 {
     if (isset($camelCache[$value])) {
         return $camelCache[$value];
     }
     return $camelCache[$value] = lcfirst(studly_case($value));
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->container['slug'] = strtolower($this->argument('slug'));
     $this->container['namespace'] = studly_case($this->container['slug']);
     $this->container['modelName'] = studly_case($this->argument('model'));
     $this->container['tableName'] = $this->container['slug'] . '_' . strtolower($this->container['modelName']);
     $this->container['className'] = studly_case($this->container['modelName']);
     if ($this->module->exists($this->container['slug'])) {
         $filename = $this->getDestinationFile();
         $dir = pathinfo($filename, PATHINFO_DIRNAME);
         if (!is_dir($dir)) {
             mkdir($dir, 0777, true);
             $this->line("<info>Created missing directory:</info> {$dir}");
         }
         if (file_exists($filename)) {
             $this->line('File already exist.');
             if ($this->confirm('Do you want to overwrite the file? [y|N]')) {
                 $this->createFile();
             } else {
                 return $this->info('File not overwritten.');
             }
         } else {
             $this->createFile();
         }
         return $this->line("<info>Created model for module:</info> {$filename}");
     }
     return $this->error('Module does not exist.');
 }
Example #11
0
 /**
  * Build the class name from the migration file.
  *
  * @todo Find a better way than doing this. This feels so icky all over
  *       whenever I look back at this.
  *       Maybe I can find something that's actually in native Laravel
  *       database classes.
  *
  * @param  string  $file
  * @return Migration
  */
 private function createMigration(string $file)
 {
     $basename = str_replace('.php', '', class_basename($file));
     $filename = substr($basename, 18);
     $classname = studly_case($filename);
     return new $classname();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $name = $this->argument('name');
     $studly_name = studly_case($name);
     $component_name = strtolower(substr($studly_name, 0, 1)) . substr($studly_name, 1);
     $html = file_get_contents(__DIR__ . '/Stubs/AngularComponent/component.html.stub');
     $js = file_get_contents(__DIR__ . '/Stubs/AngularComponent/component.js.stub');
     $less = file_get_contents(__DIR__ . '/Stubs/AngularComponent/component.less.stub');
     $js = str_replace('{{StudlyName}}', $studly_name, $js);
     $js = str_replace('{{name}}', $name, $js);
     $js = str_replace('{{componentName}}', $component_name, $js);
     $folder = base_path(config('generators.source.root')) . '/' . config('generators.source.components') . '/' . $name;
     if (is_dir($folder)) {
         $this->info('Folder already exists');
         return false;
     }
     //create folder
     File::makeDirectory($folder, 0775, true);
     //create view (.component.html)
     File::put($folder . '/' . $name . config('generators.prefix.componentView'), $html);
     //create component (.component.js)
     File::put($folder . '/' . $name . config('generators.prefix.component'), $js);
     //create less file (.less)
     File::put($folder . '/' . $name . '.less', $less);
     $this->info('Component created successfully.');
 }
 /**
  * Mutates and stores an attribute in array
  *
  * @param string $key
  * @param string $type
  * @return mixed
  */
 protected function mutateExtensionAttribute($key, $type)
 {
     $value = $this->getAttributeFromArray($key);
     $mutation = $this->{'make' . studly_case($type) . 'TypeMutation'}($value);
     $this->mutations[$key] = $mutation;
     return $mutation;
 }
Example #14
0
 protected function generate($type)
 {
     switch ($type) {
         case 'controller':
             $filename = studly_case(class_basename($this->getNameInput()) . ucfirst($type));
             break;
         case 'model':
             $filename = studly_case(class_basename($this->getNameInput()));
             break;
         case 'view':
             $filename = 'index.blade';
             break;
         case 'translation':
             $filename = 'example';
             break;
         case 'routes':
             $filename = 'routes';
             break;
     }
     // $suffix = ($type == 'controller') ? ucfirst($type) : '';
     $folder = $type != 'routes' ? ucfirst($type) . 's\\' . ($type === 'translation' ? 'en\\' : '') : '';
     $name = $this->parseName('Modules\\' . $this->getNameInput() . '\\' . $folder . $filename);
     if ($this->files->exists($path = $this->getPath($name))) {
         return $this->error($this->type . ' already exists!');
     }
     $this->currentStub = __DIR__ . '/stubs/' . $type . '.stub';
     $this->makeDirectory($path);
     $this->files->put($path, $this->buildClass($name));
 }
 /**
  * Simplify the process of routes registration
  *
  * @param Router $router
  * @param $name
  */
 protected function makeGroup(Router $router, $name)
 {
     $groupOpts = ['namespace' => $this->namespace . '\\' . studly_case($name), 'prefix' => $name, 'middleware' => ['web']];
     $router->group($groupOpts, function ($router) use($name) {
         require app_path('Http/routes/' . $name . '.php');
     });
 }
Example #16
0
File: Mws.php Project: ireisaac/mws
 /**
  * using an action, also refered to as an operation, 
  * we can easily find the correct mws path and version
  * @param  string $action
  * @return array  containing action, path, version
  */
 public function getParams($action)
 {
     $action = studly_case($action);
     $path = $this->collection->path($action);
     $version = $this->collection->version($path);
     return ['action' => $action, 'path' => $path, 'version' => $version];
 }
 public function run()
 {
     Eloquent::unguard();
     DB::table('services')->truncate();
     DB::table('service_options')->truncate();
     DB::table('billing_cycles')->truncate();
     $faker = Faker\Factory::create();
     $service = Service::create(array('name' => 'Simful Travel', 'description' => 'Complete solution for travel agents'));
     ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Economy', 'base_price' => '15', 'description' => 'Designed for small, starter agents.'));
     ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Professional', 'base_price' => '24', 'description' => 'Great for small and mid-size agents.'));
     ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Super', 'base_price' => '45', 'description' => 'For mid-size to large agents.'));
     ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Ultima', 'base_price' => '125', 'description' => 'For the enterprise level.'));
     BillingCycle::create(array('service_id' => $service->id, 'cycle' => 3, 'discount' => 5));
     BillingCycle::create(array('service_id' => $service->id, 'cycle' => 6, 'discount' => 10));
     BillingCycle::create(array('service_id' => $service->id, 'cycle' => 12, 'discount' => 20));
     BillingCycle::create(array('service_id' => $service->id, 'cycle' => 24, 'discount' => 25));
     for ($i = 0; $i < 10; $i++) {
         $service = Service::create(array('name' => studly_case($faker->domainWord), 'description' => $faker->sentence));
         ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Economy', 'base_price' => $faker->randomNumber(1, 15), 'description' => $faker->sentence));
         ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Professional', 'base_price' => $faker->randomNumber(16, 35), 'description' => $faker->sentence));
         ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Super', 'base_price' => $faker->randomNumber(36, 100), 'description' => $faker->sentence));
         ServiceOption::create(array('service_id' => $service->id, 'option_name' => 'Ultima', 'base_price' => $faker->randomNumber(101, 200), 'description' => $faker->sentence));
         BillingCycle::create(array('service_id' => $service->id, 'cycle' => 3, 'discount' => 5));
         BillingCycle::create(array('service_id' => $service->id, 'cycle' => 6, 'discount' => 10));
         BillingCycle::create(array('service_id' => $service->id, 'cycle' => 12, 'discount' => 20));
         BillingCycle::create(array('service_id' => $service->id, 'cycle' => 24, 'discount' => 25));
     }
 }
Example #18
0
 public function registerAssignedRoute(&$routes)
 {
     $routes->{$this->pluginId} = function () {
         // for static action
         require_once 'board_manager.php';
         Route::get('/manage', function () {
             $boardManager = BoardManager::getInstance();
             return $boardManager->getIndex();
         });
         Route::get('/manage/list', function () {
             $boardManager = BoardManager::getInstance();
             return $boardManager->getList();
         });
         // for dynamic action(using alias)
         require_once 'board.php';
         Route::get('{bid}/list', function ($bid) {
             $board = Board::getInstance();
             return $board->getList($bid);
         });
         Route::get('{bid}/setting', function ($bid) {
             $board = Board::getInstance();
             return $board->getSetting($bid);
         });
         Route::get('{bid}/{act?}', function ($bid, $act = null) {
             $act = $act ?: \Input::get('act', 'list');
             $board = Board::getInstance();
             $method = 'get' . studly_case($act);
             if (method_exists($board, $method)) {
                 return $board->{$method}($bid);
             }
             throw new NotFoundHttpException();
         });
     };
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $notifications = Notification::all();
     foreach ($notifications as $notification) {
         $notification->update(['object_type' => studly_case($notification->object_type)]);
     }
 }
Example #20
0
 public function index()
 {
     $folderName = Input::get('folder');
     $groupName = Input::has('group') ? shadow(Input::get('group')) : 'all';
     $className = 'Strimoid\\Models\\Folders\\' . studly_case($folderName ?: $groupName);
     if (Input::has('folder') && !class_exists('Folders\\' . studly_case($folderName))) {
         $user = Input::has('user') ? User::findOrFail(Input::get('user')) : Auth::user();
         $folder = Folder::findUserFolderOrFail($user->getKey(), Input::get('folder'));
         if (!$folder->public && (Auth::guest() || $user->getKey() != Auth::id())) {
             App::abort(404);
         }
         $builder = $folder->entries();
     } elseif (class_exists($className)) {
         $fakeGroup = new $className();
         $builder = $fakeGroup->entries();
         $builder->orderBy('sticky_global', 'desc');
     } else {
         $group = Group::name($groupName)->firstOrFail();
         $group->checkAccess();
         $builder = $group->entries();
         // Allow group moderators to stick contents
         $builder->orderBy('sticky_group', 'desc');
     }
     $builder->with(['user', 'group', 'replies', 'replies.user'])->orderBy('created_at', 'desc');
     $perPage = Input::has('per_page') ? between(Input::get('per_page'), 1, 100) : 20;
     return $builder->paginate($perPage);
 }
Example #21
0
 /**
  * Register the module service provider.
  *
  * @param  string $properties
  * @return string
  * @throws \Fabriciorabelo\Modules\Exception\FileMissingException
  */
 protected function registerServiceProvider($properties)
 {
     $module = studly_case($properties['slug']);
     $file = $this->repository->getPath() . "/{$module}/Providers/{$module}ServiceProvider.php";
     $namespace = $this->repository->getNamespace() . "\\" . $module . "\\Providers\\{$module}ServiceProvider";
     $this->app->register($namespace);
 }
 /**
  * Fetches allowed values for a certain parameter
  *
  * @param  string  $mode
  * @param  string  $param
  * @return void
  */
 public function getParameter($mode, $param)
 {
     $api = API::make($mode);
     switch ($param) {
         case 'language':
             $languages = Highlighter::make()->languages();
             $values = array_keys($languages);
             break;
         case 'expire':
             $expire = Paste::getExpiration();
             $values = array_keys($expire);
             break;
         case 'version':
             $values = array(Config::get('app.version'));
             break;
         case 'theme':
             $values = array(studly_case(Site::config('general')->skin));
             break;
         default:
             return $api->error('invalid_param', 404);
     }
     // Build the API data
     $data = array('param' => $param, 'values' => $values);
     return $api->out('param', $data);
 }
 private function saveToIndex(array $model_config)
 {
     if (empty($model_config['setup']['mapping']['properties'])) {
         throw new \InvalidArgumentException('Index model ' . self::$index_model . ' mapping properties found or empty in index config file.');
     }
     $properties_config = $model_config['setup']['mapping']['properties'];
     //go through index properties / columns in config and capture values from model for indexing
     foreach ($properties_config as $column => $column_mapping) {
         //if the column is not set on the model but there is a mutator,
         //then use that to get value for indexing
         if (!isset($this->{$column}) && method_exists($this, 'set' . studly_case($column) . 'Attribute')) {
             $columns[$column] = $this->{'set' . studly_case($column) . 'Attribute'}(null);
             continue;
         }
         //if the column is not set on the model and there is no mutator throw exception
         if (!isset($this->{$column})) {
             throw new \InvalidArgumentException('Field ' . $column . ' does not exist for indexoing on this eloquent object.');
         }
         //lastly, use column value that exists on model
         $columns[$column] = $this->{$column};
     }
     if (!isset($this->id)) {
         var_dump($this);
         throw new \InvalidArgumentException('Eloquent id field missing for indexing.');
     }
     $columns['_id'] = $this->id;
     $index_repo = \App::make('Ryanrobertsname\\LaravelElasticsearchRepository\\Repository\\IndexRepository');
     $index_repo->model(self::$index_model)->index($columns);
 }
 /**
  * Extend validator.
  *
  * @param  string         $name
  * @param  string         $class
  * @param  \Closure|null  $replacer
  */
 private function extendValidator($name, $class, Closure $replacer = null)
 {
     $this->validator->extend($name, $class . '@validate' . studly_case($name));
     if (!is_null($replacer)) {
         $this->validator->replacer($name, $replacer);
     }
 }
 /**
  * Extend the validator with new rules.
  * @param  string $rule
  * @return void
  */
 protected function extendValidator($rule)
 {
     $method = studly_case($rule);
     $translation = trans('imagevalidator::validation');
     $this->app['validator']->extend($rule, 'Yaravel\\Imagevalidator\\Imagevalidator@validate' . $method, $translation[$rule]);
     $this->app['validator']->replacer($rule, 'Yaravel\\Imagevalidator\\Imagevalidator@replace' . $method);
 }
Example #26
0
 /**
  * Parse an article from a string.
  * 
  * @param  string  $content
  * @param  string  $path
  * @return array
  */
 public function parse($content, $path)
 {
     foreach (['slug', 'date', 'meta', 'excerpt', 'content'] as $type) {
         $parsed[$type] = $this->{'parse' . studly_case($type)}($content, $path);
     }
     return $parsed;
 }
 /**
  * @param  string $contents
  * @return string
  */
 public function replaceStubContents($contents)
 {
     $contents = str_replace('{className}', studly_case($this->handlerName), $contents);
     $contents = str_replace('{handlerType}', studly_case($this->handlerType), $contents);
     $contents = str_replace('{handlingClass}', studly_case($this->handlingName), $contents);
     return $contents;
 }
Example #28
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     if (Auth::check()) {
         # code...
         if (Auth::user()->type == 1) {
             # code...
             $rules = ['activity_id' => 'required|integer', 'event_name' => 'required|unique:events', 'image_path' => 'required|image'];
             $validator = Validator::make($request->all(), $rules);
             if ($validator->fails()) {
                 # code...
                 return redirect()->back()->withErrors($validator);
             }
             if ($request->hasFile('image_path')) {
                 $input = $request->all();
                 $image = $input['image_path'];
                 $name = '' . $input['event_name'] . '.png';
                 //dd($name);
                 $image = $image->move(public_path() . '/images/events/', studly_case($name));
                 $url = '/images/events/' . studly_case($name);
                 $event = Event::create(['activity_id' => $input['activity_id'], 'event_name' => $input['event_name'], 'image_path' => $url]);
                 if ($event) {
                     # code...
                     $subscribedUsers = $this->getUsers($event->activity_id);
                     $this->sendEmail($subscribedUsers, $event->event_name);
                     Session::flash('eventCreated', $event->event_name . ' has been created!');
                 } else {
                     return "error creating the event.";
                 }
                 return redirect('home');
             }
             return redirect('/');
         }
     }
     return redirect('/');
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $subAppName = studly_case($this->argument('app_name'));
     // Get extra arguments
     $this->applicationCreator->create($subAppName);
     $this->info('Application created!');
 }
Example #30
-2
 function parse_usernames($body)
 {
     $body = preg_replace_callback('/(?<=^|\\s)c\\/([a-z0-9_-]+)(?=$|\\s|:|.)/i', function ($matches) {
         $content = Content::find($matches[1]);
         if ($content) {
             return '[' . str_replace('_', '\\_', $content->title) . '](' . $content->getSlug() . ')';
         } else {
             return 'c/' . $matches[1];
         }
     }, $body);
     $body = preg_replace_callback('/(?<=^|\\s)u\\/([a-z0-9_-]+)(?=$|\\s|:|.)/i', function ($matches) {
         $target = User::name($matches[1])->first();
         if ($target) {
             return '[u/' . str_replace('_', '\\_', $target->name) . '](/u/' . $target->name . ')';
         }
         return 'u/' . $matches[1];
     }, $body);
     $body = preg_replace_callback('/(?<=^|\\s)@([a-z0-9_-]+)(?=$|\\s|:|.)/i', function ($matches) {
         $target = User::name($matches[1])->first();
         if ($target) {
             return '[@' . str_replace('_', '\\_', $target->name) . '](/u/' . $target->name . ')';
         }
         return '@' . $matches[1];
     }, $body);
     $body = preg_replace_callback('/(?<=^|\\s)(?<=\\s|^)g\\/([a-z0-9_-żźćńółęąśŻŹĆĄŚĘŁÓŃ]+)(?=$|\\s|:|.)/i', function ($matches) {
         $target = Group::name($matches[1])->first();
         $fakeGroup = class_exists('Folders\\' . studly_case($matches[1]));
         if ($target || $fakeGroup) {
             $urlname = $target ? $target->urlname : $matches[1];
             return '[g/' . str_replace('_', '\\_', $urlname) . '](/g/' . $urlname . ')';
         }
         return 'g/' . $matches[1];
     }, $body);
     return $body;
 }