コード例 #1
1
 protected function makeCustomPostType(Post $model)
 {
     $postTypeSlug = strtolower(snake_case(class_basename($model)));
     if ($model instanceof CustomPostType) {
         $singular = property_exists($model, 'singular') ? $model->singular : str_replace(['-', '_'], ' ', $postTypeSlug);
         $plural = property_exists($model, 'plural') ? $model->plural : str_plural(str_replace(['-', '_'], ' ', $postTypeSlug));
         $postTypeData = $model->customPostTypeData();
         if (!is_array($postTypeData)) {
             $postTypeData = [];
         }
         $result = register_post_type($postTypeSlug, $this->buildPostTypeData($singular, $plural, $postTypeData));
         if (!$result instanceof \WP_Error) {
             $this->postTypes[$postTypeSlug] = get_class($model);
             if (property_exists($model, 'placeholderText')) {
                 add_filter('enter_title_here', function ($default) use($postTypeSlug, $model) {
                     if ($postTypeSlug == get_current_screen()->post_type) {
                         $default = $model->placeholderText;
                     }
                     return $default;
                 });
             }
         }
     } else {
         $this->postTypes[$postTypeSlug] = get_class($model);
     }
 }
コード例 #2
0
 /**
  * CrudCommand constructor.
  */
 public function handle()
 {
     $this->resource = str_replace(' ', '', $this->argument('resource'));
     $this->namespace = rtrim($this->getAppNamespace(), '\\');
     $this->table_single = snake_case($this->resource);
     $this->table = str_plural($this->table_single);
     $this->single = str_replace('_', ' ', $this->table_single);
     $this->plural = str_plural($this->single);
     $options = $this->input->getOptions();
     if (array_has($options, 'route-prefix') and $this->option('route-prefix')) {
         $this->route = $this->option('route-prefix') . '.' . $this->table_single;
     } else {
         $this->route = $this->table_single;
     }
     if (array_has($options, 'view-path') and $this->option('view-path')) {
         $this->view = $this->option('view-path') . '.' . $this->table_single;
     } else {
         $this->view = $this->table_single;
     }
     if (array_has($options, 'fields') and $this->option('fields')) {
         $this->fields = $this->getFields($this->option('fields'));
     } else {
         $this->fields = '';
     }
     $this->variables = ['resource' => $this->resource, 'resource_plural' => str_plural($this->resource), 'namespace' => $this->namespace, 'table' => $this->table, 'table_single' => $this->table_single, 'single' => $this->single, 'single_capital' => ucwords($this->single), 'plural' => $this->plural, 'plural_capital' => ucwords($this->plural), 'route' => $this->route, 'view' => $this->view, 'fields' => $this->fields];
 }
コード例 #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $name = ucwords(strtolower($this->argument('name')));
     if ($this->option('fields')) {
         $fields = $this->option('fields');
         $fillable_array = explode(',', $fields);
         foreach ($fillable_array as $value) {
             $data[] = preg_replace("/(.*?):(.*)/", "\$1", trim($value));
         }
         $comma_separeted_str = implode("', '", $data);
         $fillable = "['";
         $fillable .= $comma_separeted_str;
         $fillable .= "']";
         $this->call('crud:controller', ['name' => str_plural($name) . 'Controller', '--crud-name' => $name]);
         $this->call('crud:model', ['name' => str_singular($name), '--fillable' => $fillable]);
         $this->call('crud:migration', ['name' => str_plural(strtolower($name)), '--schema' => $fields]);
         $this->call('crud:view', ['name' => $name, '--fields' => $fields]);
         //add CrudName to left menu
         $this->call('crud:menu', ['name' => $name]);
         //append crudName to custom_routes.php
         $this->call('crud:route', ['name' => $name]);
     } else {
         $this->call('make:controller', ['name' => $name . 'Controller']);
         $this->call('make:model', ['name' => $name]);
     }
     // Commit Database migration
     $this->call('migrate');
 }
コード例 #4
0
ファイル: Model.php プロジェクト: RHT-Memphis/adc
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Models path defined in .env
     $model = $this->argument('model');
     $modelPath = env('MODELS');
     $s = file_get_contents('app/Console/Commands/stubs/Model.stub');
     $s = $this->replace($s, $model);
     $output = $modelPath . str_singular($model) . '.php';
     file_put_contents($output, $s);
     // {-c} Controller
     if ($this->option('c')) {
         $s = file_get_contents('app/Console/Commands/stubs/Controller.stub');
         $s = $this->replace($s, $model);
         $output = "app/Http/Controllers/" . str_plural($model) . 'Controller.php';
         file_put_contents($output, $s);
         $this->line($s);
     }
     // {-m} Migration
     if ($this->option('m')) {
         $s = file_get_contents('app/Console/Commands/stubs/Schema.stub');
         $s = $this->replace($s, $model);
         $output = "database/migrations/" . date('Y_m_d_his') . "_create_" . str_plural($model) . 'table.php';
         file_put_contents($output, $s);
         $this->line($s);
     }
     // {-s} Seeder
     if ($this->option('s')) {
         $s = file_get_contents('app/Console/Commands/stubs/Seeder.stub');
         $s = $this->replace($s, $model);
         $output = "database/seeds/" . str_plural($model) . 'TableSeeder.php';
         file_put_contents($output, $s);
     }
 }
コード例 #5
0
 public function likeCount()
 {
     $count = $this->entity->likes->count();
     $plural = str_plural('Like', $count);
     $count = $this->entity->likes()->count();
     return $count > 0 ? $count . " people like it." : "Nobody cares.";
 }
コード例 #6
0
 /**
  * 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());
     }
 }
コード例 #7
0
ファイル: View.php プロジェクト: thapavishal/laravel-crud
 /**
  * write table body
  */
 function renderTableBody()
 {
     //head
     $content = '<thead>' . PHP_EOL;
     //tr
     $content .= '<tr>' . PHP_EOL;
     //you know the rest just creating a table with head and body
     foreach ($this->fieldArr as $fieldName => $value) {
         $content .= '<th> ' . $fieldName . '</th>' . PHP_EOL;
     }
     $content .= '</tr>' . PHP_EOL;
     $content .= "<thead>" . PHP_EOL;
     $content .= "<tbody>" . PHP_EOL;
     $content .= '@foreach( ' . str_plural($this->modelVar) . ' as ' . $this->modelVar . ')' . PHP_EOL;
     foreach ($this->fieldArr as $fieldName => $value) {
         $content .= '<td>{!! ' . $this->modelVar . '->' . $fieldName . ' !!}</td>' . PHP_EOL;
     }
     $content .= '@endforeach' . PHP_EOL;
     $content .= "</tbody>" . PHP_EOL;
     $this->tableContent = $content;
     //writing the list file
     //ToDo Needs to come from template file
     $target = $this->viewTarget . '/' . str_slug($this->modelName) . "/list.blade.php";
     $template = '/vendor/developernaren/laravel-crud/src/DeveloperNaren/Crud/Templates/ListView.txt';
     $contentKeyArr = get_object_vars($this);
     $this->write($template, $contentKeyArr, $target);
 }
 /**
  * Populate the name, options and path variables.
  *
  * @return void
  */
 protected function populateVars()
 {
     $this->placeholder['App'] = str_replace('/', '\\', $this->argument('app'));
     $this->placeholder['AppPath'] = str_replace('\\', '/', $this->placeholder['App']);
     $this->placeholder['Resource'] = $this->argument('resourceName');
     $this->placeholder['resource'] = str_replace('_', '-', strtolower(snake_case($this->placeholder['Resource'])));
     $this->placeholder['Resources'] = $this->option('rn-plural') ? $this->option('rn-plural') : str_plural($this->argument('resourceName'));
     $this->placeholder['resources'] = str_replace('_', '-', strtolower(snake_case($this->placeholder['Resources'])));
     $this->placeholder['NamespacePath'] = $this->option('namespace') ? $this->option('namespace') : $this->placeholder['AppPath'] . '/' . $this->placeholder['Resources'];
     $this->placeholder['Namespace'] = str_replace('/', '\\', $this->placeholder['NamespacePath']);
     $this->placeholder['isViewableResource'] = $this->option('is-viewable-resource') ? true : false;
     $this->placeholder['tests'] = $this->option('no-tests') ? false : true;
     $this->placeholder['views'] = $this->option('no-views') ? false : true;
     if ($this->option('contract-ext')) {
         if (preg_match('/\\\\|\\//', $this->option('contract-ext'))) {
             $this->placeholder['contractExt'] = str_replace('/', '\\', $this->option('contract-ext'));
             $this->placeholder['contract'] = substr($this->placeholder['contractExt'], strrpos($this->placeholder['contractExt'], '\\') + 1);
         } else {
             $this->placeholder['contractExt'] = $this->placeholder['App'] . '\\Contracts\\' . $this->option('contract-ext');
             $this->placeholder['contract'] = $this->option('contract-ext');
         }
     }
     if ($this->option('handler-imp')) {
         if (preg_match('/\\\\|\\//', $this->option('handler-imp'))) {
             $this->placeholder['handlerImp'] = str_replace('/', '\\', $this->option('handler-imp'));
             $this->placeholder['handler'] = substr($this->placeholder['handlerImp'], strrpos($this->placeholder['handlerImp'], '\\') + 1);
         } else {
             $this->placeholder['handlerImp'] = $this->placeholder['App'] . '\\Contracts\\' . $this->option('handler-imp');
             $this->placeholder['handler'] = $this->option('handler-imp');
         }
     }
 }
コード例 #9
0
ファイル: EntitiesController.php プロジェクト: joadr/cms
 public function show($id)
 {
     $item = $this->driver->get($id);
     $entity = $this->entity;
     $this->layout->title = str_plural($entity->name);
     $this->layout->content = \View::make('admin.entities.show', compact('item', 'entity'));
 }
コード例 #10
0
ファイル: Factory.php プロジェクト: guratr/cruddy
 /**
  * Add relation field type.
  *
  * @param Entity $entity
  * @param Collection            $collection
  * @param string                $id
  * @param string                $ref
  * @param bool                  $inline
  *
  * @return BasicRelation
  */
 public function relates($entity, $collection, $id, $ref = null, $inline = false)
 {
     if ($ref === null) {
         $ref = str_plural($id);
     }
     $ref = $entity->getEntitiesRepository()->resolve($ref);
     $model = $entity->newModel();
     if (!method_exists($model, $id)) {
         $className = get_class($model);
         throw new \RuntimeException("The target model [{$className}] doesn't have relation [{$id}] defined.");
     }
     $relation = $model->{$id}();
     if (!$relation instanceof Relation) {
         $className = get_class($model);
         throw new \RuntimeException("The method [{$id}] of model [{$className}] did not return valid relation.");
     }
     $relationClassName = class_basename($relation);
     $className = __NAMESPACE__ . '\\' . ($inline ? 'InlineTypes' : 'Types') . '\\' . $relationClassName;
     if (!class_exists($className)) {
         throw new \RuntimeException("Cruddy does not know how to handle [{$relationClassName}] relation.");
     }
     $instance = new $className($entity, $id, $ref, $relation);
     $collection->add($instance);
     return $instance;
 }
コード例 #11
0
ファイル: RESTModel.php プロジェクト: andizzle/rest-framework
 /**
  * Get the root of model for the payload
  *
  * @return string
  */
 public function getRoot()
 {
     if ($this->root) {
         return $this->root;
     }
     return str_plural(strtolower(class_basename(get_class($this))));
 }
コード例 #12
0
 public function rollback($entity, $id)
 {
     $modelString = 'Yab\\Quarx\\Models\\' . ucfirst($entity);
     if (!class_exists($modelString)) {
         $modelString = 'Yab\\Quarx\\Models\\' . ucfirst($entity) . 's';
     }
     if (!class_exists($modelString)) {
         $modelString = 'Quarx\\Modules\\' . ucfirst(str_plural($entity)) . '.\\Models\\' . ucfirst(str_plural($entity));
     }
     if (!class_exists($modelString)) {
         $modelString = 'Quarx\\Modules\\' . ucfirst(str_plural($entity)) . '\\Models\\' . ucfirst(str_singular($entity));
     }
     if (!class_exists($modelString)) {
         $modelString = 'Quarx\\Modules\\' . ucfirst(str_singular($entity)) . '\\Models\\' . ucfirst(str_singular($entity));
     }
     if (!class_exists($modelString)) {
         Quarx::notification('Could not rollback Model not found', 'warning');
         return redirect(URL::previous());
     }
     $model = new $modelString();
     $modelInstance = $model->find($id);
     $archive = Archive::where('entity_id', $id)->where('entity_type', $modelString)->limit(1)->offset(1)->orderBy('id', 'desc')->first();
     if (!$archive) {
         Quarx::notification('Could not rollback', 'warning');
         return redirect(URL::previous());
     }
     $archiveData = (array) json_decode($archive->entity_data);
     $modelInstance->fill($archiveData);
     $modelInstance->save();
     Quarx::notification('Rollback was successful', 'success');
     return redirect(URL::previous());
 }
コード例 #13
0
 private function normalizeObject($object)
 {
     $normalized_object = [];
     $normalized_collections = [];
     foreach ($object as $key => $value) {
         if (is_array($value)) {
             if (array_key_exists('id', $value)) {
                 #if (is_array($))
                 if (!array_key_exists(str_plural($key), $normalized_collections)) {
                     $normalized_collections[str_plural($key)] = [];
                 }
                 $result = $this->normalizeObject($value);
                 array_push($normalized_collections[str_plural($key)], $result['object']);
                 $normalized_collections = $this->mergeCollections($normalized_collections, $result['collections']);
                 $normalized_object[$key] = $result['object']['id'];
             } else {
                 if (in_array('id', array_keys($value))) {
                     $normalized_collections = $this->mergeCollections($normalized_collections, $this->normalizeCollection($key, $value));
                     $normalized_object[$key] = array_map(function ($object) {
                         return $object['id'];
                     }, $value);
                 } else {
                     $normalized_object[$key] = $value;
                 }
             }
         } else {
             $normalized_object[$key] = $value;
         }
     }
     return ['object' => $normalized_object, 'collections' => $normalized_collections];
 }
コード例 #14
0
ファイル: ApiMakeCommand.php プロジェクト: pkfrom/l5-api
 protected function setRouteData()
 {
     $name = str_replace('\\', '', $this->stubVariables['model']['fullNameWithoutRoot']);
     $name = snake_case($name);
     $this->stubVariables['route']['name'] = str_plural($name);
     return $this;
 }
コード例 #15
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $camelCasedSingularName = $this->ask('Nom de la resource en camelCase [maNouvelleResourceEnCamelCase]');
     $ucFirstSingularName = ucfirst($camelCasedSingularName);
     $camelCasedPluralName = str_plural($camelCasedSingularName);
     $ucFirstPluralName = str_plural($ucFirstSingularName);
     //Todo : proposer plusieurs choix en fonction des modules/packages au lieu que le seul namespace app
     $namespace = $this->ask('Namespace du domaine de la resource', 'App\\Domain\\' . $ucFirstSingularName);
     //Todo : proposer plusieurs choix en fonction des modules/packages au lieu que le seul dossier app
     $directory = $this->ask('Répertoire de la resource', 'app/Domain/' . $ucFirstSingularName);
     //Todo : proposer plusieurs choix en fonction des modules/packages au lieu que le seul namespace app
     $namespaceController = $this->ask('Namespace du controller de la resource', 'App\\Http\\Controllers\\Api\\v1');
     //Todo : proposer plusieurs choix en fonction des modules/packages au lieu que le seul dossier app
     $directoryController = $this->ask('Répertoire du controlleur', 'app/Http/Controllers/Api/v1');
     $this->generateModel($namespace, $directory, $ucFirstSingularName);
     $this->info('Model généré !');
     $this->generateValidator($namespace, $directory, $ucFirstSingularName);
     $this->info('Validator généré !');
     $this->generateService($namespace, $directory, $ucFirstSingularName);
     $this->info('Service généré !');
     $this->generateTransformer($namespace, $directory, $ucFirstSingularName, $camelCasedSingularName, $camelCasedPluralName);
     $this->info('Transformer généré !');
     $this->generateController($namespaceController, $directoryController, $ucFirstPluralName, $namespace, $ucFirstSingularName, $camelCasedPluralName);
     $this->info('Controller généré !');
     //$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
 }
コード例 #16
0
 public static function boot()
 {
     parent::boot();
     /*
      * Adds a ModelHistory entry to the model after creating the model
      */
     self::created(function ($model) {
         $model->history()->create(['link' => Route::has(str_plural(strtolower(class_basename($model))) . '.show') ? route(str_plural(strtolower(class_basename($model))) . '.show', [$model->id]) : null, 'message' => 'Created new ' . strtolower(class_basename($model)) . ' "' . self::getObjectLabel($model) . '"']);
     });
     /*
      * Adds a ModelHistory entry to the model after updating the model
      */
     self::updating(function ($model) {
         /*
          * Gets the model's altered values and tracks what had changed
          */
         $changes = $model->getDirty();
         $changed = [];
         foreach ($changes as $key => $value) {
             $changed[] = ['key' => $key, 'old' => $model->getOriginal($key), 'new' => $model->{$key}];
         }
         $model->history()->create(['message' => 'Updating ' . strtolower(class_basename($model)) . ' "' . self::getObjectLabel($model) . '"', 'link' => Route::has(str_plural(strtolower(class_basename($model))) . '.show') ? route(str_plural(strtolower(class_basename($model))) . '.show', [$model->id]) : null, 'additional_information' => json_encode($changed)]);
     });
     /*
      * Adds a ModelHistory entry to the model prior to deleting it
      */
     self::deleting(function ($model) {
         $model->history()->create(['message' => 'Deleting ' . strtolower(class_basename($model)) . ' "' . self::getObjectLabel($model) . '"']);
     });
 }
コード例 #17
0
 /**
  * Get the collection name associated with the model.
  *
  * @return string
  */
 public function getCollection()
 {
     if (isset($this->collection)) {
         return $this->collection;
     }
     return str_replace('\\', '', snake_case(str_plural(class_basename($this))));
 }
コード例 #18
0
ファイル: MakeAdmin.php プロジェクト: administrcms/administr
 public function handle()
 {
     $name = trim($this->argument('name'));
     $nameSingular = str_singular($name);
     $status = 0;
     $controllerCmdArgs = ['name' => "{$name}Controller"];
     if ($this->option('translated')) {
         $controllerCmdArgs['--translated'] = true;
     }
     $status = $this->call('administr:controller', $controllerCmdArgs);
     $status = $this->call('administr:form', ['name' => "{$nameSingular}Form"]);
     $modelCmdArgs = ['name' => $nameSingular];
     if ($this->option('translated')) {
         $modelCmdArgs['--translated'] = true;
     }
     $status = $this->call('administr:model', $modelCmdArgs);
     $status = $this->call('administr:listview', ['name' => "{$name}ListView"]);
     $status = $this->call('make:seed', ['name' => "{$name}Seeder"]);
     $table = str_plural(snake_case(class_basename($name)));
     $status = $this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]);
     if ($status !== 0) {
         $this->error('Some of the commands were not executed successfuly.');
     }
     $this->info('Admin scaffold generated!');
 }
コード例 #19
0
ファイル: ExportController.php プロジェクト: marcoax/laraCms
 /**
  * @param $model
  */
 public function init($model)
 {
     $this->model = $model;
     $this->config = config('laraCms.admin.list.section.' . $this->model);
     $this->models = strtolower(str_plural($this->config['model']));
     $this->modelClass = 'App\\' . $this->config['model'];
 }
コード例 #20
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // check if module exists
     if ($this->files->exists(app_path() . '/Modules/' . $this->getNameInput())) {
         return $this->error($this->type . ' already exists!');
     }
     // Create Controller
     $this->generate('controller');
     // Create Model
     $this->generate('model');
     // Create Views folder
     $this->generate('view');
     //Flag for no translation
     if (!$this->option('no-translation')) {
         // Create Translations folder
         $this->generate('translation');
     }
     // Create Routes file
     $this->generate('routes');
     if (!$this->option('no-migration')) {
         $table = str_plural(snake_case(class_basename($this->argument('name'))));
         $this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]);
     }
     $this->info($this->type . ' created successfully.');
 }
コード例 #21
0
ファイル: Resource.php プロジェクト: ndrx-io/elude
 /**
  * @return string
  */
 public function generate()
 {
     $route = "\n        " . '$app->resource("%s", \\App\\Http\\Controllers\\Api\\%s::class);';
     $model = $this->get('model');
     $modelPlural = str_plural($model);
     return sprintf($route, $modelPlural, $model);
 }
コード例 #22
0
 /**
  * Get the resource name associated with the model.
  *
  * @return string
  */
 public function getResourceName()
 {
     if (isset($this->resourceName)) {
         return $this->resourceName;
     }
     return str_replace('\\', '', snake_case(str_plural(class_basename($this))));
 }
コード例 #23
0
 /**
  * Build the model class with the given name.
  *
  * @param  string  $name
  * @return string
  */
 protected function buildClass($name)
 {
     $stub = $this->files->get($this->getStub());
     $table = $this->option('table') ?: strtolower(str_plural($this->getNameInput()));
     $fillable = $this->option('fillable');
     return $this->replaceNamespace($stub, $name)->replaceTable($stub, $table)->replaceFillable($stub, $fillable)->replaceClass($stub, $name);
 }
コード例 #24
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $name = ucwords(strtolower($this->argument('name')));
     if ($this->option('fields')) {
         $fields = $this->option('fields');
         $primaryKey = $this->option('pk');
         $viewPath = $this->option('view-path');
         $fillableArray = explode(',', $fields);
         foreach ($fillableArray as $value) {
             $data[] = preg_replace("/(.*?):(.*)/", "\$1", trim($value));
         }
         $commaSeparetedString = implode("', '", $data);
         $fillable = "['" . $commaSeparetedString . "']";
         $this->call('crud:controller', ['name' => $name . 'Controller', '--crud-name' => $name, '--view-path' => $viewPath]);
         $this->call('crud:model', ['name' => str_plural($name), '--fillable' => $fillable]);
         $this->call('crud:migration', ['name' => str_plural(strtolower($name)), '--schema' => $fields, '--pk' => $primaryKey]);
         $this->call('crud:view', ['name' => $name, '--fields' => $fields, '--path' => $viewPath]);
     } else {
         $this->call('make:controller', ['name' => $name . 'Controller']);
         $this->call('make:model', ['name' => $name]);
     }
     // Updating the Http/routes.php file
     $routeFile = app_path('Http/routes.php');
     if (file_exists($routeFile) && strtolower($this->option('route')) === 'yes') {
         $isAdded = File::append($routeFile, "\nRoute::resource('" . strtolower($name) . "', '" . $name . "Controller');");
         if ($isAdded) {
             $this->info('Crud/Resource route added to ' . $routeFile);
         } else {
             $this->info('Unable to add the route to ' . $routeFile);
         }
     }
 }
コード例 #25
0
ファイル: CleanCommand.php プロジェクト: bmartel/transient
 /**
  * Execute the console command.
  *
  * @throws \Bmartel\Transient\Exception\InvalidObjectTypeException
  * @return mixed
  */
 public function fire()
 {
     // If user provided a class as an argument,
     // ensure its a valid class which implments \Bmartel\Transient\TransientPropertyInterface.
     if ($class = $this->argument('modelClass')) {
         // Parse the class
         $model = $this->inputParser->parse($class);
         $modelType = $this->app->make($model);
         if (!$modelType instanceof TransientPropertyInterface) {
             throw new InvalidObjectTypeException('Class does not implement \\Bmartel\\Transient\\TransientPropertyInterface');
         }
     }
     // If user provided property options, parse them into an array for querying.
     if ($properties = $this->option('properties')) {
         $transientProperties = $this->inputParser->parseProperties($properties);
     }
     $result = null;
     // Determine what parameters to base the transient removal on.
     if (isset($transientProperties) && isset($modelType)) {
         $result = $this->transient->deleteByModelProperty($modelType, $transientProperties);
     } elseif (isset($modelType)) {
         $result = $this->transient->deleteByModelType($modelType);
     } elseif (isset($transientProperties)) {
         $result = $this->transient->deleteByProperty($transientProperties);
     } else {
         $result = $this->transient->deleteAll();
     }
     $propertiesName = str_plural('property', $result);
     // Report the result of the command
     $this->info("All done! Removed {$result} transient {$propertiesName}.");
 }
コード例 #26
0
ファイル: MakeChart.php プロジェクト: asgard83/gov-maker
 private function formatTableName($model)
 {
     $model = $this->formatModelName($model);
     $model = snake_case($model);
     $model = strtolower($model);
     return $model = str_plural($model);
 }
コード例 #27
0
ファイル: CrudController.php プロジェクト: ThunderID/Halo
 function __construct()
 {
     parent::__construct();
     // ------------------------------------------------------------------------------------
     // MODEL
     // ------------------------------------------------------------------------------------
     if (!$this->model) {
         throw new Exception('Please initialize $model', 1);
     }
     // ------------------------------------------------------------------------------------
     // FILTERS
     // ------------------------------------------------------------------------------------
     if (!$this->filters) {
         throw new Exception('Please initialize $filters', 1);
     }
     // ------------------------------------------------------------------------------------
     // CRUD NAME
     // ------------------------------------------------------------------------------------
     if (!$this->crud_name) {
         throw new Exception('Please initialize $crud_name', 1);
     } else {
         $this->views['pages'] = $this->views['pages'] . str_plural($this->crud_name) . '.';
     }
     // ------------------------------------------------------------------------------------
     // STORE Command
     // ------------------------------------------------------------------------------------
     if (!$this->store_command) {
         throw new Exception('Please initialize $store_command', 1);
     }
 }
コード例 #28
0
ファイル: StrTest.php プロジェクト: hyhyxu/hook
 public function testStrings()
 {
     $this->assertTrue(str_singular('match') == 'match');
     $this->assertTrue(str_singular('matches') == 'match');
     $this->assertTrue(str_plural('matches') == 'matches');
     $this->assertTrue(str_plural('match') == 'matches');
 }
コード例 #29
0
 /**
  * Saves all datamodels in all services to the database.
  */
 public function save()
 {
     $data = $this->getData();
     $repo = \App::make(YoutubeRepository::class);
     call_user_func([$repo, 'save' . ucfirst(str_plural($this->_params->get('resource')['name']))], $data);
     event(new PackageSaved($this));
 }
コード例 #30
0
 public function __construct(Model $model)
 {
     parent::__construct();
     $this->model = $model;
     $this->folder = strtolower(str_plural(last(array_slice(explode('\\', get_class($this->model)), 0))));
     $this->viewPath = 'kit::' . $this->folder;
 }