| @@ -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; | 
| @@ -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; | 
| @@ -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) | 
| @@ -70,7 +70,7 @@ discard block | ||
| 70 | 70 | ' // url, icon, title | 
| 71 | 71 | ]; | 
| 72 | 72 | |
| 73 | -        $traverse = function ($rows) use (&$traverse, $templates, $user) { | |
| 73 | +        $traverse = function($rows) use (&$traverse, $templates, $user) { | |
| 74 | 74 | $menuString = ""; | 
| 75 | 75 | $hasActive = false; | 
| 76 | 76 |              foreach ($rows as $menu) { | 
| @@ -97,14 +97,14 @@ discard block | ||
| 97 | 97 | (!empty($menu->route) ? url($menu->route) : '#'), | 
| 98 | 98 | (!empty($menu->icon) ? $menu->icon : 'fa fa-circle-o'), | 
| 99 | 99 |                      //trans('back-project::base.dashboard') | 
| 100 | -                    \Lang::has('back-project::menu.' . $menu->title) ? __('back-project::menu.' . $menu->title) : $menu->title, | |
| 100 | +                    \Lang::has('back-project::menu.'.$menu->title) ? __('back-project::menu.'.$menu->title) : $menu->title, | |
| 101 | 101 | $menu_caret | 
| 102 | 102 | ); | 
| 103 | 103 | $class = (!empty($submenu) ? 'treeview' : ''); | 
| 104 | 104 | $current_url = \Route::current()->uri(); | 
| 105 | 105 | |
| 106 | 106 |                  if ($authorized) { | 
| 107 | - $menuString .= sprintf($templates['menu_row'], $class, $link . $submenu); | |
| 107 | + $menuString .= sprintf($templates['menu_row'], $class, $link.$submenu); | |
| 108 | 108 | } | 
| 109 | 109 | } | 
| 110 | 110 | |
| @@ -10,7 +10,6 @@ | ||
| 10 | 10 | use Afrittella\BackProject\Services\BackProject; | 
| 11 | 11 | use Afrittella\BackProject\Services\SlugGenerator; | 
| 12 | 12 | use Illuminate\Support\ServiceProvider; | 
| 13 | -use Illuminate\Routing\Router; | |
| 14 | 13 | use function Symfony\Component\HttpKernel\Tests\controller_func; | 
| 15 | 14 | |
| 16 | 15 | |
| @@ -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(); | 
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 | |
| 63 | 63 | public function register() | 
| 64 | 64 |      { | 
| 65 | -        $this->app->singleton('media-manager', function ($app) { | |
| 65 | +        $this->app->singleton('media-manager', function($app) { | |
| 66 | 66 | return new MediaManager(); | 
| 67 | 67 | }); | 
| 68 | 68 | |
| @@ -105,15 +105,15 @@ discard block | ||
| 105 | 105 | public function publishFiles() | 
| 106 | 106 |      { | 
| 107 | 107 | // publish config file | 
| 108 | - $this->publishes([__DIR__ . '/../config/config.php' => config_path() . '/back-project.php'], 'config'); | |
| 108 | + $this->publishes([__DIR__.'/../config/config.php' => config_path().'/back-project.php'], 'config'); | |
| 109 | 109 | // publish lang files | 
| 110 | -        $this->publishes([__DIR__ . '/../resources/lang' => resource_path('lang/vendor/back-project')], 'lang'); | |
| 110 | +        $this->publishes([__DIR__.'/../resources/lang' => resource_path('lang/vendor/back-project')], 'lang'); | |
| 111 | 111 | // publish public BackProject assets | 
| 112 | -        $this->publishes([__DIR__ . '/../public' => public_path('vendor/back-project')], 'public'); | |
| 112 | +        $this->publishes([__DIR__.'/../public' => public_path('vendor/back-project')], 'public'); | |
| 113 | 113 | // publish views | 
| 114 | -        $this->publishes([__DIR__ . '/../resources/views' => resource_path('views/vendor/back-project')], 'views'); | |
| 114 | +        $this->publishes([__DIR__.'/../resources/views' => resource_path('views/vendor/back-project')], 'views'); | |
| 115 | 115 | // publish error views | 
| 116 | -        $this->publishes([__DIR__ . '/../resources/error_views' => resource_path('views/errors')], 'errors'); | |
| 116 | +        $this->publishes([__DIR__.'/../resources/error_views' => resource_path('views/errors')], 'errors'); | |
| 117 | 117 | // publish public AdminLTE assets | 
| 118 | 118 |          $this->publishes(['vendor/almasaeed2010/adminlte/bootstrap' => public_path('vendor/adminlte/bootstrap')], 'adminlte'); | 
| 119 | 119 |          $this->publishes(['vendor/almasaeed2010/adminlte/dist' => public_path('vendor/adminlte/dist')], 'adminlte'); | 
| @@ -128,7 +128,7 @@ discard block | ||
| 128 | 128 |          $router->aliasMiddleware('admin', \Afrittella\BackProject\Http\Middleware\Admin::class); | 
| 129 | 129 |          $router->aliasMiddleware('role', \Afrittella\BackProject\Http\Middleware\Role::class); | 
| 130 | 130 | |
| 131 | - $this->loadRoutesFrom(__DIR__ . '/../routes/web.php'); | |
| 131 | + $this->loadRoutesFrom(__DIR__.'/../routes/web.php'); | |
| 132 | 132 | } | 
| 133 | 133 | |
| 134 | 134 | public function handleMigrations() | 
| @@ -138,8 +138,8 @@ discard block | ||
| 138 | 138 |                  $timestamp = date('Y_m_d_His', time()); | 
| 139 | 139 | |
| 140 | 140 | $this->publishes([ | 
| 141 | - __DIR__ . '/../database/migrations/' . $file . '.php' => | |
| 142 | -                        database_path('migrations/' . $timestamp . '_' . $file . '.php') | |
| 141 | + __DIR__.'/../database/migrations/'.$file.'.php' => | |
| 142 | +                        database_path('migrations/'.$timestamp.'_'.$file.'.php') | |
| 143 | 143 | ], 'migrations'); | 
| 144 | 144 | } | 
| 145 | 145 | } | 
| @@ -179,7 +179,7 @@ discard block | ||
| 179 | 179 | public function loadHelpers() | 
| 180 | 180 |      { | 
| 181 | 181 | foreach ($this->helpers as $helper): | 
| 182 | - $file = __DIR__ . '/Helpers/' . $helper . '.php'; | |
| 182 | + $file = __DIR__.'/Helpers/'.$helper.'.php'; | |
| 183 | 183 | |
| 184 | 184 |              if (file_exists($file)) { | 
| 185 | 185 | require_once($file); |