/** * Register administrator view composers. */ protected function bootAdministratorViewComposer() { view()->composer('administrator.widgets.*', function (View $view) { /** @var \Yajra\CMS\Themes\Repositories\Repository $themes */ $themes = $this->app['themes']; $theme = $themes->current(); $positions = $theme->positions; $data = []; foreach ($positions as $position) { $data[$position] = Str::title($position); } $view->with('widget_positions', $data); $view->with('theme', $theme); /** @var \Yajra\CMS\Repositories\Extension\Repository $extensions */ $extensions = $this->app['extensions']; $widgets = $extensions->allWidgets()->filter(function ($extension) { return $extension->enabled; }); $view->with('extensions', $widgets); }); view()->composer(['administrator.partials.permissions'], function (View $view) { $view->with('permissions', Permission::orderBy('resource')->get()); }); view()->composer(['system.macro.image-browser'], function (View $view) { $view->with('mediaDirectories', $this->getFileDirectories()); }); }
/** * Search for physicians. * * @return JSON */ public function search(Request $request) { $physicians = null; $searchDistance = $request->distance ? $request->distance : 0; $coords = $this->getCoordinates($request); $orderBy = $request->has('order_by') ? $request->order_by : 'distance'; $sort = $request->has('sort') ? $request->sort : 'asc'; $limit = $request->has('per_page') ? $request->per_page : '25'; // if we don't have a requested distance, we'll cycle through // our fallback distances until we get at least 1 result; // if we don't have anything by our max distance, we'll return 0. if (!$request->has('distance')) { while (!$physicians || $physicians->count() == 0) { $searchDistance = $this->getNextDistance($searchDistance); $physicians = Physician::withinDistance($coords['lat'], $coords['lon'], $searchDistance)->alias($request->alias_id)->name($request->q)->gender($request->gender); if ($searchDistance == $this->maxDistance) { break; } } } else { $physicians = Physician::withinDistance($coords['lat'], $coords['lon'], $searchDistance)->alias($request->alias_id)->name($request->q)->gender($request->gender); } $alias = Alias::find($request->alias_id); $queryMeta = ['city' => Str::title(urldecode($request->city)), 'state' => mb_strtoupper($request->state), 'zip' => $request->zip ? $request->zip : $this->getZip($request->city, $request->state), 'alias' => $alias ? $alias->alias : null, 'alias_id' => $alias ? $alias->id : null, 'aggregate' => AggregateReporter::report($physicians, $request->alias_id), 'q' => $request->q, 'gender' => $request->gender, 'count' => $physicians ? $physicians->count() : 0, 'radius' => $searchDistance, 'order_by' => $request->order_by, 'sort' => $request->sort, 'center' => ['lat' => $coords['lat'], 'lon' => $coords['lon']]]; $physicians = $physicians->orderBy($orderBy, $sort)->paginate($limit)->appends($request->query()); return $this->response->withPaginator($physicians, new PhysicianTransformer(), null, $queryMeta); }
/** * Display a listing the employees. * * @return \Illuminate\Http\Response */ public function emplist() { $str = \Request()->getRequestUri(); $id = substr($str, strrpos($str, '/') + 1, strlen($str)); $params = array('View' => Str::title($id) . ' Employee List', 'Description' => 'Manage your <strong>' . Str::title($id) . '</strong> employee records here.'); return view('employees.list', compact($params)); }
protected function select($data, $show) { $select = []; foreach ($data as $d) { if (is_array($show)) { $value = ''; foreach ($show as $show_key) { $value .= Str::title($show_key) . ': ' . $d[$show_key]; if (end($show) != $show_key) { $value .= ' | '; } } } elseif (is_callable($show)) { $value = $show($d); } else { $value = $d[$show]; } $select[$d['id']] = $value; } if (Request::has($this->name)) { $this->id = Request::get($this->name); } else { if (isset($this->value->id)) { $this->id = $this->value->id; } else { $this->id = $this->value; } } echo \Form::select($this->name, ['0' => Request::ajax() ? '(current)' : '(none)'] + $select, $this->id, $this->attributes); }
/** * Send the given notification. * * @param mixed $notifiable * @param \Illuminate\Notifications\Notification $notification * @return void */ public function send($notifiable, Notification $notification) { if (!$notifiable->routeNotificationFor('mail')) { return; } $message = $notification->toMail($notifiable); if ($message instanceof Mailable) { return $message->send($this->mailer); } $this->mailer->send($message->view, $message->data(), function ($m) use($notifiable, $notification, $message) { $recipients = empty($message->to) ? $notifiable->routeNotificationFor('mail') : $message->to; if (!empty($message->from)) { $m->from($message->from[0], isset($message->from[1]) ? $message->from[1] : null); } if (is_array($recipients)) { $m->bcc($recipients); } else { $m->to($recipients); } $m->subject($message->subject ?: Str::title(Str::snake(class_basename($notification), ' '))); foreach ($message->attachments as $attachment) { $m->attach($attachment['file'], $attachment['options']); } foreach ($message->rawAttachments as $attachment) { $m->attachData($attachment['data'], $attachment['name'], $attachment['options']); } }); }
private function generateIndex() { $templateData = $this->commandData->templatesHelper->getTemplate("index.blade", $this->viewsPath); if ($this->commandData->useSearch) { $searchLayout = $this->commandData->templatesHelper->getTemplate("search.blade", $this->viewsPath); $templateData = str_replace('$SEARCH$', $searchLayout, $templateData); $fieldTemplate = $this->commandData->templatesHelper->getTemplate("field.blade", $this->viewsPath); $fieldsStr = ""; foreach ($this->commandData->inputFields as $field) { $singleFieldStr = str_replace('$FIELD_NAME_TITLE$', Str::title(str_replace("_", " ", $field['fieldName'])), $fieldTemplate); $singleFieldStr = str_replace('$FIELD_NAME$', $field['fieldName'], $singleFieldStr); $fieldsStr .= "\n\n" . $singleFieldStr . "\n\n"; } $templateData = str_replace('$FIELDS$', $fieldsStr, $templateData); } else { $templateData = str_replace('$SEARCH$', '', $templateData); } $templateData = $this->fillTemplate($templateData); $fileName = "index.blade.php"; $headerFields = ""; foreach ($this->commandData->inputFields as $field) { $headerFields .= "<th>" . Str::title(str_replace("_", " ", $field['fieldName'])) . "</th>\n\t\t\t"; } $headerFields = trim($headerFields); $templateData = str_replace('$FIELD_HEADERS$', $headerFields, $templateData); $tableBodyFields = ""; foreach ($this->commandData->inputFields as $field) { $tableBodyFields .= "<td>{!! \$" . $this->commandData->modelNameCamel . "->" . $field['fieldName'] . " !!}</td>\n\t\t\t\t\t"; } $tableBodyFields = trim($tableBodyFields); $templateData = str_replace('$FIELD_BODY$', $tableBodyFields, $templateData); $path = $this->path . $fileName; $this->commandData->fileHelper->writeFile($path, $templateData); $this->commandData->commandObj->info("index.blade.php created"); }
private static function compileSchema() { $upSchema = ""; $downSchema = ""; $schema = ""; $newSchema = ""; $count = 1; foreach (self::$schema as $name => $values) { if (in_array($name, self::$ignore)) { continue; } $upSchema .= "\n//\n// NOTE -- {$name}\n// --------------------------------------------------\n\n{$values['up']}"; $downSchema .= "\n{$values['down']}"; // } $schema = "<?php\n\n//\n// NOTE Migration Created: " . date("Y-m-d H:i:s") . "\n// --------------------------------------------------\n\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Database\\Migrations\\Migration;\n\nclass Create" . str_replace('_', '', Str::title($name)) . "Table extends Migration {\n//\n// NOTE - Make changes to the database.\n// --------------------------------------------------\n\npublic function up()\n{\n" . $upSchema . "\n" . self::$up . "\n}\n\n//\n// NOTE - Revert the changes to the database.\n// --------------------------------------------------\n\npublic function down()\n{\n" . $downSchema . "\n" . self::$down . "\n}\n}"; $date = new \DateTime($values['create']); //$filename = date('Y_m_d_His') . "_create_" . $name . "_table.php"; $filename = $date->format('Y_m_d_His') . $count . "_create_" . $name . "_table.php"; file_put_contents(__DIR__ . "/../database/migrations/{$filename}", $schema); $schema = ""; $upSchema = ""; $downSchema = ""; $count++; } return $schema; }
/** * Generate path from argument * * @param string $argument * @return string */ public static function path($argument) { $directories = explode('/', $argument); $directories = array_map(function ($dir) { return Str::title($dir); }, $directories); return implode('/', $directories); }
/** * @return array */ public static function CKEDITORS() { $result = []; foreach (['none', 'basic', 'standard', 'full', 'TinyMCE'] as $editor) { $result[$editor] = Str::title($editor); } return $result; }
public function statuses() { $allStatuses = [static::STATUS_DRAFT, static::STATUS_PUBLISHED, static::STATUS_REMOVED]; $captions = array_map(function ($item) { return Str::title($item); }, $allStatuses); return array_combine($allStatuses, $captions); }
public function make($tag, $name = '') { $role = new $this->class(); $role->tag = $tag; $role->name = $name ?: Str::title($tag); $role->save(); return $role; }
public function make($tag, $name = '', $description = '') { $permission = new $this->class(); $permission->tag = $tag; $permission->name = $name ?: Str::title($tag); $permission->description = $description; $permission->save(); return $permission; }
/** * Display nested categories of the article. * * @return \Illuminate\Support\HtmlString */ public function slugList() { $categories = explode('/', $this->alias()); $html = []; foreach ($categories as $category) { $html[] = new HtmlString('<span class="label label-info">' . e(Str::title($category)) . '</span> '); } return new HtmlString(implode('', $html)); }
/** * Build the mail message. * * @param \Illuminate\Mail\Message $mailMessage * @param mixed $notifiable * @param \Illuminate\Notifications\Notification $notification * @param \Illuminate\Notifications\Messages\MailMessage $message * @return void */ protected function buildMessage($mailMessage, $notifiable, $notification, $message) { $this->addressMessage($mailMessage, $notifiable, $message); $mailMessage->subject($message->subject ?: Str::title(Str::snake(class_basename($notification), ' '))); $this->addAttachments($mailMessage, $message); if (!is_null($message->priority)) { $mailMessage->setPriority($message->priority); } }
/** * Send the given notification. * * @param mixed $notifiable * @param \Illuminate\Notifications\Notification $notification * @return void */ public function send($notifiable, Notification $notification) { if (!$notifiable->routeNotificationFor('mail')) { return; } $message = $notification->toMail($notifiable); $this->mailer->send($message->view, $message->toArray(), function ($m) use($notifiable, $notification, $message) { $m->to($notifiable->routeNotificationFor('mail')); $m->subject($message->subject ?: Str::title(Str::snake(class_basename($notification), ' '))); }); }
protected function seedTables() { $this->setForeignKeyChecks(false); $this->setSQLMode(); foreach ($this->tables as $tableName) { $tableNameFormatted = strpos($tableName, '_') !== false ? Str::title($tableName) : ucfirst(Str::camel($tableName)); $tableSeeder = $tableNameFormatted . 'TableSeeder'; $this->call($tableSeeder); } $this->setForeignKeyChecks(true); }
public static function processFieldInput($fieldInput, $htmlType, $validations, $searchable = false, $fillable = true) { $fieldInputs = explode(':', $fieldInput); $fieldName = array_shift($fieldInputs); $databaseInputs = implode(":", $fieldInputs); $fieldType = explode(",", $fieldInputs[0])[0]; $htmlTypeInputs = explode(':', $htmlType); $htmlType = array_shift($htmlTypeInputs); if (count($htmlTypeInputs) > 0) { $htmlTypeInputs = array_shift($htmlTypeInputs); } return ['fieldInput' => $fieldInput, 'fieldTitle' => Str::title(str_replace('_', ' ', $fieldName)), 'fieldType' => $fieldType, 'fieldName' => $fieldName, 'databaseInputs' => $databaseInputs, 'htmlType' => $htmlType, 'htmlTypeInputs' => $htmlTypeInputs, 'validations' => $validations, 'searchable' => $searchable, 'fillable' => $fillable]; }
public static function processFieldInput($fieldInput, $htmlType, $validations, $fieldSettings = []) { $fieldInputs = explode(':', $fieldInput); $fieldName = array_shift($fieldInputs); $databaseInputs = implode(':', $fieldInputs); $fieldType = explode(',', $fieldInputs[0])[0]; $htmlTypeInputs = explode(':', $htmlType); $htmlType = array_shift($htmlTypeInputs); if (count($htmlTypeInputs) > 0) { $htmlTypeInputs = array_shift($htmlTypeInputs); } return ['fieldInput' => $fieldInput, 'fieldTitle' => Str::title(str_replace('_', ' ', $fieldName)), 'fieldType' => $fieldType, 'fieldName' => $fieldName, 'databaseInputs' => $databaseInputs, 'htmlType' => $htmlType, 'htmlTypeInputs' => $htmlTypeInputs, 'validations' => $validations, 'searchable' => isset($fieldSettings['searchable']) ? $fieldSettings['searchable'] : false, 'fillable' => isset($fieldSettings['fillable']) ? $fieldSettings['fillable'] : true, 'primary' => isset($fieldSettings['primary']) ? $fieldSettings['primary'] : false, 'inForm' => isset($fieldSettings['inForm']) ? $fieldSettings['inForm'] : true, 'inIndex' => isset($fieldSettings['inIndex']) ? $fieldSettings['inIndex'] : true]; }
public static function make($name, $model = null) { $attributes = is_array($name) ? $name : ['name' => $name]; if (!is_null($model)) { $model = $model instanceof Model ? $model : new $model(); $attributes['entity_type'] = $model->getMorphClass(); $attributes['entity_id'] = $model->exists ? $model->getKey() : null; } if (!isset($attributes['label'])) { $attributes['label'] = Str::title(str_replace(['-', '_'], ' ', $name) . ($model ? ' ' . $model->getTable() : '')); } return new static($attributes); }
/** * Function to get the minimum template variables * * @return array */ public function getTemplateVars() { $entity = $this->getEntityName(); $fieldData = $this->getFieldData(); $form_rows = []; foreach ($fieldData as $property => $meta) { $display = Str::title(str_replace('_', ' ', $property)); $result['label'] = "{{ Form::label('{$property}', '{$display}:') }}"; $elementType = $this->getElementType($meta['type']); $result['element'] = "{{ Form::{$elementType}('{$property}') }}"; $form_rows[] = $result; } return ['Entity' => Str::studly($entity), 'Entities' => Str::plural(Str::studly($entity)), 'collection' => Str::plural(Str::snake($entity)), 'instance' => Str::singular(Str::snake($entity)), 'fields' => $fieldData, 'form_rows' => $form_rows]; }
private static function compileSchema() { $upSchema = ""; $downSchema = ""; $newSchema = ""; foreach (self::$schema as $name => $values) { if (in_array($name, self::$ignore)) { continue; } $upSchema .= "\n//\n// NOTE -- {$name}\n// --------------------------------------------------\n \n{$values['up']}"; $downSchema .= "\n{$values['down']}"; } $schema = "<?php\n \n//\n// NOTE Migration Created: " . date("Y-m-d H:i:s") . "\n// --------------------------------------------------\n \nclass Create" . str_replace('_', '', Str::title(self::$database)) . "Database {\n//\n// NOTE - Make changes to the database.\n// --------------------------------------------------\n \npublic function up()\n{\n" . $upSchema . "\n" . self::$up . "\n}\n \n//\n// NOTE - Revert the changes to the database.\n// --------------------------------------------------\n \npublic function down()\n{\n" . $downSchema . "\n" . self::$down . "\n}\n}"; return $schema; }
protected function processDatatables($datatables) { return $datatables->editColumn('title', function ($data) { return '<a target="_blank" href="' . $data->url_preview . '">' . $data->title . '</a>'; })->editColumn('content', function ($data) { return str_limit(strip_tags($data->content), 300); })->editColumn('author_id', function ($data) { return $data->author->name; })->editColumn('picture', function ($data) { $imgUrl = $data->picture_small_cover; return $imgUrl ? '<a target="_blank" href="' . $imgUrl . '"><img src="' . $imgUrl . '" style="max-width: 100px; max-height: 50px;"></a>' : '-'; })->editColumn('published_at', function ($data) { return $data->published_at ? $data->published_at->diffForHumans() : ''; })->editColumn('status', function ($data) { return Str::title($data->status); }); }
public static function radio($templateData, $field) { $textField = self::generateLabel($field); if (count($field['typeOptions']) > 0) { $arr = explode(',', $field['typeOptions']); foreach ($arr as $item) { $label = Str::title(str_replace('_', ' ', $item)); $textField .= "\n\t<div class=\"radio-inline\">"; $textField .= "\n\t\t<label>"; $textField .= "\n\t\t\t{!! Form::radio('\$FIELD_NAME\$', '" . $item . "', null) !!} {$label}"; $textField .= "\n\t\t</label>"; $textField .= "\n\t</div>"; } } $templateData = str_replace('$FIELD_INPUT$', $textField, $templateData); $templateData = self::replaceFieldVars($templateData, $field); return $templateData; }
/** * Writes the form language file. * * @param array $columns * @param string $model * @return void */ protected function writeLangFiles($columns, $model) { $stub = $this->getStub('lang/en/model.stub'); $values = []; foreach ($columns as $column) { $values[$column['field']] = Str::title($column['field']); $values[$column['field'] . '_help'] = 'Enter the ' . Str::title($column['field']) . ' here'; } $filePath = $this->path . '/lang/en/' . strtolower(Str::plural($model)) . '/'; $this->ensureDirectory($filePath); $filePath .= 'model.php'; if ($this->files->exists($filePath)) { $trans = $this->files->getRequire($filePath); $values = array_merge($values, array_get($trans, 'general')); } $trans = $this->wrapArray($values, "\t"); $content = $this->prepare($stub, ['fields' => trim($trans)]); $this->files->put($filePath, $content); }
private function generateIndex() { $templateData = $this->commandData->templatesHelper->getTemplate("index.blade", "Scaffold"); $templateData = $this->fillTemplate($templateData); $fileName = "index.blade.php"; $headerFields = ""; foreach ($this->commandData->inputFields as $field) { $headerFields .= "<th>" . Str::title($field['fieldName']) . "</th>\n\t\t\t"; } $headerFields = trim($headerFields); $templateData = str_replace('$FIELD_HEADERS$', $headerFields, $templateData); $tableBodyFields = ""; foreach ($this->commandData->inputFields as $field) { $tableBodyFields .= "<td>{!! \$" . $this->commandData->modelNameCamel . "->" . $field['fieldName'] . " !!}</td>\n\t\t\t\t\t"; } $tableBodyFields = trim($tableBodyFields); $templateData = str_replace('$FIELD_BODY$', $tableBodyFields, $templateData); $path = $this->path . $fileName; $this->commandData->fileHelper->writeFile($path, $templateData); $this->commandData->commandObj->info("index.blade.php created"); }
private function generateIndex() { $templateData = $this->commandData->templatesHelper->getTemplate("index.blade", $this->viewsPath); if ($this->commandData->useSearch) { $searchLayout = $this->commandData->templatesHelper->getTemplate("search.blade", $this->viewsPath); $templateData = str_replace('$SEARCH$', $searchLayout, $templateData); $fieldTemplate = $this->commandData->templatesHelper->getTemplate("field.blade", $this->viewsPath); $fieldsStr = ""; foreach ($this->commandData->inputFields as $field) { $singleFieldStr = str_replace('$FIELD_NAME_TITLE$', Str::title(str_replace("_", " ", $field['fieldName'])), $fieldTemplate); $singleFieldStr = str_replace('$FIELD_NAME$', $field['fieldName'], $singleFieldStr); $fieldsStr .= "\n\n" . $singleFieldStr . "\n\n"; } $templateData = str_replace('$FIELDS$', $fieldsStr, $templateData); } else { $templateData = str_replace('$SEARCH$', '', $templateData); } $templateData = $this->fillTemplate($templateData); $fileName = "index.blade.php"; $headerFields = ""; foreach ($this->commandData->inputFields as $field) { // Custom By @merma158 at www.innodite.com // Last TH // $headerFields .= "<th>". Str::title(str_replace("_", " ", $field['fieldName'])) . "</th>\n\t\t\t"; $headerFields .= "<th class='text-center'> {{ trans('application.model." . strtolower($this->commandData->modelName) . ".attributes." . $field['fieldName'] . "') }} </th>\n\t\t\t"; } $headerFields = trim($headerFields); $templateData = str_replace('$FIELD_HEADERS$', $headerFields, $templateData); $tableBodyFields = ""; foreach ($this->commandData->inputFields as $field) { $tableBodyFields .= "<td class='text-center'>{!! \$" . $this->commandData->modelNameCamel . "->" . $field['fieldName'] . " !!}</td>\n\t\t\t\t\t"; } $tableBodyFields = trim($tableBodyFields); $templateData = str_replace('$FIELD_BODY$', $tableBodyFields, $templateData); $path = $this->path . $fileName; $this->commandData->fileHelper->writeFile($path, $templateData); $this->commandData->commandObj->info("index.blade.php created"); }
public function generate() { $templateData = $this->commandData->templatesHelper->getTemplate('Controller', 'scaffold'); $templateData = GeneratorUtils::fillTemplate($this->commandData->dynamicVars, $templateData); if ($this->commandData->paginate) { $templateData = str_replace('$RENDER_TYPE$', 'paginate(' . $this->commandData->paginate . ')', $templateData); } else { $templateData = str_replace('$RENDER_TYPE$', 'all()', $templateData); } //$SelectOptions=""; //$SelectSource=""; $DataFields = ""; // foreach ($this->commandData->inputFields as $field) { // if (!is_null($field['typeOptions'])) // { // $SelectSource .= "$" . Str::title(str_replace('_', ' ', $field['typeOptions'])) . " = ".Config::get('generator.path_model', app_path('Models/')) . Str::title(str_replace('_', ' ', $field['typeOptions'])) . "::lists('description','id');\n\t"; // $SelectOptions .= "->with('" . Str::title(str_replace('_', ' ', $field['typeOptions'])) . "', $" . Str::title(str_replace('_', ' ', $field['typeOptions'])) . ")\n\t"; // } $DataFields .= "'" . $this->commandData->modelNameCamel . "." . Str::title(str_replace('_', ' ', $field['fieldName'])) . "',"; } // //$SelectOptions = trim($SelectOptions); //$SelectSource = trim($SelectSource); $DataFields = trim($DataFields); // $templateData = str_replace('$DATA_FIELDS$', $DataFields, $templateData); // $templateData = str_replace('$SELECTS_INPUTS$', "", $templateData); // $templateData = str_replace('$SELECTS_SOURCE$', "", $templateData); // $fileName = $this->commandData->modelName . 'Controller.php'; $path = $this->path . $fileName; $this->commandData->fileHelper->writeFile($path, $templateData); $this->commandData->commandObj->comment("\nController created: "); $this->commandData->commandObj->info($fileName); }
public static function getTranslate($word, $from, $to) { //Create path to languages models $fromModel = "App\\" . ucfirst($from) . '_Word'; $toModel = "App\\" . ucfirst($to) . '_Word'; //Create languages models objects $sWord = new $fromModel(); $tWord = new $toModel(); if (!isset($sWord)) { echo 'Not support sourse language'; } elseif (!isset($tWord)) { echo 'Not support target language'; } else { //Get sourse language id $sourseLang = Languages::where('name', $from)->get(); //Get target language id $targetLang = Languages::where('name', $to)->get(); //Get sourse word id $sWord = $sWord->where('word', $word)->get(); //Get id's from objects $sLangId = $sourseLang[0]['id']; $tLangId = $targetLang[0]['id']; $sWordId = $sWord[0]['id']; //Get result word $tWordId = Translations::where('sLangId', $sLangId)->where('tLangId', $tLangId)->where('sWordId', $sWordId)->get(); if (count($tWordId) === 0) { $tWordId = Translations::where('sLangId', $tLangId)->where('tLangId', $sLangId)->where('tWordId', $sWordId)->get(); $tWordId = $tWordId[0]['sWordId']; } else { $tWordId = $tWordId[0]['tWordId']; } $tWord = $tWord->where('id', $tWordId)->get(); $tWord = $tWord[0]['word']; mb_strtolower($word) === $word ? $result = $tWord : ($result = Str::title($tWord)); $data = array('word' => $word, 'sourse' => $from, 'target' => $to, 'result' => $result); return $data; } }
public function postCustomerEdit(NewCustomerRequest $request, Customer $customer, CustomerProfile $profile, Payment $payment) { $id = $request->input('customer_id'); $this->customer = $customer->whereId((int) $id)->update(['firstname' => Str::title($request->input('firstname')), 'lastname' => Str::title($request->input('lastname')), 'email' => Str::lower($request->input('email')), 'phone' => $request->input('phone')]); $dob = explode('/', $request->input('dob')); $dob_piece = [$dob[2], $dob[1], $dob[0]]; $this->profile = $profile->where('customer_id', (int) $id)->update(['dob' => implode('-', $dob_piece), 'gender_id' => $request->input('gender'), 'state_id' => $request->input('state_of_origin'), 'hostel_address' => $request->input('hostel_address'), 'guardian_name' => Str::words($request->input('guardian_name')), 'guardian_phone' => $request->input('guardian_phone'), 'guardian_address' => $request->input('guardian_address')]); $this->payment = $payment->where('customer_id', (int) $id)->update(['account_balance' => $request->input('account_balance')]); if (!$this->customer && !$this->profile) { flash()->error('An error occurred, try updating the Customer again!'); } else { flash()->success('Customer Updated Successfully!'); } return redirect()->route('customer.list'); }
/** * Convert a value to title case. * * @param string $value * @return string */ function title_case($value) { return Str::title($value); }