@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | ->where('template_slug', $templateSlug)->first(); |
| 80 | 80 | |
| 81 | 81 | if ($template !== null) { |
| 82 | - self::saveTemplates(self::getTemplates()->reject(function ($value) use ($template) { |
|
| 82 | + self::saveTemplates(self::getTemplates()->reject(function($value) use ($template) { |
|
| 83 | 83 | return $value->template_slug === $template->template_slug; |
| 84 | 84 | })); |
| 85 | 85 | |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | public static function getTemplatesFile() |
| 108 | 108 | { |
| 109 | 109 | $file = config('maileclipse.mailables_dir').'templates.json'; |
| 110 | - if (! file_exists($file)) { |
|
| 111 | - if (! file_exists(config('maileclipse.mailables_dir'))) { |
|
| 112 | - if (! mkdir($concurrentDirectory = config('maileclipse.mailables_dir')) && ! is_dir($concurrentDirectory)) { |
|
| 110 | + if (!file_exists($file)) { |
|
| 111 | + if (!file_exists(config('maileclipse.mailables_dir'))) { |
|
| 112 | + if (!mkdir($concurrentDirectory = config('maileclipse.mailables_dir')) && !is_dir($concurrentDirectory)) { |
|
| 113 | 113 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory)); |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | ->where('template_slug', $request->templateslug)->first(); |
| 140 | 140 | |
| 141 | 141 | if ($template !== null) { |
| 142 | - if (! preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->title)) { |
|
| 142 | + if (!preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->title)) { |
|
| 143 | 143 | return response()->json([ |
| 144 | 144 | 'status' => 'failed', |
| 145 | 145 | 'message' => 'Template name not valid', |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Update |
| 161 | - $oldForm = self::getTemplates()->reject(function ($value) use ($template) { |
|
| 161 | + $oldForm = self::getTemplates()->reject(function($value) use ($template) { |
|
| 162 | 162 | return $value->template_slug === $template->template_slug; |
| 163 | 163 | }); |
| 164 | 164 | $newForm = array_merge($oldForm->toArray(), [array_merge((array) $template, [ |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public static function createTemplate($request): JsonResponse |
| 243 | 243 | { |
| 244 | - if (! preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->template_name)) { |
|
| 244 | + if (!preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->template_name)) { |
|
| 245 | 245 | return response()->json([ |
| 246 | 246 | 'status' => 'error', |
| 247 | 247 | 'message' => 'Template name not valid', |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $view = self::VIEW_NAMESPACE.'::templates.'.$request->template_name; |
| 253 | 253 | $templateName = Str::camel(preg_replace('/\s+/', '_', $request->template_name)); |
| 254 | 254 | |
| 255 | - if (! view()->exists($view) && ! self::getTemplates()->contains('template_slug', '=', $templateName)) { |
|
| 255 | + if (!view()->exists($view) && !self::getTemplates()->contains('template_slug', '=', $templateName)) { |
|
| 256 | 256 | self::saveTemplates(self::getTemplates() |
| 257 | 257 | ->push([ |
| 258 | 258 | 'template_name' => $request->template_name, |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | $dir = resource_path('views/vendor/'.self::VIEW_NAMESPACE.'/templates'); |
| 267 | 267 | |
| 268 | - if (! File::isDirectory($dir)) { |
|
| 268 | + if (!File::isDirectory($dir)) { |
|
| 269 | 269 | File::makeDirectory($dir, 0755, true); |
| 270 | 270 | } |
| 271 | 271 | |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | |
| 306 | 306 | $replaced = Replacer::toBlade($content); |
| 307 | 307 | |
| 308 | - if (! $save) { |
|
| 308 | + if (!$save) { |
|
| 309 | 309 | return $replaced; |
| 310 | 310 | } |
| 311 | 311 | |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | ]); |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - if (! $request->has('force') && ! self::getMailable('name', $name)->isEmpty()) { |
|
| 406 | + if (!$request->has('force') && !self::getMailable('name', $name)->isEmpty()) { |
|
| 407 | 407 | return response()->json([ |
| 408 | 408 | 'status' => 'error', |
| 409 | 409 | 'message' => 'This mailable name already exists. names should be unique! to override it, enable "force" option.', |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | { |
| 458 | 458 | $fqcns = []; |
| 459 | 459 | |
| 460 | - if (! file_exists(config('maileclipse.mailables_dir'))) { |
|
| 460 | + if (!file_exists(config('maileclipse.mailables_dir'))) { |
|
| 461 | 461 | return; |
| 462 | 462 | } else { |
| 463 | 463 | $allFiles = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(config('maileclipse.mailables_dir'))); |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | $tokens = token_get_all($content); |
| 471 | 471 | $namespace = ''; |
| 472 | 472 | for ($index = 0; isset($tokens[$index]); $index++) { |
| 473 | - if (! isset($tokens[$index][0])) { |
|
| 473 | + if (!isset($tokens[$index][0])) { |
|
| 474 | 474 | continue; |
| 475 | 475 | } |
| 476 | 476 | if (T_NAMESPACE === $tokens[$index][0]) { |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | |
| 487 | 487 | $mailableClass = $namespace.'\\'.$tokens[$index][1]; |
| 488 | 488 | |
| 489 | - if (! self::mailable_exists($mailableClass)) { |
|
| 489 | + if (!self::mailable_exists($mailableClass)) { |
|
| 490 | 490 | continue; |
| 491 | 491 | } |
| 492 | 492 | |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | |
| 499 | 499 | $mailable_data = self::buildMailable($mailableClass); |
| 500 | 500 | |
| 501 | - if (! is_null(self::handleMailableViewDataArgs($mailableClass))) { |
|
| 501 | + if (!is_null(self::handleMailableViewDataArgs($mailableClass))) { |
|
| 502 | 502 | $mailable_view_data = self::getMailableViewData(self::handleMailableViewDataArgs($mailableClass), $mailable_data); |
| 503 | 503 | } else { |
| 504 | 504 | $mailable_view_data = self::getMailableViewData(new $mailableClass, $mailable_data); |
@@ -519,16 +519,16 @@ discard block |
||
| 519 | 519 | $fqcns[$i]['view_path'] = null; |
| 520 | 520 | $fqcns[$i]['text_view_path'] = null; |
| 521 | 521 | |
| 522 | - if (! is_null($fqcns[$i]['markdown']) && View::exists($fqcns[$i]['markdown'])) { |
|
| 522 | + if (!is_null($fqcns[$i]['markdown']) && View::exists($fqcns[$i]['markdown'])) { |
|
| 523 | 523 | $fqcns[$i]['view_path'] = View($fqcns[$i]['markdown'])->getPath(); |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - if (! is_null($fqcns[$i]['data'])) { |
|
| 527 | - if (! is_null($fqcns[$i]['data']->view) && View::exists($fqcns[$i]['data']->view)) { |
|
| 526 | + if (!is_null($fqcns[$i]['data'])) { |
|
| 527 | + if (!is_null($fqcns[$i]['data']->view) && View::exists($fqcns[$i]['data']->view)) { |
|
| 528 | 528 | $fqcns[$i]['view_path'] = View($fqcns[$i]['data']->view)->getPath(); |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - if (! is_null($fqcns[$i]['data']->textView) && View::exists($fqcns[$i]['data']->textView)) { |
|
| 531 | + if (!is_null($fqcns[$i]['data']->textView) && View::exists($fqcns[$i]['data']->textView)) { |
|
| 532 | 532 | $fqcns[$i]['text_view_path'] = View($fqcns[$i]['data']->textView)->getPath(); |
| 533 | 533 | $fqcns[$i]['text_view'] = $fqcns[$i]['data']->textView; |
| 534 | 534 | } |
@@ -541,10 +541,10 @@ discard block |
||
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - $collection = collect($fqcns)->map(function ($mailable) { |
|
| 544 | + $collection = collect($fqcns)->map(function($mailable) { |
|
| 545 | 545 | return $mailable; |
| 546 | - })->reject(function ($object) { |
|
| 547 | - return ! method_exists($object['namespace'], 'build'); |
|
| 546 | + })->reject(function($object) { |
|
| 547 | + return !method_exists($object['namespace'], 'build'); |
|
| 548 | 548 | }); |
| 549 | 549 | |
| 550 | 550 | return $collection; |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | $eloquentFactory = app(EloquentFactory::class); |
| 572 | 572 | |
| 573 | - $args = collect($params)->map(function ($param) { |
|
| 573 | + $args = collect($params)->map(function($param) { |
|
| 574 | 574 | if ($param->getType() !== null) { |
| 575 | 575 | if (class_exists($param->getType()->getName())) { |
| 576 | 576 | $parameters = [ |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | |
| 690 | 690 | foreach ($properties as $prop) { |
| 691 | 691 | if ($prop->class == $data->getName() || $prop->class == get_parent_class($data->getName()) && |
| 692 | - get_parent_class($data->getName()) != 'Illuminate\Mail\Mailable' && ! $prop->isStatic()) { |
|
| 692 | + get_parent_class($data->getName()) != 'Illuminate\Mail\Mailable' && !$prop->isStatic()) { |
|
| 693 | 693 | $allProps[] = $prop->name; |
| 694 | 694 | } |
| 695 | 695 | } |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | |
| 709 | 709 | $mailableData = collect($classProps)->merge($withFuncData); |
| 710 | 710 | |
| 711 | - $data = $mailableData->map(function ($parameter) use ($mailable_data) { |
|
| 711 | + $data = $mailableData->map(function($parameter) use ($mailable_data) { |
|
| 712 | 712 | return [ |
| 713 | 713 | 'key' => $parameter, |
| 714 | 714 | 'value' => property_exists($mailable_data, $parameter) ? $mailable_data->$parameter : null, |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | */ |
| 756 | 756 | protected static function mailable_exists($mailable): bool |
| 757 | 757 | { |
| 758 | - if (! class_exists($mailable)) { |
|
| 758 | + if (!class_exists($mailable)) { |
|
| 759 | 759 | return false; |
| 760 | 760 | } |
| 761 | 761 | |
@@ -816,17 +816,17 @@ discard block |
||
| 816 | 816 | */ |
| 817 | 817 | public static function renderPreview($simpleview, $view, $template = false, $instance = null) |
| 818 | 818 | { |
| 819 | - if (! View::exists($view)) { |
|
| 819 | + if (!View::exists($view)) { |
|
| 820 | 820 | return; |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | - if (! $template) { |
|
| 823 | + if (!$template) { |
|
| 824 | 824 | $obj = self::buildMailable($instance); |
| 825 | 825 | $viewData = $obj->viewData; |
| 826 | 826 | $_data = array_merge($instance->buildViewData(), $viewData); |
| 827 | 827 | |
| 828 | 828 | foreach ($_data as $key => $value) { |
| 829 | - if (! is_object($value)) { |
|
| 829 | + if (!is_object($value)) { |
|
| 830 | 830 | $_data[$key] = '<span class="maileclipse-key" title="Variable">'.$key.'</span>'; |
| 831 | 831 | } |
| 832 | 832 | } |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | /** |
| 893 | 893 | * Removal of reserved keywords. |
| 894 | 894 | */ |
| 895 | - if (! preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name) || |
|
| 895 | + if (!preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name) || |
|
| 896 | 896 | substr_compare($name, $suffix, -strlen($suffix), strlen($suffix), true) !== 0 |
| 897 | 897 | ) { |
| 898 | 898 | return false; |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | */ |
| 913 | 913 | private static function resolveFactory($eloquentFactory, $model): ?object |
| 914 | 914 | { |
| 915 | - if (! config('maileclipse.factory')) { |
|
| 915 | + if (!config('maileclipse.factory')) { |
|
| 916 | 916 | return app($model); |
| 917 | 917 | } |
| 918 | 918 | |
@@ -957,15 +957,15 @@ discard block |
||
| 957 | 957 | self::$traversed += 1; |
| 958 | 958 | |
| 959 | 959 | collect((new ReflectionClass($factoryModel))->getMethods()) |
| 960 | - ->filter(function (\ReflectionMethod $method) use ($model) { |
|
| 961 | - return ! $model->hasMethod($method->getName()); |
|
| 960 | + ->filter(function(\ReflectionMethod $method) use ($model) { |
|
| 961 | + return !$model->hasMethod($method->getName()); |
|
| 962 | 962 | }) |
| 963 | - ->filter(function (\ReflectionMethod $method) use ($factoryModel) { |
|
| 963 | + ->filter(function(\ReflectionMethod $method) use ($factoryModel) { |
|
| 964 | 964 | if ($method->getNumberOfParameters() >= 1) { |
| 965 | 965 | return false; |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | - $parents = rescue(function () use ($method, $factoryModel) { |
|
| 968 | + $parents = rescue(function() use ($method, $factoryModel) { |
|
| 969 | 969 | $methodName = $method->getName(); |
| 970 | 970 | |
| 971 | 971 | return $method->hasReturnType() |
@@ -975,7 +975,7 @@ discard block |
||
| 975 | 975 | |
| 976 | 976 | return isset($parents["Illuminate\Database\Eloquent\Relations\Relation"]); |
| 977 | 977 | }) |
| 978 | - ->each(function (\ReflectionMethod $relationName) use (&$factoryModel, $eloquentFactory) { |
|
| 978 | + ->each(function(\ReflectionMethod $relationName) use (&$factoryModel, $eloquentFactory) { |
|
| 979 | 979 | $factoryModel = self::loadRelations($relationName->getName(), $factoryModel, $eloquentFactory); |
| 980 | 980 | }); |
| 981 | 981 | |
@@ -1004,7 +1004,7 @@ discard block |
||
| 1004 | 1004 | $relatedFactory = self::resolveFactory($eloquentFactory, get_class($related)); |
| 1005 | 1005 | |
| 1006 | 1006 | if (self::$traversed <= config('maileclipse.relations.relation_depth')) { |
| 1007 | - if (! $loadIfIterable) { |
|
| 1007 | + if (!$loadIfIterable) { |
|
| 1008 | 1008 | $relatedFactory = self::hydrateRelations($eloquentFactory, $relatedFactory); |
| 1009 | 1009 | } else { |
| 1010 | 1010 | $models = collect(); |