protected function replaceClass($stub, $name) { $stub = parent::replaceClass($stub, $name); $noControllerName = str_replace('Controller', '', $this->getNameInput()); $dummyRoute = config('administr.prefix') . '.' . str_plural(strtolower(snake_case($noControllerName, '-'))); $stub = str_replace('dummyroute', $dummyRoute, $stub); $appNamespace = $this->getLaravel()->getNamespace(); $dummyModel = str_singular($noControllerName); $dummyModelNamespaced = $appNamespace . 'Models\\' . $dummyModel; $stub = str_replace('DummyModelNamespaced', $dummyModelNamespaced, $stub); $stub = str_replace('DummyModel', $dummyModel, $stub); $dummyForm = str_singular($noControllerName) . 'Form'; $dummyFormNamespaced = $appNamespace . 'Http\\Forms\\' . $dummyForm; $stub = str_replace('DummyFormNamespaced', $dummyFormNamespaced, $stub); $stub = str_replace('DummyForm', $dummyForm, $stub); $dummyListView = str_plural($noControllerName) . 'ListView'; $dummyListViewNamespaced = $appNamespace . 'Http\\ListViews\\' . $dummyListView; $stub = str_replace('DummyListViewNamespaced', $dummyListViewNamespaced, $stub); $stub = str_replace('DummyListView', $dummyListView, $stub); $viewPath = config('administr.viewPath'); if (strlen($viewPath) > 0) { $viewPath .= '.'; } $dummyView = $viewPath . str_plural(snake_case(class_basename($noControllerName), '-')); $stub = str_replace('dummyview', $dummyView, $stub); return $stub; }
/** * Constructor function * * @param string $type * @param array $items */ public function __construct($type, $singular = '', $items = array(), $modelClassName) { $this->entity = $type; $this->entity_singular = $singular ?: str_singular($type); $this->setItems($items); $this->modelClassName = $modelClassName; }
/** * Get contents for base.stub * * @author Verron Knowles <*****@*****.**> * @return string */ protected function buildClassContents($name, $stub_data) { $table_name = $this->getTableName($name); $simple_name = str_singular($table_name); $proper_name = $this->getProperName($simple_name); $model_name = $this->input->getOption('model'); // Setup fillable namespace $fillable = array(); foreach ($stub_data as $stubname => $column) { if (empty(strpos($stubname, '&'))) { if (!in_array($column['name'], $this->ignore_items, $column['name'])) { $column_name = $column['name']; $fillable[] = "\"{$column_name}\""; } } } $fillable = implode(",", $fillable); $stub_contents = ""; foreach ($this->stub_names as $view) { $stub_location = $this->getStubDirectory() . "{$view}.stub"; if ($this->files->isFile($stub_location)) { $stub_contents .= file_get_contents($stub_location) . "\n"; } } // Build replacement tags $replacements = compact('proper_name', 'simple_name', 'model_name', 'table_name', 'fillable'); $this->replaceTag($stub_contents, $replacements); return $stub_contents; }
/** * Create a singular version of this name. Allows us to override * any names that str_singular doesn't do correctly. * * @param string $name * @return string */ protected function singular($name) { if ($name == "menus") { return "menu"; } return str_singular($name); }
public function goToView($route, $parentAssociation, $additionalAssigns, $content) { $route_array = explode('.', $route); if (count($route_array) == 2) { $parent = $route_array[0]; $action = $route_array[1]; $controller = $parent; } elseif (count($route_array) == 3) { $parent = $route_array[0]; $child = $route_array[1]; $action = $route_array[2]; $controller = $child; } else { throw new InvalidArgumentException("{$route} is not in correct format"); } $assignStr = str_singular($controller); $assigns = array($assignStr => $content); if (!null_or_empty($parentAssociation)) { $assigns = array_merge($assigns, $parentAssociation); } if (!null_or_empty($additionalAssigns)) { $assigns = array_merge($assigns, $additionalAssigns); } return $this->view->make($controller . "." . $action, $assigns); }
/** * Show the form for creating a new resource. * GET /model/create * * @return Response */ public function create() { $model_class = $this->config->get('entrust.' . str_singular($this->resource)); $model = new $model_class(); $relations = $this->relation->lists('name', 'id'); return view('entrust-gui::' . $this->resource . '.create', compact('model', 'relations')); }
/** * Add include to the construct method * * @param $stub * @param $include * @return $this */ private function addInclude(&$stub, $include) { $stub = str_replace('DummyIncludeCamel', camel_case($include), $stub); $stub = str_replace('DummyIncludeStudly', studly_case($include), $stub); $stub = str_replace('DummyIncludeSingleStudly', studly_case(str_singular($include)), $stub); return $this; }
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'); }
/** * Handle the command. * */ public function handle() { $module = $this->module; $stream = $this->stream; $assignment = $this->assignment; $destination = $module->getPath(); $entity = __DIR__ . '/../../resources/stubs/entity'; $source = $entity . '/code/{{namespace|studly_case}}/'; /* get the field config params from build.php */ $fieldConfig = _getFieldConfig($module, $stream->getNamespace(), $assignment->getFieldSlug()); /* protect module classes from being overwriten */ $this->files->setAvoidOverwrite(_config('builder.avoid_overwrite', $module)); /* get the template data */ $data = ['config' => _config('builder', $module), 'field_slug' => $assignment->getFieldSlug(), 'vendor' => $module->getVendor(), 'module_slug' => $module->getSlug(), 'namespace' => $stream->getNamespace(), 'stream_slug' => $stream->getSlug(), 'entity_name' => studly_case(str_singular($stream->getSlug())), 'column_template' => $fieldConfig['column_template']]; $entityDest = $destination . '/src/' . (_config('builder.group', $module) ? $data['namespace'] . '/' : '') . $data['entity_name']; /* get the assigned class name, i.e. TextFieldType */ $fieldTypeClassName = _getFieldTypeClassName($assignment); /* (1) process the form builder class */ if (!$fieldConfig['hide_field']) { $this->processFormBuilder($entityDest . '/Form/' . $data['entity_name'] . 'FormBuilder.php', $entity . '/templates/field/form/', $fieldTypeClassName, $data); } /* (2) process the table column class */ if (!$fieldConfig['hide_column']) { $this->processTableColumns($entityDest . '/Table/' . $data['entity_name'] . 'TableColumns.php', $entity . '/templates/field/table/' . ($data['column_template'] ? 'template/' : ''), $fieldTypeClassName, $data); } /* (3) process the field language file */ $this->processFile($destination . '/resources/lang/en/field.php', [$data['field_slug'] => $entity . '/templates/module/field.php'], $data); }
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!'); }
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()); }
/** * Gets model names for the main navigation * * @return array */ public function getMainArea($currentArea) { $mainArea = ''; $currentArea = str_singular($currentArea); foreach (config('admin.navigation_tree') as $parent) { if (!$parent['children']) { if ($currentArea == $parent['name']) { $mainArea = $parent['name']; } } else { foreach ($parent['children'] as $child) { if (!$child['children']) { if ($currentArea == $child['name']) { $mainArea = $parent['name']; } } else { foreach ($child['children'] as $grandchild) { if ($currentArea == $grandchild['name']) { $mainArea = $parent['name']; } } } } } } return $mainArea; }
/** * Get the class name for the Eloquent model generator. * * @return string */ protected function getModelName() { if ($this->option('model')) { return trim($this->option('model')); } return ucwords(str_singular(camel_case($this->meta['table']))); }
/** * Handle the command. * */ public function handle() { $stream = $this->stream; $module = $this->module; $entityPath = __DIR__ . '/../../resources/stubs/entity'; $modulePath = __DIR__ . '/../../resources/stubs/module'; $dest = $module->getPath(); /* seed file path for this entity */ $seedFile = "{$dest}/resources/seeders/" . strtolower(str_singular($stream->getSlug())) . ".php"; $data = ['config' => _config('builder', $module), 'vendor' => $module->getVendor(), 'namespace' => $stream->getNamespace(), 'module_slug' => $module->getSlug(), 'stream_slug' => $stream->getSlug(), 'entity_name' => studly_case(str_singular($stream->getSlug())), 'seeder_data' => file_exists($seedFile) ? file_get_contents($seedFile) : '']; $moduleName = studly_case($data['module_slug']); /* protect module classes from being overwriten */ $this->files->setAvoidOverwrite(_config('builder.avoid_overwrite', $module)); /* initially, copy the entity template files to the module src folder */ if (_config('builder.group', $module)) { $this->files->parseDirectory($entityPath . "/code/", "{$dest}/src", $data); } else { $this->files->parseDirectory($entityPath . "/code/{{namespace|studly_case}}/", "{$dest}/src", $data); $this->files->parseDirectory($entityPath . "/code/Http", "{$dest}/src/Http", $data); } /* create an empty seeder if it does not exist */ $this->put("{$dest}/resources/seeders/" . strtolower($data['entity_name']) . '.php', '', true); try { /* stitch the entity with the module classes */ $this->processFile("{$dest}/src/{$moduleName}" . 'ModuleServiceProvider.php', ['routes' => $entityPath . '/templates/module/routes.php', 'bindings' => $entityPath . '/templates/module/bindings.php', 'singletons' => $entityPath . '/templates/module/singletons.php'], $data); $this->processFile("{$dest}/src/{$moduleName}" . 'Module.php', ['sections' => $entityPath . '/templates/module/sections.php'], $data); $this->processFile("{$dest}/src/{$moduleName}" . 'ModuleSeeder.php', ['seeders' => $entityPath . '/templates/module/seeding.php'], $data); $this->processFile("{$dest}/resources/lang/en/section.php", [strtolower(str_plural($data['entity_name'])) => $entityPath . '/templates/module/section.php'], $data); $this->processFile("{$dest}/resources/config/permissions.php", [$data['stream_slug'] => $entityPath . '/templates/module/permissions.php'], $data); $this->processFile("{$dest}/resources/lang/en/stream.php", [$data['stream_slug'] => $entityPath . '/templates/module/stream.php'], $data); $this->processFile("{$dest}/resources/lang/en/permission.php", [$data['stream_slug'] => $entityPath . '/templates/module/permission.php'], $data); } catch (\PhpParser\Error $e) { die($e->getMessage()); } }
public function __construct() { //$this->beforeFilter(function(){ }); $this->uriSegment = null; $this->modelName = null; $this->viewsPath = null; $this->resourceId = null; if (Route::input('alias') !== null) { $this->uriSegment = Route::input('alias'); $this->viewsPath = File::exists(app_path('views/' . Config::get('reactiveadmin::uri') . '/' . $this->uriSegment)) ? Config::get('reactiveadmin::uri') . '.' . $this->uriSegment : 'reactiveadmin::default'; $this->modelName = studly_case(str_singular(Route::input('alias'))); $this->modelWrapper = App::make('model_wrapper'); $this->modelWrapper->model($this->modelName); if (Route::input('id') !== null) { $this->resourceId = Route::input('id'); } View::share('config', $this->modelWrapper->getConfig()); // TODO: refactor this! // custom behavior switch ($this->uriSegment) { case 'settings': View::composer(array('admin.' . $this->viewsPath . '.index'), function ($view) { $view->with('settings', Settings::all()); }); break; default: # code... break; } } View::share('view', $this->uriSegment); View::share('model', $this->modelName); }
public function assertRelationship($relationship, $class, $type) { $this->assertRespondsTo($relationship, $class); $class = Mockery::mock($class . "[{$type}]"); $class->shouldReceive($type)->with('/' . str_singular($relationship) . '/i')->once(); $class->{$relationship}(); }
public function parse($source) { if ($this->parent->configHas('data')) { $data = $this->parent->getConfig('data'); foreach ($data as $accessor) { $classAccessor = $this->getClassAccessor($accessor); $classMethod = $this->getClassMethod($accessor); $classMethodId = $this->getClassMethodId($accessor); if (isset($this->classes[$classAccessor])) { $class = $this->classes[$classAccessor]; if (!is_null($classMethodId)) { if (starts_with($classMethodId, '#')) { $id = $this->realNumber($classMethodId); } else { $id = $classMethodId; } $dataObject = $class->{$classMethod}($id); $this->parent->setAttribute(str_singular($classAccessor), $dataObject); } else { $dataObject = $class->{$classMethod}(); $this->parent->setAttribute($classAccessor, $dataObject); } } else { throw new \Exception("Unknown data accessor: {$accessor}."); } } } return $source; }
/** * Execute the console command. * * @return mixed */ public function handle() { $name = $this->argument('name'); $view = $name; // items $request = str_singular(ucwords(camel_case($name))) . 'Request.php'; // ItemRequest.php $model = str_singular(ucwords(camel_case($name))) . '.php'; // Item.php; $presenter = str_singular(ucwords(camel_case($name))) . 'Presenter.php'; // ItemPresenter.php; $controller = ucwords(camel_case($name)) . 'Controller.php'; // ItemsController.php $seed = ucwords(camel_case($name)) . 'TableSeeder.php'; // ItemsTableSeeder.php $views = base_path('resources/views/' . $view); $request = base_path('app/Http/Requests/' . $request); $model = base_path('app/Models/' . $model); $presenter = base_path('app/Presenters/' . $presenter); $controller = base_path('app/Http/Controllers/' . $controller); $seed = base_path('database/seeds/' . $seed); $this->files->delete([$request, $model, $presenter, $controller, $seed]); $this->files->deleteDirectory($views); $this->info('Delete ' . $views); $this->info('Delete ' . $request); $this->info('Delete ' . $model); $this->info('Delete ' . $presenter); $this->info('Delete ' . $controller); $this->info('Delete ' . $seed); $this->info('Dont forget to delete migration file and route'); }
protected function setUpModel(\Illuminate\Http\Request $request) { $uri = $request->route()->uri(); $modelSlug = strpos($uri, '/') ? substr($uri, 0, strpos($uri, '/')) : $uri; $modelName = ucfirst(camel_case(str_singular($modelSlug))); $modules = new \Ormic\Modules(); $module = $modules->getModuleOfModel($modelName); if ($module) { $modelClass = 'Ormic\\modules\\' . $module . '\\Model\\' . $modelName; $viewName = snake_case($module) . '::' . snake_case($modelName) . '.' . $this->currentAction; } else { $modelClass = 'Ormic\\Model\\' . $modelName; $viewName = snake_case($modelName) . '.' . $this->currentAction; } $this->model = new $modelClass(); $this->model->setUser($this->user); try { $this->view = view($viewName); } catch (\InvalidArgumentException $ex) { try { $this->view = view('models.' . $this->currentAction); } catch (\InvalidArgumentException $ex) { // Still no view; give up. $this->view = view(); } } $this->view->title = ucwords(str_replace('-', ' ', $modelSlug)); $this->view->modelSlug = $modelSlug; $this->view->columns = $this->model->getColumns(); $this->view->record = $this->model; }
/** * 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()); } }
protected function parseTables() { $this->tables = array_map(function ($arg) { return snake_case(str_singular($this->argument($arg))); }, ['model1', 'model2']); sort($this->tables); }
protected function fetchOptions($relatedModuleTableName) { $relatedModule = Module::where('table_name', $relatedModuleTableName)->first(); $modelName = studly_case(str_singular($relatedModule->table_name)); $data = $modelName::get(); return $data; }
public function listFiles($target, $target_action, $target_id) { $resource_type = 'App\\Models\\' . ucfirst(str_singular($target)); $uploader_id = Auth::user()->active_contact->id; if ($target == "posts") { if ($target_action == "create") { $post = Post::where('author_id', $uploader_id)->where("status_id", "=", POST_DRAFT_STATUS_ID)->where("ticket_id", $target_id)->first(); } elseif ($target_action == "edit") { $post = Post::where("id", $target_id)->first(); } $id = isset($post->id) ? $post->id : null; } elseif ($target == "tickets") { if ($target_action == "create") { $ticket = Ticket::where('status_id', TICKET_DRAFT_STATUS_ID)->where('creator_id', $uploader_id)->first(); } else { $ticket = Ticket::where("id", $target_id)->first(); } $id = isset($ticket->id) ? $ticket->id : null; } elseif ($target == "people") { $target_id = is_null($target_id) ? Auth::user()->owner->id : $target_id; $person = Person::find($target_id); $id = $person->id; } $files = is_null($id) ? [] : File::where('resource_type', $resource_type)->where("resource_id", $id)->get(); foreach ($files as $file) { $file->size = filesize(RESOURCES . DS . $file->file_path . DS . $file->file_name); } return $files; }
/** * 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'); }
private function setChildParentNames() { $parent = str_singular($this->inputs['ParentName']); $this->parent = ucwords($parent); $child = str_singular($this->inputs['ChildName']); $this->child = ucwords($child); }
/** * 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); } }
/** * Build Landing Page * * @param $routeSuffix * @param null $articleId * @throws \Exception * * @return \Illuminate\View\View */ public function landingPage($routeSuffix, $articleId = null) { $service = new ApiService(); $this->data['pageType'] = $routeSuffix; $this->data['pageContent'] = $service->read(str_singular($routeSuffix), $articleId); return view('landingPages.' . $routeSuffix, $this->data); }
/** * Replace the model name for the given stub. * * @param string $stub * @param string $name * @return string */ protected function replaceModel($stub, $name) { $model = $this->getModel($name); $stub = str_replace('{{Model}}', ucfirst($model), $stub); $stub = str_replace('{{model}}', str_singular($model), $stub); $stub = str_replace('{{models}}', str_plural($model), $stub); return $stub; }
/** * Create migration file * * @param string $tableName */ protected function createMigrationFile($tableName) { $stubPath = realpath(__DIR__ . '/../../stubs'); $stub = file_get_contents($stubPath . '/migration.stub'); $stub = str_replace(['RepositoryClass', 'RepositoryTable', 'ForeignKey', 'ForeignTable'], ['CreateRepository' . ucfirst(camel_case($tableName)) . 'Table', 'repository_' . $tableName, str_singular($tableName) . '_id', $tableName], $stub); $migrationName = date('Y_m_d_His') . '_create_repository_' . $tableName . '_table'; file_put_contents(database_path('migrations/' . $migrationName . '.php'), $stub); }
/** * Handle the command. */ public function handle(MessageBag $messages, Translator $translator) { // If we can't save or there are errors then skip it. if ($this->builder->hasFormErrors() || !$this->builder->canSave()) { return; } // If there is no model and there isn't anything specific to say, skip it. if (!$this->builder->getFormEntry() && !$this->builder->getFormOption('success_message')) { return; } $mode = $this->builder->getFormMode(); // False means no message is desired. if ($this->builder->getFormOption('success_message') === false) { return; } $entry = $this->builder->getFormEntry(); $stream = $this->builder->getFormStream(); $parameters = ['title' => is_object($entry) ? $entry->getTitle() : null, 'name' => is_object($stream) ? $stream->getName() : null]; // If the name doesn't exist we need to be clever. if (str_contains($parameters['name'], '::') && !$translator->has($parameters['name']) && $stream) { $parameters['name'] = ucfirst(str_singular(str_replace('_', ' ', $stream->getSlug()))); } elseif ($parameters['name']) { $parameters['name'] = str_singular(trans($parameters['name'])); } else { $parameters['name'] = trans('streams::entry.name'); } /** * Set the default success message. */ if ($this->builder->getFormOption('success_message') === null) { $this->builder->setFormOption('success_message', trans('streams::message.' . $mode . '_success', $parameters)); } $messages->{$this->builder->getFormOption('success_message_type', 'success')}($this->builder->getFormOption('success_message')); }