@@ -45,45 +45,45 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function index($slug = null) |
| 47 | 47 | { |
| 48 | - if($slug == null){ |
|
| 48 | + if ($slug == null) { |
|
| 49 | 49 | $page = $this->page->where('isHp', 1)->firstOrFail(); |
| 50 | - } elseif($slug !== null){ |
|
| 50 | + } elseif ($slug !== null) { |
|
| 51 | 51 | |
| 52 | 52 | $redirect = $this->redirect->where('slug', $slug)->first(); |
| 53 | - if($redirect !== null){ |
|
| 53 | + if ($redirect !== null) { |
|
| 54 | 54 | return redirect($redirect->to, $redirect->type); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $repeater = $this->repeater->where('url', $slug)->first(); |
| 58 | - if($repeater !== null){ |
|
| 58 | + if ($repeater !== null) { |
|
| 59 | 59 | $templateHintpath = explode('::', $repeater->page)[0]; |
| 60 | 60 | $template = $this->template->where('active', 1)->where('hintpath', $templateHintpath)->first(); |
| 61 | 61 | return view($repeater->page, compact('template', 'repeater')); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $page = $this->page->where('slug->'.app()->getLocale(), $slug)->first(); |
|
| 65 | - if($page == null){ |
|
| 66 | - foreach(\LaravelLocalization::getSupportedLocales() as $localeCode => $properties){ |
|
| 67 | - $page = $this->page->where('slug->'.$localeCode, $slug)->first(); |
|
| 68 | - if($page !== null && $localeCode == app()->getLocale()) break; |
|
| 64 | + $page = $this->page->where('slug->' . app()->getLocale(), $slug)->first(); |
|
| 65 | + if ($page == null) { |
|
| 66 | + foreach (\LaravelLocalization::getSupportedLocales() as $localeCode => $properties) { |
|
| 67 | + $page = $this->page->where('slug->' . $localeCode, $slug)->first(); |
|
| 68 | + if ($page !== null && $localeCode == app()->getLocale()) break; |
|
| 69 | 69 | |
| 70 | - if($page !== null && $localeCode !== app()->getLocale()){ |
|
| 70 | + if ($page !== null && $localeCode !== app()->getLocale()) { |
|
| 71 | 71 | //dd(app()->getLocale()); |
| 72 | 72 | app()->setLocale($localeCode); |
| 73 | 73 | \LaravelLocalization::setLocale($localeCode); |
| 74 | 74 | |
| 75 | - return redirect($localeCode.'/'.$slug); |
|
| 75 | + return redirect($localeCode . '/' . $slug); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if($page == null) abort(404); |
|
| 80 | + if ($page == null) abort(404); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $ogpageblocks = $this->pageblock->getAllByPageId($page->id); |
| 84 | 84 | $pageblocks = $this->pageBlockRepository->getRenderedByPageBlocks($ogpageblocks); |
| 85 | 85 | |
| 86 | - if($page->page !== null) { |
|
| 86 | + if ($page->page !== null) { |
|
| 87 | 87 | $template = $this->template->where('active', 1)->where('hintpath', explode('::', $page->page)[0])->first(); |
| 88 | 88 | |
| 89 | 89 | return view($page->page, compact('template', 'page', 'pageblocks')); |
@@ -91,6 +91,6 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $template = $this->template->where('active', 1)->where('id', $page->template_id)->first(); |
| 93 | 93 | |
| 94 | - return view($template->hintpath.'::templates.'.$template->slug.'.page', compact('template', 'page', 'pageblocks')); |
|
| 94 | + return view($template->hintpath . '::templates.' . $template->slug . '.page', compact('template', 'page', 'pageblocks')); |
|
| 95 | 95 | } |
| 96 | 96 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $form_slug = $request->get('form_slug'); |
| 56 | 56 | $fields_slug = $request->get('fields_slug'); |
| 57 | 57 | |
| 58 | - for ($i=0; $i < count($fields_slug); $i++) { |
|
| 58 | + for ($i = 0; $i < count($fields_slug); $i++) { |
|
| 59 | 59 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['label'] = $request->get('fields_label')[$i]; |
| 60 | 60 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['type'] = $request->get('fields_type')[$i]; |
| 61 | 61 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['class'] = $request->get('fields_class')[$i]; |
@@ -64,15 +64,15 @@ discard block |
||
| 64 | 64 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['validation'] = $request->get('fields_validation')[$i]; |
| 65 | 65 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['value'] = $request->get('fields_value')[$i]; |
| 66 | 66 | |
| 67 | - for ($k=0; $k < count(explode(';',$request->get('fields_attributes_name')[$i])); $k++) { |
|
| 68 | - $form['fields'][$form_slug . '_' . $fields_slug[$i]]['attributes'][explode(';',$request->get('fields_attributes_name')[$i])[$k]] = explode(';',$request->get('fields_attributes_value')[$i])[$k]; |
|
| 67 | + for ($k = 0; $k < count(explode(';', $request->get('fields_attributes_name')[$i])); $k++) { |
|
| 68 | + $form['fields'][$form_slug . '_' . $fields_slug[$i]]['attributes'][explode(';', $request->get('fields_attributes_name')[$i])[$k]] = explode(';', $request->get('fields_attributes_value')[$i])[$k]; |
|
| 69 | 69 | } |
| 70 | 70 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['required'] = $request->get('fields_required')[$i]; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $form['actions']['store'] = $request->get('action_store'); |
| 74 | - if($request->get('action_send') == true) { |
|
| 75 | - for ($g=0; $g < count($request->get('action_send_slug')); $g++) { |
|
| 74 | + if ($request->get('action_send') == true) { |
|
| 75 | + for ($g = 0; $g < count($request->get('action_send_slug')); $g++) { |
|
| 76 | 76 | $form['actions']['send'][$request->get('action_send_slug')[$g]]['to'] = $request->get('action_send_to')[$g]; |
| 77 | 77 | $form['actions']['send'][$request->get('action_send_slug')[$g]]['to_name'] = $request->get('action_send_to_name')[$g]; |
| 78 | 78 | $form['actions']['send'][$request->get('action_send_slug')[$g]]['from'] = $request->get('action_send_from')[$g]; |
@@ -110,14 +110,14 @@ discard block |
||
| 110 | 110 | $rules = $form->getRules(); |
| 111 | 111 | $this->validate(request(), $rules); |
| 112 | 112 | $store = $form->storeEntry($request); |
| 113 | - if($store !== 'error'){ |
|
| 113 | + if ($store !== 'error') { |
|
| 114 | 114 | //send emails |
| 115 | - foreach($form->form['actions']['send'] as $sendKey => $sendValue){ |
|
| 115 | + foreach ($form->form['actions']['send'] as $sendKey => $sendValue) { |
|
| 116 | 116 | $mailData = $form->getMailData($sendValue, $request, $store); |
| 117 | 117 | Mail::send(new FormActionMail($mailData)); |
| 118 | 118 | } |
| 119 | 119 | return redirect()->to($form->form['actions']['redirect']); |
| 120 | - }else { |
|
| 120 | + } else { |
|
| 121 | 121 | // error catching ... ? |
| 122 | 122 | } |
| 123 | 123 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | public function invite(Request $request) |
| 46 | 46 | { |
| 47 | - $this->validate(request(), [ //@todo create custom Request class for page validation |
|
| 47 | + $this->validate(request(), [//@todo create custom Request class for page validation |
|
| 48 | 48 | 'name' => 'max:185|required', |
| 49 | 49 | 'email' => 'email|required|unique:users', |
| 50 | 50 | 'role' => 'required|in:user,moderator,administrator,super-admin' |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | public function activate(Request $request) |
| 94 | 94 | { |
| 95 | - $this->validate(request(), [ //@todo create custom Request class for user password validation |
|
| 95 | + $this->validate(request(), [//@todo create custom Request class for user password validation |
|
| 96 | 96 | 'password' => 'required|min:8|regex:/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\X])(?=.*[!$#%]).*$/', |
| 97 | 97 | 'password_again' => 'required|same:password', |
| 98 | 98 | '_user_token' => 'required', |
@@ -130,14 +130,14 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | public function save(Request $request) |
| 132 | 132 | { |
| 133 | - $this->validate(request(), [ //@todo create custom Request class for page validation |
|
| 133 | + $this->validate(request(), [//@todo create custom Request class for page validation |
|
| 134 | 134 | 'name' => 'max:185|required', |
| 135 | 135 | 'email' => 'email|required', |
| 136 | 136 | 'role' => 'required|in:user,moderator,administrator,super-admin' |
| 137 | 137 | ]); |
| 138 | 138 | |
| 139 | 139 | // update the user |
| 140 | - $user = $this->user->create([ // TODO CHANGE TO UPDATE METHOD |
|
| 140 | + $user = $this->user->create([// TODO CHANGE TO UPDATE METHOD |
|
| 141 | 141 | 'name' => $request->get('name'), |
| 142 | 142 | 'email' => $request->get('email'), |
| 143 | 143 | 'token' => $this->userRepository->createToken(), |
@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | { |
| 13 | 13 | use HasTranslations; |
| 14 | 14 | |
| 15 | - public function template(){ |
|
| 15 | + public function template() { |
|
| 16 | 16 | return $this->belongsTo('Chuckbe\Chuckcms\Models\Template'); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function page_blocks(){ |
|
| 19 | + public function page_blocks() { |
|
| 20 | 20 | return $this->hasMany('Chuckbe\Chuckcms\Models\PageBlock')->orderBy('order'); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $page = new Page(); |
| 36 | 36 | |
| 37 | 37 | $meta = []; |
| 38 | - foreach(ChuckSite::getSupportedLocales() as $langKey => $langValue){ |
|
| 38 | + foreach (ChuckSite::getSupportedLocales() as $langKey => $langValue) { |
|
| 39 | 39 | $page->setTranslation('title', $langKey, $values->get('page_title')[$langKey]); |
| 40 | 40 | $page->setTranslation('slug', $langKey, $values->get('page_slug')[$langKey]); |
| 41 | 41 | |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | $meta[$langKey]['og-title'] = $values->get('meta_title')[$langKey]; |
| 48 | 48 | $meta[$langKey]['og-description'] = $values->get('meta_description')[$langKey]; |
| 49 | 49 | $meta[$langKey]['og-site_name'] = $values->get('meta_title')[$langKey]; |
| 50 | - if($values->get('meta_robots_index')[$langKey] == '1') { |
|
| 50 | + if ($values->get('meta_robots_index')[$langKey] == '1') { |
|
| 51 | 51 | $index = 'index, '; |
| 52 | 52 | } else { |
| 53 | 53 | $index = 'noindex, '; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if($values->get('meta_robots_follow')[$langKey] == '1') { |
|
| 56 | + if ($values->get('meta_robots_follow')[$langKey] == '1') { |
|
| 57 | 57 | $follow = 'follow'; |
| 58 | 58 | } else { |
| 59 | 59 | $follow = 'nofollow'; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $meta[$langKey]['robots'] = $index . $follow; |
| 63 | 63 | $meta[$langKey]['googlebots'] = $index . $follow; |
| 64 | - for ($i=0; $i < count($values->get('meta_key')[$langKey]); $i++) { |
|
| 64 | + for ($i = 0; $i < count($values->get('meta_key')[$langKey]); $i++) { |
|
| 65 | 65 | $meta[$langKey][$values->get('meta_key')[$langKey][$i]] = $values->get('meta_value')[$langKey][$i]; |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | $page = $this->getById($values['page_id']); |
| 81 | 81 | |
| 82 | 82 | $meta = []; |
| 83 | - foreach(ChuckSite::getSupportedLocales() as $langKey => $langValue){ |
|
| 83 | + foreach (ChuckSite::getSupportedLocales() as $langKey => $langValue) { |
|
| 84 | 84 | $page->setTranslation('title', $langKey, $values->get('page_title')[$langKey]); |
| 85 | 85 | $page->setTranslation('slug', $langKey, $values->get('page_slug')[$langKey]); |
| 86 | - for ($i=0; $i < count($values->get('meta_key')[$langKey]); $i++) { |
|
| 86 | + for ($i = 0; $i < count($values->get('meta_key')[$langKey]); $i++) { |
|
| 87 | 87 | $meta[$langKey][$values->get('meta_key')[$langKey][$i]] = $values->get('meta_value')[$langKey][$i]; |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | public function deleteById($id) |
| 101 | 101 | { |
| 102 | 102 | $page = $this->where('id', $id)->first(); |
| 103 | - if($page){ |
|
| 103 | + if ($page) { |
|
| 104 | 104 | PageBlock::where('page_id', $page->id)->delete(); |
| 105 | - if($page->delete()){ |
|
| 105 | + if ($page->delete()) { |
|
| 106 | 106 | return 'success'; |
| 107 | 107 | } else { |
| 108 | 108 | return 'error'; |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | { |
| 9 | 9 | protected $table = 'menus'; |
| 10 | 10 | |
| 11 | - public function __construct( array $attributes = [] ){ |
|
| 11 | + public function __construct(array $attributes = []) { |
|
| 12 | 12 | //parent::construct( $attributes ); |
| 13 | 13 | $this->table = config('menu.table_prefix') . config('menu.table_name_menus'); |
| 14 | 14 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function getRules() |
| 30 | 30 | { |
| 31 | 31 | $rules = []; |
| 32 | - foreach($this->content['fields'] as $fieldKey => $fieldValue){ |
|
| 32 | + foreach ($this->content['fields'] as $fieldKey => $fieldValue) { |
|
| 33 | 33 | $rules[$fieldKey] = $fieldValue['validation']; |
| 34 | 34 | } |
| 35 | 35 | return $rules; |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | public function storeEntry($input) |
| 39 | 39 | { |
| 40 | 40 | $slug = $input->get('content_slug'); |
| 41 | - if(is_array($this->content['actions']['detail'])){ |
|
| 42 | - if(array_key_exists('url', $this->content['actions']['detail'])) { |
|
| 41 | + if (is_array($this->content['actions']['detail'])) { |
|
| 42 | + if (array_key_exists('url', $this->content['actions']['detail'])) { |
|
| 43 | 43 | $url = $this->getUrlFromInput($this->content['actions']['detail']['url'], $input); |
| 44 | 44 | $page = $this->content['actions']['detail']['page']; |
| 45 | 45 | } else { |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | $json = []; |
| 56 | - foreach($this->content['fields'] as $fieldKey => $fieldValue){ |
|
| 57 | - if($fieldValue['type'] !== 'file'){ |
|
| 58 | - $cleanKey = str_replace($slug.'_', '', $fieldKey); |
|
| 56 | + foreach ($this->content['fields'] as $fieldKey => $fieldValue) { |
|
| 57 | + if ($fieldValue['type'] !== 'file') { |
|
| 58 | + $cleanKey = str_replace($slug . '_', '', $fieldKey); |
|
| 59 | 59 | $json[$cleanKey] = $input->get($fieldKey); |
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - if($this->content['files'] == 'true'){ |
|
| 64 | - foreach($this->content['fields'] as $fieldKey => $fieldValue){ |
|
| 65 | - if($fieldValue['type'] == 'file'){ |
|
| 63 | + if ($this->content['files'] == 'true') { |
|
| 64 | + foreach ($this->content['fields'] as $fieldKey => $fieldValue) { |
|
| 65 | + if ($fieldValue['type'] == 'file') { |
|
| 66 | 66 | //@todo save input files |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | $repeater = Repeater::where('id', $id)->first(); |
| 85 | 85 | |
| 86 | - if($repeater->delete()){ |
|
| 86 | + if ($repeater->delete()) { |
|
| 87 | 87 | return 'success'; |
| 88 | 88 | } else { |
| 89 | 89 | return 'error'; |
@@ -94,8 +94,8 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | $fields = $this->getContents($url, '[', ']'); |
| 96 | 96 | $finalUrl = $url; |
| 97 | - foreach($fields as $field){ |
|
| 98 | - $finalUrl = str_replace('['.$field.']', $input->get($field), $finalUrl); |
|
| 97 | + foreach ($fields as $field) { |
|
| 98 | + $finalUrl = str_replace('[' . $field . ']', $input->get($field), $finalUrl); |
|
| 99 | 99 | } |
| 100 | 100 | return $finalUrl; |
| 101 | 101 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | class Template extends Eloquent |
| 8 | 8 | { |
| 9 | - public function pages(){ |
|
| 9 | + public function pages() { |
|
| 10 | 10 | return $this->hasMany('Chuckbe\Chuckcms\Models\Page'); |
| 11 | 11 | } |
| 12 | 12 | |
@@ -31,22 +31,22 @@ discard block |
||
| 31 | 31 | $templates = $this->where('active', 1)->where('type', 'default')->get(); |
| 32 | 32 | $emailTemplates = []; |
| 33 | 33 | foreach ($templates as $template) { |
| 34 | - if(file_exists(base_path('vendor/'.$template->path.'/src/views/templates/'.$template->slug.'/mails'))){ |
|
| 35 | - $mailDir = array_slice(scandir(base_path('vendor/'.$template->path.'/src/views/templates/'.$template->slug.'/mails')), 2); |
|
| 34 | + if (file_exists(base_path('vendor/' . $template->path . '/src/views/templates/' . $template->slug . '/mails'))) { |
|
| 35 | + $mailDir = array_slice(scandir(base_path('vendor/' . $template->path . '/src/views/templates/' . $template->slug . '/mails')), 2); |
|
| 36 | 36 | if (count($mailDir) > 0) { |
| 37 | 37 | $emailTemplates[$template->slug]['hintpath'] = $template->hintpath; |
| 38 | - foreach($mailDir as $mdKey => $mdValue) { |
|
| 38 | + foreach ($mailDir as $mdKey => $mdValue) { |
|
| 39 | 39 | if (strpos($mdValue, '.blade.php')) { |
| 40 | 40 | $emailTemplates[$template->slug]['files'][] = str_replace('.blade.php', '', $mdValue); |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | - if(file_exists(base_path('resources/views/vendor/'.$template->slug.'/templates/'.$template->slug.'/mails'))){ |
|
| 46 | - $mailDirVendor = array_slice(scandir(base_path('resources/views/vendor/'.$template->slug.'/templates/'.$template->slug.'/mails')), 2); |
|
| 45 | + if (file_exists(base_path('resources/views/vendor/' . $template->slug . '/templates/' . $template->slug . '/mails'))) { |
|
| 46 | + $mailDirVendor = array_slice(scandir(base_path('resources/views/vendor/' . $template->slug . '/templates/' . $template->slug . '/mails')), 2); |
|
| 47 | 47 | if (count($mailDirVendor) > 0) { |
| 48 | 48 | $emailTemplates[$template->slug]['hintpath'] = $template->hintpath; |
| 49 | - foreach($mailDirVendor as $mdKey => $mdValue) { |
|
| 49 | + foreach ($mailDirVendor as $mdKey => $mdValue) { |
|
| 50 | 50 | if (strpos($mdValue, '.blade.php')) { |
| 51 | 51 | $emailTemplates[$template->slug]['files'][] = str_replace('.blade.php', '', $mdValue); |
| 52 | 52 | } |
@@ -62,22 +62,22 @@ discard block |
||
| 62 | 62 | $templates = $this->where('active', 1)->where('type', 'default')->get(); |
| 63 | 63 | $pageViews = []; |
| 64 | 64 | foreach ($templates as $template) { |
| 65 | - if(file_exists(base_path('vendor/'.$template->path.'/src/views/templates/'.$template->slug))){ |
|
| 66 | - $pageDir = array_slice(scandir(base_path('vendor/'.$template->path.'/src/views/templates/'.$template->slug)), 2); |
|
| 65 | + if (file_exists(base_path('vendor/' . $template->path . '/src/views/templates/' . $template->slug))) { |
|
| 66 | + $pageDir = array_slice(scandir(base_path('vendor/' . $template->path . '/src/views/templates/' . $template->slug)), 2); |
|
| 67 | 67 | if (count($pageDir) > 0) { |
| 68 | 68 | $pageViews[$template->slug]['hintpath'] = $template->hintpath; |
| 69 | - foreach($pageDir as $pdKey => $pdValue) { |
|
| 69 | + foreach ($pageDir as $pdKey => $pdValue) { |
|
| 70 | 70 | if (strpos($pdValue, '.blade.php')) { |
| 71 | 71 | $pageViews[$template->slug]['files'][] = str_replace('.blade.php', '', $pdValue); |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | - if(file_exists(base_path('resources/views/vendor/'.$template->slug.'/templates/'.$template->slug))){ |
|
| 77 | - $pageDir = array_slice(scandir(base_path('resources/views/vendor/'.$template->slug.'/templates/'.$template->slug)), 2); |
|
| 76 | + if (file_exists(base_path('resources/views/vendor/' . $template->slug . '/templates/' . $template->slug))) { |
|
| 77 | + $pageDir = array_slice(scandir(base_path('resources/views/vendor/' . $template->slug . '/templates/' . $template->slug)), 2); |
|
| 78 | 78 | if (count($pageDir) > 0) { |
| 79 | 79 | $pageViews[$template->slug]['hintpath'] = $template->hintpath; |
| 80 | - foreach($pageDir as $pdKey => $pdValue) { |
|
| 80 | + foreach ($pageDir as $pdKey => $pdValue) { |
|
| 81 | 81 | if (strpos($pdValue, '.blade.php')) { |
| 82 | 82 | $pageViews[$template->slug]['files'][] = str_replace('.blade.php', '', $pdValue); |
| 83 | 83 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function getRules() |
| 30 | 30 | { |
| 31 | 31 | $rules = []; |
| 32 | - foreach($this->form['fields'] as $fieldKey => $fieldValue){ |
|
| 32 | + foreach ($this->form['fields'] as $fieldKey => $fieldValue) { |
|
| 33 | 33 | $rules[$fieldKey] = $fieldValue['validation']; |
| 34 | 34 | } |
| 35 | 35 | $rules['chuckpot'] = 'honeypot'; |
@@ -39,25 +39,25 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function storeEntry($input) |
| 41 | 41 | { |
| 42 | - if($this->form['actions']['store'] == 'true'){ |
|
| 42 | + if ($this->form['actions']['store'] == 'true') { |
|
| 43 | 43 | $entry = new FormEntry(); |
| 44 | 44 | $entry->slug = $input->get('_form_slug'); |
| 45 | 45 | $json = []; |
| 46 | - foreach($this->form['fields'] as $fieldKey => $fieldValue){ |
|
| 47 | - if($fieldValue['type'] !== 'file'){ |
|
| 46 | + foreach ($this->form['fields'] as $fieldKey => $fieldValue) { |
|
| 47 | + if ($fieldValue['type'] !== 'file') { |
|
| 48 | 48 | $json[$fieldKey] = $input->get($fieldKey); |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | - if($this->form['files'] == 'true'){ |
|
| 52 | - foreach($this->form['fields'] as $fieldKey => $fieldValue){ |
|
| 53 | - if($fieldValue['type'] == 'file'){ |
|
| 54 | - if($input->hasFile($fieldKey)){ |
|
| 51 | + if ($this->form['files'] == 'true') { |
|
| 52 | + foreach ($this->form['fields'] as $fieldKey => $fieldValue) { |
|
| 53 | + if ($fieldValue['type'] == 'file') { |
|
| 54 | + if ($input->hasFile($fieldKey)) { |
|
| 55 | 55 | $avatar = $input->file($fieldKey); |
| 56 | 56 | $filename = time() . '.' . $avatar->getClientOriginalExtension(); |
| 57 | 57 | if (!file_exists(public_path('/files/uploads/'))) { |
| 58 | 58 | mkdir(public_path('/files/uploads/'), 0777, true); |
| 59 | 59 | } |
| 60 | - $avatar->move( public_path('/files/uploads/'), $filename ); |
|
| 60 | + $avatar->move(public_path('/files/uploads/'), $filename); |
|
| 61 | 61 | $filepath = '/files/uploads/' . $filename; |
| 62 | 62 | } else { |
| 63 | 63 | $filepath = null; |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | $entry->entry = $json; |
| 70 | - if($entry->save()){ |
|
| 70 | + if ($entry->save()) { |
|
| 71 | 71 | return $entry; |
| 72 | 72 | } else { |
| 73 | 73 | return 'error'; |
| 74 | 74 | } |
| 75 | - }else { |
|
| 75 | + } else { |
|
| 76 | 76 | return 'pass'; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | public function deleteById($id) |
| 81 | 81 | { |
| 82 | 82 | $form = $this->where('id', $id)->first(); |
| 83 | - if($form){ |
|
| 83 | + if ($form) { |
|
| 84 | 84 | FormEntry::where('slug', $form->slug)->delete(); |
| 85 | - if($form->delete()){ |
|
| 85 | + if ($form->delete()) { |
|
| 86 | 86 | return 'success'; |
| 87 | 87 | } else { |
| 88 | 88 | return 'error'; |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | public function deleteBySlug($slug) |
| 96 | 96 | { |
| 97 | 97 | $form = $this->where('slug', $slug)->first(); |
| 98 | - if($form){ |
|
| 98 | + if ($form) { |
|
| 99 | 99 | FormEntry::where('slug', $slug)->delete(); |
| 100 | - if($form->delete()){ |
|
| 100 | + if ($form->delete()) { |
|
| 101 | 101 | return 'success'; |
| 102 | 102 | } else { |
| 103 | 103 | return 'error'; |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | public function getMailData($sendData, $input, $entry) |
| 111 | 111 | { |
| 112 | 112 | $mailData = []; |
| 113 | - foreach($sendData as $sendKey => $sendValue){ |
|
| 113 | + foreach ($sendData as $sendKey => $sendValue) { |
|
| 114 | 114 | $findThis = $this->getResources($sendValue, '[', ']'); |
| 115 | - if(count($findThis) > 0){ |
|
| 115 | + if (count($findThis) > 0) { |
|
| 116 | 116 | |
| 117 | - foreach($findThis as $founded){ |
|
| 118 | - if(strpos($founded, $input->get('_form_slug')) !== false) { |
|
| 117 | + foreach ($findThis as $founded) { |
|
| 118 | + if (strpos($founded, $input->get('_form_slug')) !== false) { |
|
| 119 | 119 | $sendValue = str_replace('[' . $founded . ']', $input->get($founded), $sendValue); |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | $mailData[$sendKey] = $inputData; |
| 129 | - if($sendKey == 'files' && $sendValue == 'true') { |
|
| 129 | + if ($sendKey == 'files' && $sendValue == 'true') { |
|
| 130 | 130 | $mailData[$sendKey] = []; |
| 131 | - foreach($this->form['fields'] as $fKey => $fValue) { |
|
| 132 | - if($fValue['type'] == 'file') { |
|
| 131 | + foreach ($this->form['fields'] as $fKey => $fValue) { |
|
| 132 | + if ($fValue['type'] == 'file') { |
|
| 133 | 133 | $mailData[$sendKey][] = $entry->entry[$fKey]; |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -10,5 +10,5 @@ |
||
| 10 | 10 | 'json' => 'array', |
| 11 | 11 | ]; |
| 12 | 12 | |
| 13 | - protected $fillable = ['slug','json']; |
|
| 13 | + protected $fillable = ['slug', 'json']; |
|
| 14 | 14 | } |