@@ -91,7 +91,7 @@ |
||
91 | 91 | <a href="%s"><i class="%s text-red"></i><span>%s</span></a> |
92 | 92 | ' // url, icon, title |
93 | 93 | ]; |
94 | - $traverse = function ($rows) use (&$traverse, $templates, $user) { |
|
94 | + $traverse = function($rows) use (&$traverse, $templates, $user) { |
|
95 | 95 | $menuString = ""; |
96 | 96 | $hasActive = false; |
97 | 97 | foreach ($rows as $menu) { |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct(MenuRepository $menuRepository) |
14 | 14 | { |
15 | - $this->menuRepository = $menuRepository; |
|
15 | + $this->menuRepository = $menuRepository; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function compose(View $view) |
@@ -95,22 +95,22 @@ discard block |
||
95 | 95 | $menuString = ""; |
96 | 96 | $hasActive = false; |
97 | 97 | foreach ($rows as $menu) { |
98 | - if (!empty($menu->permission) and !$user->hasPermission($menu->permission)) { |
|
99 | - continue; |
|
100 | - } |
|
98 | + if (!empty($menu->permission) and !$user->hasPermission($menu->permission)) { |
|
99 | + continue; |
|
100 | + } |
|
101 | 101 | |
102 | - $hasActive = false; |
|
103 | - $link = sprintf($templates['menu_link'], |
|
102 | + $hasActive = false; |
|
103 | + $link = sprintf($templates['menu_link'], |
|
104 | 104 | (!empty($menu->route) ? url($menu->route) : '#'), |
105 | 105 | (!empty($menu->icon) ? $menu->icon : 'fa fa-circle-o'), |
106 | 106 | //trans('back-project::base.dashboard') |
107 | 107 | \Lang::has('back-project::menu.'.$menu->title) ? __('back-project::menu.'.$menu->title) : $menu->title |
108 | - ); |
|
108 | + ); |
|
109 | 109 | |
110 | - $submenu = ""; |
|
111 | - $authorized = true; |
|
110 | + $submenu = ""; |
|
111 | + $authorized = true; |
|
112 | 112 | |
113 | - if ($menu->children->count() > 0) { |
|
113 | + if ($menu->children->count() > 0) { |
|
114 | 114 | list($submenuString, $hasActive) = $traverse($menu->children); |
115 | 115 | $submenu = ""; |
116 | 116 | if (!empty($submenuString)) { |
@@ -118,19 +118,19 @@ discard block |
||
118 | 118 | } else { |
119 | 119 | $authorized = false; |
120 | 120 | } |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - $class = (!empty($submenu) ? 'treeview' : ''); |
|
124 | - $current_url = \Route::current()->uri(); |
|
123 | + $class = (!empty($submenu) ? 'treeview' : ''); |
|
124 | + $current_url = \Route::current()->uri(); |
|
125 | 125 | |
126 | - if ($authorized) { |
|
127 | - $menuString .= sprintf($templates['menu_row'], $class, $link.$submenu); |
|
128 | - } |
|
126 | + if ($authorized) { |
|
127 | + $menuString .= sprintf($templates['menu_row'], $class, $link.$submenu); |
|
128 | + } |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | return [ |
132 | - $menuString, |
|
133 | - $hasActive |
|
132 | + $menuString, |
|
133 | + $hasActive |
|
134 | 134 | ]; |
135 | 135 | }; |
136 | 136 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | public function attachments() |
22 | 22 | { |
23 | - return $this->morphToMany( Attachment::class, 'attachable' )->orderBy('is_main', 'desc'); |
|
23 | + return $this->morphToMany(Attachment::class, 'attachable')->orderBy('is_main', 'desc'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function getAttachment() { |
@@ -19,6 +19,6 @@ |
||
19 | 19 | |
20 | 20 | public function attachments() |
21 | 21 | { |
22 | - return $this->morphToMany( Attachment::class, 'attachable' )->orderBy('is_main', 'desc'); |
|
22 | + return $this->morphToMany(Attachment::class, 'attachable')->orderBy('is_main', 'desc'); |
|
23 | 23 | } |
24 | 24 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | return $this->model->create($data); |
49 | 49 | } |
50 | 50 | |
51 | - public function update(array $data, $id, $attribute="id") |
|
51 | + public function update(array $data, $id, $attribute = "id") |
|
52 | 52 | { |
53 | 53 | $model_data = $this->model->where($attribute, '=', $id)->first(); |
54 | 54 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | return $this; |
124 | 124 | } |
125 | 125 | |
126 | - public function skipCriteria($status = true){ |
|
126 | + public function skipCriteria($status = true) { |
|
127 | 127 | $this->skipCriteria = $status; |
128 | 128 | return $this; |
129 | 129 | } |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | public function applyCriteria() { |
146 | - if($this->skipCriteria === true) |
|
146 | + if ($this->skipCriteria === true) |
|
147 | 147 | return $this; |
148 | 148 | |
149 | - foreach($this->getCriteria() as $criteria) { |
|
150 | - if($criteria instanceof Criteria) |
|
149 | + foreach ($this->getCriteria() as $criteria) { |
|
150 | + if ($criteria instanceof Criteria) |
|
151 | 151 | $this->model = $criteria->apply($this->model, $this); |
152 | 152 | } |
153 | 153 |
@@ -29,6 +29,9 @@ discard block |
||
29 | 29 | $this->makeModel(); |
30 | 30 | } |
31 | 31 | |
32 | + /** |
|
33 | + * @return string |
|
34 | + */ |
|
32 | 35 | abstract public function model(); |
33 | 36 | |
34 | 37 | public function all($columns = ['*']) |
@@ -96,6 +99,9 @@ discard block |
||
96 | 99 | return $this->model->findOrCreate($data); |
97 | 100 | } |
98 | 101 | |
102 | + /** |
|
103 | + * @param string $attribute |
|
104 | + */ |
|
99 | 105 | public function findBy($attribute, $value, $columns = array('*')) |
100 | 106 | { |
101 | 107 | $this->applyCriteria(); |
@@ -107,8 +107,9 @@ discard block |
||
107 | 107 | $model = $this->app->make($this->model()); |
108 | 108 | //$model = app()->make($this->model()); |
109 | 109 | |
110 | - if (!$model instanceof Model) |
|
111 | - throw new RepositoryException("Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model"); |
|
110 | + if (!$model instanceof Model) { |
|
111 | + throw new RepositoryException("Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model"); |
|
112 | + } |
|
112 | 113 | |
113 | 114 | return $this->model = $model; |
114 | 115 | } |
@@ -143,12 +144,14 @@ discard block |
||
143 | 144 | } |
144 | 145 | |
145 | 146 | public function applyCriteria() { |
146 | - if($this->skipCriteria === true) |
|
147 | - return $this; |
|
147 | + if($this->skipCriteria === true) { |
|
148 | + return $this; |
|
149 | + } |
|
148 | 150 | |
149 | 151 | foreach($this->getCriteria() as $criteria) { |
150 | - if($criteria instanceof Criteria) |
|
151 | - $this->model = $criteria->apply($this->model, $this); |
|
152 | + if($criteria instanceof Criteria) { |
|
153 | + $this->model = $criteria->apply($this->model, $this); |
|
154 | + } |
|
152 | 155 | } |
153 | 156 | |
154 | 157 | return $this; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -Route::group(['namespace' => '\Afrittella\BackProject\Http\Controllers'], function () { |
|
3 | - Route::group(['middleware' => 'web'], function () { |
|
2 | +Route::group(['namespace' => '\Afrittella\BackProject\Http\Controllers'], function() { |
|
3 | + Route::group(['middleware' => 'web'], function() { |
|
4 | 4 | Route::get('confirm/{code}/{user}', 'Auth\RegisterController@confirm')->name('users.confirm'); |
5 | 5 | Route::auth(); |
6 | 6 | |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | Route::get('auth/{provider}/callback', 'Auth\SocialLoginController@handleProviderCallback')->name('social_callback'); |
9 | 9 | }); |
10 | 10 | |
11 | - Route::group(['middleware' => 'web', 'prefix' => config('back-project.route_prefix')], function () { |
|
11 | + Route::group(['middleware' => 'web', 'prefix' => config('back-project.route_prefix')], function() { |
|
12 | 12 | Route::get('dashboard', 'AdminController@dashboard')->name('admin.dashboard'); |
13 | 13 | Route::get('account', 'UsersController@account')->name('admin.account'); |
14 | 14 | Route::put('account', 'UsersController@accountStore')->name('admin.add-account'); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | Route::get('attachments/{attachment}/main', 'AttachmentsController@setMain')->name('attachments.main'); |
19 | 19 | Route::resource('attachments', 'AttachmentsController', ['except' => ['destroy', 'show']]); |
20 | 20 | // Users |
21 | - Route::group(['middleware' => 'role:administrator'], function () { |
|
21 | + Route::group(['middleware' => 'role:administrator'], function() { |
|
22 | 22 | Route::get('users/{user}/delete', 'UsersController@delete')->name('users.delete'); // Implementing delete avoiding DELETE method |
23 | 23 | Route::resource('users', 'UsersController', ['except' => ['destroy', 'show']]); |
24 | 24 |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Afrittella\BackProject\Http\Controllers; |
4 | 4 | |
5 | -use Afrittella\BackProject\Exceptions\NotFoundException; |
|
6 | 5 | use Afrittella\BackProject\Http\Requests\AttachmentAdd; |
7 | 6 | use Afrittella\BackProject\Repositories\Attachments; |
8 | 7 | use Afrittella\BackProject\Repositories\Criteria\Attachments\ByUser; |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | // - first the published views (in case they have any changes) |
38 | 38 | $this->loadViewsFrom(resource_path('views/vendor/back-project/base'), 'back-project'); |
39 | 39 | // - then the stock views that come with the package, in case a published view might be missing |
40 | - $this->loadViewsFrom(__DIR__ . '/../resources/views', 'back-project'); |
|
40 | + $this->loadViewsFrom(__DIR__.'/../resources/views', 'back-project'); |
|
41 | 41 | // Load Translations |
42 | - $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'back-project'); |
|
42 | + $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'back-project'); |
|
43 | 43 | |
44 | 44 | // use the vendor configuration file as fallback |
45 | 45 | $this->mergeConfigFrom( |
46 | - __DIR__ . '/../config/config.php', 'back-project' |
|
46 | + __DIR__.'/../config/config.php', 'back-project' |
|
47 | 47 | ); |
48 | 48 | |
49 | 49 | $this->routes($router); |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | return new BackProject($app); |
68 | 68 | });*/ |
69 | 69 | |
70 | - $this->app->singleton('attachments-manager', function ($app) { |
|
70 | + $this->app->singleton('attachments-manager', function($app) { |
|
71 | 71 | return new MediaManager(); |
72 | 72 | }); |
73 | 73 | |
74 | - $this->app->singleton('back-project', function ($app) { |
|
74 | + $this->app->singleton('back-project', function($app) { |
|
75 | 75 | return new BackProject(); |
76 | 76 | }); |
77 | 77 | |
78 | - $this->app->singleton('slug-generator', function ($app) { |
|
78 | + $this->app->singleton('slug-generator', function($app) { |
|
79 | 79 | return new SlugGenerator(); |
80 | 80 | }); |
81 | 81 | |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | public function publishFiles() |
114 | 114 | { |
115 | 115 | // publish config file |
116 | - $this->publishes([__DIR__ . '/../config/config.php' => config_path() . '/back-project.php'], 'config'); |
|
116 | + $this->publishes([__DIR__.'/../config/config.php' => config_path().'/back-project.php'], 'config'); |
|
117 | 117 | // publish lang files |
118 | - $this->publishes([__DIR__ . '/../resources/lang' => resource_path('lang/vendor/back-project')], 'lang'); |
|
118 | + $this->publishes([__DIR__.'/../resources/lang' => resource_path('lang/vendor/back-project')], 'lang'); |
|
119 | 119 | // publish public BackProject assets |
120 | - $this->publishes([__DIR__ . '/../public' => public_path('vendor/back-project')], 'public'); |
|
120 | + $this->publishes([__DIR__.'/../public' => public_path('vendor/back-project')], 'public'); |
|
121 | 121 | // publish views |
122 | - $this->publishes([__DIR__ . '/../resources/views' => resource_path('views/vendor/back-project')], 'views'); |
|
122 | + $this->publishes([__DIR__.'/../resources/views' => resource_path('views/vendor/back-project')], 'views'); |
|
123 | 123 | // publish error views |
124 | - $this->publishes([__DIR__ . '/../resources/error_views' => resource_path('views/errors')], 'errors'); |
|
124 | + $this->publishes([__DIR__.'/../resources/error_views' => resource_path('views/errors')], 'errors'); |
|
125 | 125 | // publish public AdminLTE assets |
126 | 126 | $this->publishes(['vendor/almasaeed2010/adminlte/bootstrap' => public_path('vendor/adminlte/bootstrap')], 'adminlte'); |
127 | 127 | $this->publishes(['vendor/almasaeed2010/adminlte/dist' => public_path('vendor/adminlte/dist')], 'adminlte'); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | //$router->aliasMiddleware('guest', \Afrittella\BackProject\Http\Middleware\RedirectIfAuthenticated::class); |
137 | 137 | $router->aliasMiddleware('role', \Afrittella\BackProject\Http\Middleware\Role::class); |
138 | 138 | |
139 | - $this->loadRoutesFrom(__DIR__ . '/../routes/web.php'); |
|
139 | + $this->loadRoutesFrom(__DIR__.'/../routes/web.php'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | public function handleMigrations() |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | $timestamp = date('Y_m_d_His', time()); |
147 | 147 | |
148 | 148 | $this->publishes([ |
149 | - __DIR__ . '/../database/migrations/' . $file . '.php' => |
|
150 | - database_path('migrations/' . $timestamp . '_' . $file . '.php') |
|
149 | + __DIR__.'/../database/migrations/'.$file.'.php' => |
|
150 | + database_path('migrations/'.$timestamp.'_'.$file.'.php') |
|
151 | 151 | ], 'migrations'); |
152 | 152 | } |
153 | 153 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | public function loadHelpers() |
188 | 188 | { |
189 | 189 | foreach ($this->helpers as $helper): |
190 | - $file = __DIR__ . '/Helpers/' . $helper . '.php'; |
|
190 | + $file = __DIR__.'/Helpers/'.$helper.'.php'; |
|
191 | 191 | |
192 | 192 | if (file_exists($file)) { |
193 | 193 | require_once($file); |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Get similar slugs |
38 | - * @param $slug |
|
38 | + * @param string $slug |
|
39 | 39 | * @param $id |
40 | 40 | * @return mixed |
41 | 41 | */ |
@@ -23,7 +23,7 @@ |
||
23 | 23 | $i = 1; |
24 | 24 | |
25 | 25 | while ($completed == false) { |
26 | - $newSlug = $slug .'-'.$i; |
|
26 | + $newSlug = $slug.'-'.$i; |
|
27 | 27 | if (!$relatedSlugs->contains('slug', $newSlug)) { |
28 | 28 | return $newSlug; |
29 | 29 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | { |
15 | 15 | //@TODO implement google or s3 cloud storage support |
16 | 16 | //if (config('filesystems.default') == 'google') { |
17 | - // $this->media_path = Storage::disk()->getDriver()->getAdapter()->getStorageApiUri() . '/' . Storage::disk()->getDriver()->getAdapter()->getBucket()->name(); |
|
17 | + // $this->media_path = Storage::disk()->getDriver()->getAdapter()->getStorageApiUri() . '/' . Storage::disk()->getDriver()->getAdapter()->getBucket()->name(); |
|
18 | 18 | //} else { |
19 | 19 | //$this->media_path = Storage::disk()->getDriver()->getAdapter()->getPathPrefix(); |
20 | 20 | //} |
@@ -51,7 +51,7 @@ |
||
51 | 51 | { |
52 | 52 | $format = $this->chooseFormat($format); |
53 | 53 | |
54 | - return '<img src="'.$this->getCachedImageUrl($format, $image->name).'" alt="'.$image->description.'" '.$attributes. '>'; |
|
54 | + return '<img src="'.$this->getCachedImageUrl($format, $image->name).'" alt="'.$image->description.'" '.$attributes.'>'; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | protected function chooseFormat($format) |