diff --git a/classes/Controllers/Elements.php b/classes/Controllers/Elements.php index 5db5853b..41987c6a 100644 --- a/classes/Controllers/Elements.php +++ b/classes/Controllers/Elements.php @@ -58,7 +58,7 @@ public function index($locale = null, $tab = null) // If handling a deep link to a tab, verify that the passed tab // slug is a real key in the data. Else 404. - if ($tab && !in_array($tab, $elements->lists('page_label') + if ($tab && !in_array($tab, $elements->pluck('page_label') ->map(function ($title) { return Str::slug($title); }) @@ -288,7 +288,7 @@ protected function storeImage(Element $el, $input) // Check for the image in the input. If isn't found, make no changes. $name = $el->inputName(); if (!$data = array_first($input['images'], - function ($id, $data) use ($name) { + function ($data, $id) use ($name) { return $data['name'] == $name; })) { return; diff --git a/classes/Controllers/ForgotPassword.php b/classes/Controllers/ForgotPassword.php new file mode 100644 index 00000000..61a87974 --- /dev/null +++ b/classes/Controllers/ForgotPassword.php @@ -0,0 +1,42 @@ + 'required|email', + ]); + + // Set the breadcrumbs + app('decoy.breadcrumbs')->set([ + route('decoy::account@login') => 'Login', + url()->current() => 'Forgot Password', + ]); + + // Show the page + $this->title = 'Forgot Password'; + $this->description = 'You know the drill.'; + + return $this->populateView('decoy::account.forgot'); + } +} diff --git a/classes/Controllers/Login.php b/classes/Controllers/Login.php index b8902f63..f127d911 100644 --- a/classes/Controllers/Login.php +++ b/classes/Controllers/Login.php @@ -5,7 +5,6 @@ use Auth; use Former; use Illuminate\Routing\Controller; -use Illuminate\Foundation\Auth\ThrottlesLogins; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Foundation\Validation\ValidatesRequests; @@ -15,7 +14,7 @@ */ class Login extends Controller { - use AuthenticatesUsers, ThrottlesLogins, ValidatesRequests; + use AuthenticatesUsers, ValidatesRequests; /** * Use the guest middleware to redirect logged in admins away from the login @@ -25,7 +24,7 @@ class Login extends Controller */ public function __construct() { - $this->middleware('decoy.guest', ['except' => 'getLogout']); + $this->middleware('decoy.guest', ['except' => 'logout']); } /** @@ -55,7 +54,7 @@ public function showLoginForm() public function logout() { // Logout the session - Auth::guard($this->getGuard())->logout(); + Auth::logout(); // Redirect back to previous page so that switching users takes you back to // your previous page. diff --git a/classes/Controllers/ResetPassword.php b/classes/Controllers/ResetPassword.php index 4c85451e..701eb58a 100644 --- a/classes/Controllers/ResetPassword.php +++ b/classes/Controllers/ResetPassword.php @@ -18,41 +18,6 @@ class ResetPassword extends Base { use ResetsPasswords; - /** - * Display the form to request a password reset link. - * - * @return \Illuminate\Http\Response - */ - public function showLinkRequestForm() - { - // Pass validation rules - Former::withRules([ - 'email' => 'required|email', - ]); - - // Set the breadcrumbs - app('decoy.breadcrumbs')->set([ - route('decoy::account@login') => 'Login', - url()->current() => 'Forgot Password', - ]); - - // Show the page - $this->title = 'Forgot Password'; - $this->description = 'You know the drill.'; - - return $this->populateView('decoy::account.forgot'); - } - - /** - * Get the e-mail subject line to be used for the reset link email. - * - * @return string - */ - protected function getEmailSubject() - { - return 'Recover access to '.Decoy::site(); - } - /** * Display the password reset view for the given token. * @@ -120,6 +85,6 @@ protected function resetPassword($user, $password) 'remember_token' => Str::random(60), ])->save(); - Auth::guard($this->getGuard())->login($user); + Auth::login($user); } } diff --git a/classes/Input/Localize.php b/classes/Input/Localize.php index 66cae77e..6896e1ca 100644 --- a/classes/Input/Localize.php +++ b/classes/Input/Localize.php @@ -121,7 +121,7 @@ public function localizableLocales() Config::get('decoy.site.locales'), // ... the locales of other localizations ... - $this->other()->lists('locale')->flip()->toArray(), + $this->other()->pluck('locale')->flip()->toArray(), // ... and the model's locale [$this->item->locale => null] diff --git a/classes/Models/Admin.php b/classes/Models/Admin.php index b68f5480..570179e4 100644 --- a/classes/Models/Admin.php +++ b/classes/Models/Admin.php @@ -12,11 +12,13 @@ use DecoyURL; use Bkwld\Library\Utils\Text; use Bkwld\Decoy\Auth\AuthInterface; +use Bkwld\Decoy\Notifications\ResetPassword; use Illuminate\Auth\Authenticatable; use Illuminate\Contracts\Auth\Access\Gate; use Illuminate\Auth\Passwords\CanResetPassword; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; +use Illuminate\Notifications\Notifiable; class Admin extends Base implements AuthInterface, @@ -25,7 +27,7 @@ class Admin extends Base implements { // Note, not using the Authorizable trait because I've defined my own versions // for backwards compatability with Decoy 4 and also to have a tigher syntax. - use Authenticatable, CanResetPassword, Traits\HasImages; + use Authenticatable, CanResetPassword, Traits\HasImages, Notifiable; /** * The table associated with the model. Explicitly declaring so that sub @@ -248,6 +250,18 @@ public function cannot($action, $controller) return $this->cant($action, $controller); } + /** + * Send the password reset notification. This overrides a method inheritted + * from the CanResetPassword trait + * + * @param string $token + * @return void + */ + public function sendPasswordResetNotification($token) + { + $this->notify(new ResetPassword($token)); + } + /** * A shorthand for getting the admin name as a string * diff --git a/classes/Models/Base.php b/classes/Models/Base.php index 0a5ce473..2a18466b 100644 --- a/classes/Models/Base.php +++ b/classes/Models/Base.php @@ -14,14 +14,14 @@ use Bkwld\Upchuck\SupportsUploads; use Bkwld\Library\Utils\Collection; use Bkwld\Decoy\Exceptions\Exception; -use Cviebrock\EloquentSluggable\SluggableTrait; +use Cviebrock\EloquentSluggable\Sluggable; +use Cviebrock\EloquentSluggable\SluggableScopeHelpers; use Bkwld\Decoy\Collections\Base as BaseCollection; -use Cviebrock\EloquentSluggable\SluggableInterface; use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Eloquent\ModelNotFoundException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -abstract class Base extends Eloquent implements SluggableInterface +abstract class Base extends Eloquent { /** @@ -29,11 +29,11 @@ abstract class Base extends Eloquent implements SluggableInterface * negligible. */ use Cloneable, - SluggableTrait, + Sluggable, + SluggableScopeHelpers, SupportsUploads, - Traits\CanSerializeTransform { - needsSlugging as traitNeedsSlugging; - } + Traits\CanSerializeTransform + ; /** * Use the Decoy Base Collection @@ -195,12 +195,18 @@ public function changes() * Tell sluggable where to get the source for the slug and apply other * customizations. * - * @var array + * @return array */ - protected $sluggable = [ - 'build_from' => 'admin_title', - 'max_length' => 100, - ]; + public function sluggable() + { + if (!$this->needsSlugging()) return []; + return [ + 'slug' => [ + 'source' => 'admin_title', + 'maxLength' => 100, + ] + ]; + } /** * Check for a validation rule for a slug column @@ -209,11 +215,7 @@ public function changes() */ protected function needsSlugging() { - if (!array_key_exists('slug', static::$rules)) { - return false; - } - - return $this->traitNeedsSlugging(); + return array_key_exists('slug', static::$rules); } //--------------------------------------------------------------------------- @@ -636,12 +638,13 @@ public function scopeOtherLocalizations($query) * Find by the slug and fail if missing. Invokes methods from the * Sluggable trait. * - * @param string $string + * @param string $string + * @param array $columns * @return Illuminate\Database\Eloquent\Model * * @throws Illuminate\Database\Eloquent\ModelNotFoundException */ - public static function findBySlugOrFail($slug) + public static function findBySlugOrFail($slug, array $columns = ['*']) { // Model not found, throw exception if (!$item = static::findBySlug($slug)) { diff --git a/classes/Models/Change.php b/classes/Models/Change.php index 6f8532e3..0f115425 100644 --- a/classes/Models/Change.php +++ b/classes/Models/Change.php @@ -130,7 +130,7 @@ public static function log(Model $model, $action, Admin $admin = null) */ public static function getActions() { - return static::groupBy('action')->lists('action', 'action'); + return static::groupBy('action')->pluck('action', 'action'); } /** @@ -144,7 +144,7 @@ public static function getAdmins() return static::groupBy('admin_id') ->join('admins', 'admins.id', '=', 'admin_id') ->select(DB::raw('changes.id, CONCAT(first_name, " ", last_name) name')) - ->lists('name', 'id'); + ->pluck('name', 'id'); } /** diff --git a/classes/Models/Traits/HasImages.php b/classes/Models/Traits/HasImages.php index 7cd23af8..4204a6dd 100644 --- a/classes/Models/Traits/HasImages.php +++ b/classes/Models/Traits/HasImages.php @@ -58,7 +58,7 @@ public function images() */ public function img($name = null) { - return $this->images->first(function ($key, Image $image) use ($name) { + return $this->images->first(function (Image $image, $key) use ($name) { return $image->getAttribute('name') == $name; // When the $name isn't found, return an empty Image object so all the diff --git a/classes/Notifications/ResetPassword.php b/classes/Notifications/ResetPassword.php new file mode 100644 index 00000000..2589eb7b --- /dev/null +++ b/classes/Notifications/ResetPassword.php @@ -0,0 +1,36 @@ +token); + + // Send the message + return (new MailMessage) + ->subject('Recover access to '.Decoy::site()) + ->line('You are receiving this email because we received a password reset request for your account.') + ->action('Reset Password', $url) + ->line('If you did not request a password reset, no further action is required.'); + } + +} diff --git a/classes/Observers/ValidateExistingFiles.php b/classes/Observers/ValidateExistingFiles.php index 2faad0b9..a8ca957a 100644 --- a/classes/Observers/ValidateExistingFiles.php +++ b/classes/Observers/ValidateExistingFiles.php @@ -38,23 +38,48 @@ public function onValidating($model, $validation) // For each of the file rules, if the input has a value, make a file // instance for it if it's a local path. - $files = $validation->getFiles(); $data = $validation->getData(); foreach ($rules as $attribute => $rules) { - // Skip if a file was uploaded for this attribtue or if the existing data - // is undefined - if (isset($files[$attribute]) || empty($data[$attribute])) { + // Test that the attribute is in the data. It may not be for images + // attributes or other nested models + if (!array_key_exists($attribute, $data)) { continue; - } + + // Skip if a file was uploaded for this attribtue + } else if (is_a($data[$attribute], File::class)) { + continue; + + // If the value is empty, because the user is deleting the file + // instance, make an empty File instance that will pass the file + // check but fail required checks + } else if (empty($data[$attribute])) { + $data[$attribute] = new File('', false); // Create the file instance and clear the data instance - $data[$attribute] = new File(Config::get('upchuck.disk.path').'/'.app('upchuck')->path($data[$attribute])); + } else { + $data[$attribute] = $this->makeFileFromPath($data[$attribute]); + } + } // Replace the files and data with the updated set. `setData()` expects the // data to contain files in it. But `getData()` strips out the files. Thus, // they need to be merged back in before being set. - $validation->setData(array_merge($files, $data)); + $validation->setData(array_merge($data)); + } + + /** + * Make a file instance using uphuck from the string input value + * + * @param string $path + * @return File + */ + public function makeFileFromPath($path) + { + $upchuck_path = app('upchuck')->path($path); + $absolute_path = Config::get('upchuck.disk.path').'/'.$upchuck_path; + return new File($absolute_path); + } } diff --git a/classes/Routing/Router.php b/classes/Routing/Router.php index 6a79f022..6307d90d 100644 --- a/classes/Routing/Router.php +++ b/classes/Routing/Router.php @@ -83,17 +83,17 @@ public function registerLogin() { Route::get('/', [ 'as' => 'decoy::account@login', - 'uses' => '\Bkwld\Decoy\Controllers\Login@getLogin', + 'uses' => '\Bkwld\Decoy\Controllers\Login@showLoginForm', ]); Route::post('/', [ 'as' => 'decoy::account@postLogin', - 'uses' => '\Bkwld\Decoy\Controllers\Login@postLogin', + 'uses' => '\Bkwld\Decoy\Controllers\Login@login', ]); Route::get('logout', [ 'as' => 'decoy::account@logout', - 'uses' => '\Bkwld\Decoy\Controllers\Login@getLogout', + 'uses' => '\Bkwld\Decoy\Controllers\Login@logout', ]); } @@ -105,19 +105,19 @@ public function registerLogin() public function registerResetPassword() { Route::get('forgot', ['as' => 'decoy::account@forgot', - 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@getEmail', + 'uses' => '\Bkwld\Decoy\Controllers\ForgotPassword@showLinkRequestForm', ]); Route::post('forgot', ['as' => 'decoy::account@postForgot', - 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@postEmail', + 'uses' => '\Bkwld\Decoy\Controllers\ForgotPassword@sendResetLinkEmail', ]); - Route::get('reset/{code}', ['as' => 'decoy::account@reset', - 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@getReset', + Route::get('password/reset/{code}', ['as' => 'decoy::account@reset', + 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@showResetForm', ]); - Route::post('reset/{code}', ['as' => 'decoy::account@postReset', - 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@postReset', + Route::post('password/reset/{code}', ['as' => 'decoy::account@postReset', + 'uses' => '\Bkwld\Decoy\Controllers\ResetPassword@reset', ]); } diff --git a/classes/ServiceProvider.php b/classes/ServiceProvider.php index 7fc5c60d..4ea142a5 100644 --- a/classes/ServiceProvider.php +++ b/classes/ServiceProvider.php @@ -341,7 +341,7 @@ private function registerPackages() $this->app->register('Bkwld\Upchuck\ServiceProvider'); // Creation of slugs - $this->app->register('Cviebrock\EloquentSluggable\SluggableServiceProvider'); + $this->app->register('Cviebrock\EloquentSluggable\ServiceProvider'); // Support for cloning models $this->app->register('Bkwld\Cloner\ServiceProvider'); diff --git a/composer.json b/composer.json index db44757c..ef19fefb 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "bkwld/laravel-haml": "~2.0", "bkwld/library": "~4.0", "bkwld/upchuck": "^2.0.1", - "cviebrock/eloquent-sluggable": "~3.0", + "cviebrock/eloquent-sluggable": "~4.0", "illuminate/support": "^5.0", "illuminate/console": "^5.0", "symfony/yaml": "~2.5 || ^3.0", @@ -41,12 +41,12 @@ "jenssegers/agent": "~2.1" }, "require-dev": { - "laravel/framework": "5.2.*", + "laravel/framework": "5.3.*", "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", "phpunit/phpunit": "~5.7", - "symfony/css-selector": "2.8.*|3.0.*", - "symfony/dom-crawler": "2.8.*|3.0.*", + "symfony/css-selector": "3.1.*", + "symfony/dom-crawler": "3.1.*", "doctrine/dbal": "^2.5", "satooshi/php-coveralls": "^1.0", "adlawson/vfs": "^0.12.1", diff --git a/example/app/Article.php b/example/app/Article.php index d884499b..161dcec9 100644 --- a/example/app/Article.php +++ b/example/app/Article.php @@ -1,8 +1,10 @@ position)) return; + if (isset($this->position)) { + return; + } $this->position = self::max('position') + 1; } @@ -82,5 +86,4 @@ public function getAdminFeaturedAttribute() { return $this->featured ? 'Featured' : ''; } - } diff --git a/example/app/Console/Kernel.php b/example/app/Console/Kernel.php index 71c519d3..622e774b 100644 --- a/example/app/Console/Kernel.php +++ b/example/app/Console/Kernel.php @@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel * @var array */ protected $commands = [ - // Commands\Inspire::class, + // ]; /** @@ -27,4 +27,14 @@ protected function schedule(Schedule $schedule) // $schedule->command('inspire') // ->hourly(); } + + /** + * Register the Closure based commands for the application. + * + * @return void + */ + protected function commands() + { + require base_path('routes/console.php'); + } } diff --git a/example/app/Events/Event.php b/example/app/Events/Event.php deleted file mode 100644 index ba2f8883..00000000 --- a/example/app/Events/Event.php +++ /dev/null @@ -1,8 +0,0 @@ -expectsJson()) { + return response()->json(['error' => 'Unauthenticated.'], 401); + } + + return redirect()->guest('login'); } } diff --git a/example/app/Http/Controllers/Admin/Articles.php b/example/app/Http/Controllers/Admin/Articles.php index a6435272..41bca8bf 100644 --- a/example/app/Http/Controllers/Admin/Articles.php +++ b/example/app/Http/Controllers/Admin/Articles.php @@ -1,30 +1,31 @@ 'getAdminTitleHtmlAttribute', - 'Status' => 'getAdminFeaturedAttribute', - 'Date' => 'created_at', - ]; - protected $search = [ - 'title', - 'featured' => [ - 'type' => 'select', - 'label' => 'featured status', - 'options' => [ - 1 => 'featured', - 0 => 'not featured', - ] - ], - 'category' => [ - 'type' => 'select', - 'options' => 'App\Article::$categories', - ], - 'date' => 'date', - ]; +class Articles extends Base +{ + protected $title = 'News & Events'; + protected $description = 'News and events yo!'; + protected $columns = [ + 'Title' => 'getAdminTitleHtmlAttribute', + 'Status' => 'getAdminFeaturedAttribute', + 'Date' => 'created_at', + ]; + protected $search = [ + 'title', + 'featured' => [ + 'type' => 'select', + 'label' => 'featured status', + 'options' => [ + 1 => 'featured', + 0 => 'not featured', + ] + ], + 'category' => [ + 'type' => 'select', + 'options' => 'App\Article::$categories', + ], + 'date' => 'date', + ]; } diff --git a/example/app/Http/Controllers/Admin/Slides.php b/example/app/Http/Controllers/Admin/Slides.php index 87caee5a..a41dd07c 100644 --- a/example/app/Http/Controllers/Admin/Slides.php +++ b/example/app/Http/Controllers/Admin/Slides.php @@ -1,9 +1,11 @@ middleware('guest'); + } +} diff --git a/example/app/Http/Controllers/Auth/LoginController.php b/example/app/Http/Controllers/Auth/LoginController.php new file mode 100644 index 00000000..75949531 --- /dev/null +++ b/example/app/Http/Controllers/Auth/LoginController.php @@ -0,0 +1,39 @@ +middleware('guest', ['except' => 'logout']); + } +} diff --git a/example/app/Http/Controllers/Auth/AuthController.php b/example/app/Http/Controllers/Auth/RegisterController.php similarity index 67% rename from example/app/Http/Controllers/Auth/AuthController.php rename to example/app/Http/Controllers/Auth/RegisterController.php index a100dd6e..34c376cf 100644 --- a/example/app/Http/Controllers/Auth/AuthController.php +++ b/example/app/Http/Controllers/Auth/RegisterController.php @@ -5,39 +5,38 @@ use App\User; use Validator; use App\Http\Controllers\Controller; -use Illuminate\Foundation\Auth\ThrottlesLogins; -use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; +use Illuminate\Foundation\Auth\RegistersUsers; -class AuthController extends Controller +class RegisterController extends Controller { /* |-------------------------------------------------------------------------- - | Registration & Login Controller + | Register Controller |-------------------------------------------------------------------------- | - | This controller handles the registration of new users, as well as the - | authentication of existing users. By default, this controller uses - | a simple trait to add these behaviors. Why don't you explore it? + | This controller handles the registration of new users as well as their + | validation and creation. By default this controller uses a trait to + | provide this functionality without requiring any additional code. | */ - use AuthenticatesAndRegistersUsers, ThrottlesLogins; + use RegistersUsers; /** * Where to redirect users after login / registration. * * @var string */ - protected $redirectTo = '/'; + protected $redirectTo = '/home'; /** - * Create a new authentication controller instance. + * Create a new controller instance. * * @return void */ public function __construct() { - $this->middleware($this->guestMiddleware(), ['except' => 'logout']); + $this->middleware('guest'); } /** diff --git a/example/app/Http/Controllers/Auth/PasswordController.php b/example/app/Http/Controllers/Auth/ResetPasswordController.php similarity index 88% rename from example/app/Http/Controllers/Auth/PasswordController.php rename to example/app/Http/Controllers/Auth/ResetPasswordController.php index 1ceed97b..c73bf99f 100644 --- a/example/app/Http/Controllers/Auth/PasswordController.php +++ b/example/app/Http/Controllers/Auth/ResetPasswordController.php @@ -5,7 +5,7 @@ use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\ResetsPasswords; -class PasswordController extends Controller +class ResetPasswordController extends Controller { /* |-------------------------------------------------------------------------- @@ -21,7 +21,7 @@ class PasswordController extends Controller use ResetsPasswords; /** - * Create a new password controller instance. + * Create a new controller instance. * * @return void */ diff --git a/example/app/Http/Controllers/Controller.php b/example/app/Http/Controllers/Controller.php index d492e0b3..03e02a23 100644 --- a/example/app/Http/Controllers/Controller.php +++ b/example/app/Http/Controllers/Controller.php @@ -6,9 +6,8 @@ use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; -use Illuminate\Foundation\Auth\Access\AuthorizesResources; class Controller extends BaseController { - use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests; + use AuthorizesRequests, DispatchesJobs, ValidatesRequests; } diff --git a/example/app/Http/Kernel.php b/example/app/Http/Kernel.php index bffcfd9f..bcabec41 100644 --- a/example/app/Http/Kernel.php +++ b/example/app/Http/Kernel.php @@ -29,10 +29,12 @@ class Kernel extends HttpKernel \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, ], 'api' => [ 'throttle:60,1', + 'bindings', ], ]; @@ -44,9 +46,10 @@ class Kernel extends HttpKernel * @var array */ protected $routeMiddleware = [ - 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, - 'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class, + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, ]; diff --git a/example/app/Http/Middleware/Authenticate.php b/example/app/Http/Middleware/Authenticate.php deleted file mode 100644 index 67abcaea..00000000 --- a/example/app/Http/Middleware/Authenticate.php +++ /dev/null @@ -1,30 +0,0 @@ -guest()) { - if ($request->ajax() || $request->wantsJson()) { - return response('Unauthorized.', 401); - } else { - return redirect()->guest('login'); - } - } - - return $next($request); - } -} diff --git a/example/app/Http/Middleware/RedirectIfAuthenticated.php b/example/app/Http/Middleware/RedirectIfAuthenticated.php index e27860e2..e4cec9c8 100644 --- a/example/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/example/app/Http/Middleware/RedirectIfAuthenticated.php @@ -18,7 +18,7 @@ class RedirectIfAuthenticated public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { - return redirect('/'); + return redirect('/home'); } return $next($request); diff --git a/example/app/Http/Requests/Request.php b/example/app/Http/Requests/Request.php deleted file mode 100644 index 76b2ffd4..00000000 --- a/example/app/Http/Requests/Request.php +++ /dev/null @@ -1,10 +0,0 @@ -registerPolicies($gate); + $this->registerPolicies(); // } diff --git a/example/app/Providers/BroadcastServiceProvider.php b/example/app/Providers/BroadcastServiceProvider.php new file mode 100644 index 00000000..1dcf8d28 --- /dev/null +++ b/example/app/Providers/BroadcastServiceProvider.php @@ -0,0 +1,26 @@ +id === (int) $userId; + }); + } +} diff --git a/example/app/Providers/EventServiceProvider.php b/example/app/Providers/EventServiceProvider.php index 58ce9624..a182657e 100644 --- a/example/app/Providers/EventServiceProvider.php +++ b/example/app/Providers/EventServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; +use Illuminate\Support\Facades\Event; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider @@ -19,14 +19,13 @@ class EventServiceProvider extends ServiceProvider ]; /** - * Register any other events for your application. + * Register any events for your application. * - * @param \Illuminate\Contracts\Events\Dispatcher $events * @return void */ - public function boot(DispatcherContract $events) + public function boot() { - parent::boot($events); + parent::boot(); // } diff --git a/example/app/Providers/RouteServiceProvider.php b/example/app/Providers/RouteServiceProvider.php index bde08819..87ffb05a 100644 --- a/example/app/Providers/RouteServiceProvider.php +++ b/example/app/Providers/RouteServiceProvider.php @@ -2,7 +2,7 @@ namespace App\Providers; -use Illuminate\Routing\Router; +use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; class RouteServiceProvider extends ServiceProvider @@ -19,25 +19,25 @@ class RouteServiceProvider extends ServiceProvider /** * Define your route model bindings, pattern filters, etc. * - * @param \Illuminate\Routing\Router $router * @return void */ - public function boot(Router $router) + public function boot() { // - parent::boot($router); + parent::boot(); } /** * Define the routes for the application. * - * @param \Illuminate\Routing\Router $router * @return void */ - public function map(Router $router) + public function map() { - $this->mapWebRoutes($router); + $this->mapApiRoutes(); + + $this->mapWebRoutes(); // } @@ -47,15 +47,33 @@ public function map(Router $router) * * These routes all receive session state, CSRF protection, etc. * - * @param \Illuminate\Routing\Router $router * @return void */ - protected function mapWebRoutes(Router $router) + protected function mapWebRoutes() + { + Route::group([ + 'middleware' => 'web', + 'namespace' => $this->namespace, + ], function ($router) { + require base_path('routes/web.php'); + }); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + * + * @return void + */ + protected function mapApiRoutes() { - $router->group([ - 'namespace' => $this->namespace, 'middleware' => 'web', + Route::group([ + 'middleware' => 'api', + 'namespace' => $this->namespace, + 'prefix' => 'api', ], function ($router) { - require app_path('Http/routes.php'); + require base_path('routes/api.php'); }); } } diff --git a/example/app/Recipe.php b/example/app/Recipe.php index 8a8912e4..e66a89a3 100644 --- a/example/app/Recipe.php +++ b/example/app/Recipe.php @@ -15,8 +15,8 @@ class Recipe extends Base * @var array */ public static $rules = [ - 'title' => 'required', - 'images.default' => 'image', + 'title' => 'required', + 'images.default' => 'image', 'file' => 'file', ]; @@ -33,5 +33,4 @@ class Recipe extends Base * @var boolean */ static public $localizable = true; - } diff --git a/example/app/Slide.php b/example/app/Slide.php index a47250d5..5cf8b2a1 100644 --- a/example/app/Slide.php +++ b/example/app/Slide.php @@ -1,25 +1,26 @@ 'required', - ]; + /** + * Validation rules + * + * @var array + */ + public static $rules = [ + 'title' => 'required', + ]; - /** - * List of all relationships - * - * @return Illuminate\Database\Eloquent\Relations\Relation - */ - public function article() + /** + * List of all relationships + * + * @return Illuminate\Database\Eloquent\Relations\Relation + */ + public function article() { - return $this->belongsTo('App\Article'); + return $this->belongsTo('App\Article'); } - } diff --git a/example/app/Tag.php b/example/app/Tag.php index 1b5043b8..f6eeeeb2 100644 --- a/example/app/Tag.php +++ b/example/app/Tag.php @@ -1,8 +1,10 @@ orderBy('name'); } - } diff --git a/example/app/User.php b/example/app/User.php index 75741ae4..bfd96a6a 100644 --- a/example/app/User.php +++ b/example/app/User.php @@ -2,10 +2,13 @@ namespace App; +use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { + use Notifiable; + /** * The attributes that are mass assignable. * diff --git a/example/composer.json b/example/composer.json index f30e7297..73b58a13 100644 --- a/example/composer.json +++ b/example/composer.json @@ -1,20 +1,23 @@ { "name": "laravel/laravel", "description": "The Laravel Framework.", - "keywords": ["framework", "laravel"], + "keywords": [ + "framework", + "laravel" + ], "license": "MIT", "type": "project", "require": { - "php": ">=5.5.9", - "laravel/framework": "5.2.*", + "php": ">=5.6.4", + "laravel/framework": "5.3.*", "bkwld/decoy": "*" }, "require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", - "phpunit/phpunit": "~4.0", - "symfony/css-selector": "2.8.*|3.0.*", - "symfony/dom-crawler": "2.8.*|3.0.*" + "phpunit/phpunit": "~5.0", + "symfony/css-selector": "3.1.*", + "symfony/dom-crawler": "3.1.*" }, "autoload": { "classmap": [ @@ -50,4 +53,4 @@ "config": { "preferred-install": "dist" } -} +} \ No newline at end of file diff --git a/example/config/app.php b/example/config/app.php index 71e86659..1aaa7c7a 100644 --- a/example/config/app.php +++ b/example/config/app.php @@ -2,6 +2,18 @@ return [ + /* + |-------------------------------------------------------------------------- + | Application Name + |-------------------------------------------------------------------------- + | + | This value is the name of your application. This value is used when the + | framework needs to place the application's name in a notification or + | any other location as required by the application or its packages. + */ + + 'name' => 'My Application', + /* |-------------------------------------------------------------------------- | Application Environment @@ -138,6 +150,7 @@ Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, + Illuminate\Notifications\NotificationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class, @@ -152,6 +165,7 @@ * Application Service Providers... */ App\Providers\AppServiceProvider::class, + // App\Providers\BroadcastServiceProvider::class, App\Providers\AuthServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, @@ -177,6 +191,7 @@ 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, + 'Bus' => Illuminate\Support\Facades\Bus::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class, @@ -190,6 +205,7 @@ 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, + 'Notification' => Illuminate\Support\Facades\Notification::class, 'Password' => Illuminate\Support\Facades\Password::class, 'Queue' => Illuminate\Support\Facades\Queue::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class, diff --git a/example/config/auth.php b/example/config/auth.php index 3fa7f491..78175010 100644 --- a/example/config/auth.php +++ b/example/config/auth.php @@ -81,10 +81,6 @@ | Resetting Passwords |-------------------------------------------------------------------------- | - | Here you may set the options for resetting passwords including the view - | that is your password reset e-mail. You may also set the name of the - | table that maintains all of the reset tokens for your application. - | | You may specify multiple password reset configurations if you have more | than one user table or model in the application and you want to have | separate password reset settings based on the specific user types. @@ -98,7 +94,6 @@ 'passwords' => [ 'users' => [ 'provider' => 'users', - 'email' => 'auth.emails.password', 'table' => 'password_resets', 'expire' => 60, ], diff --git a/example/config/cache.php b/example/config/cache.php index 3ffa840b..1d3de874 100644 --- a/example/config/cache.php +++ b/example/config/cache.php @@ -11,6 +11,8 @@ | using this caching library. This connection is used when another is | not explicitly specified when executing a given caching function. | + | Supported: "apc", "array", "database", "file", "memcached", "redis" + | */ 'default' => env('CACHE_DRIVER', 'file'), @@ -49,6 +51,14 @@ 'memcached' => [ 'driver' => 'memcached', + 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), + 'sasl' => [ + env('MEMCACHED_USERNAME'), + env('MEMCACHED_PASSWORD'), + ], + 'options' => [ + // Memcached::OPT_CONNECT_TIMEOUT => 2000, + ], 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), diff --git a/example/config/decoy/core.php b/example/config/decoy/core.php index 59a05edd..232ffca8 100644 --- a/example/config/decoy/core.php +++ b/example/config/decoy/core.php @@ -1,33 +1,33 @@ - 'admin', + // The directory for the admin + 'dir' => 'admin', - // The layout to use - 'layout' => 'decoy::layouts.default', + // The layout to use + 'layout' => 'decoy::layouts.default', - // Auth guard and policy to use - 'guard' => 'decoy', - 'policy' => 'Bkwld\Decoy\Auth\Policy@check', + // Auth guard and policy to use + 'guard' => 'decoy', + 'policy' => 'Bkwld\Decoy\Auth\Policy@check', - // Use a password input field for admins - 'obscure_admin_password' => false, + // Use a password input field for admins + 'obscure_admin_password' => false, - // Mail FROM info - 'mail_from_name' => 'Site Admin', - 'mail_from_address' => 'postmaster@'.(app()->runningInConsole() ? - 'locahost' : parse_url(url()->current(), PHP_URL_HOST)), + // Mail FROM info + 'mail_from_name' => 'Site Admin', + 'mail_from_address' => 'postmaster@'.(app()->runningInConsole() ? + 'locahost' : parse_url(url()->current(), PHP_URL_HOST)), - // Allow regex in redirect rules - 'allow_regex_in_redirects' => false, + // Allow regex in redirect rules + 'allow_regex_in_redirects' => false, - // Register routes automatically in ServiceProvider->boot(). You might set - // this to false if the App needed to register some /admin routes and didn't - // want them to get trampled by the Decoy wildcard capture. - 'register_routes' => true, + // Register routes automatically in ServiceProvider->boot(). You might set + // this to false if the App needed to register some /admin routes and didn't + // want them to get trampled by the Decoy wildcard capture. + 'register_routes' => true, - // Set up the default stylesheet and script tags - 'stylesheet' => '/assets/decoy/index.min.css', - 'script' => '/assets/decoy/index.min.js', + // Set up the default stylesheet and script tags + 'stylesheet' => '/assets/decoy/index.min.css', + 'script' => '/assets/decoy/index.min.js', -); +]; diff --git a/example/config/decoy/encode.php b/example/config/decoy/encode.php index 8abca45d..660df8d1 100644 --- a/example/config/decoy/encode.php +++ b/example/config/decoy/encode.php @@ -1,62 +1,62 @@ - 'REQUIRED', - - /** - * The destination directory. In other words, where the encoded video files - * should be pushed to. - * Ex: s3://bucket-name/directory - * Ex: sftp://xx.xx.xx.xx:xx/home/gopagoda/data/public/uploads/encodes - */ - 'destination' => 'REQUIRED', - - /** - * If not empty, subsitute the destiation path that is returned from the - * encoder with this. If this is an absolute path (like the example), then - * Decoy will try and remove the encodes if the encode is deleted. - * Ex: /uploads/encodes - */ - 'destination_root' => '', - - /** - * Settings that can be applied uniquely to each video instance. - */ - 'presets' => [ - - '1080p' => [ - 'title' => '1080p (quality: 2)', - 'settings' => [ - 'quality' => 2, - 'height' => '1080', - ], - ], - - '1080pq3' => [ - 'title' => '1080p (quality: 3)', - 'settings' => [ - 'quality' => 3, - 'height' => '1080', - ], - ], - - '720p' => [ - 'title' => '1080p (quality: 2)', - 'settings' => [ - 'quality' => 2, - 'height' => '720', - ], - ], - - ], - - /** - * A class that implements the Bkwld\Decoy\Input\EncodingProviders\EncoderInterface - * interface and contains the logic to push a video encode request to service - * provider and handle the responses - */ - 'provider' => '\Bkwld\Decoy\Input\EncodingProviders\Zencoder', - -); + 'REQUIRED', + + /** + * The destination directory. In other words, where the encoded video files + * should be pushed to. + * Ex: s3://bucket-name/directory + * Ex: sftp://xx.xx.xx.xx:xx/home/gopagoda/data/public/uploads/encodes + */ + 'destination' => 'REQUIRED', + + /** + * If not empty, subsitute the destiation path that is returned from the + * encoder with this. If this is an absolute path (like the example), then + * Decoy will try and remove the encodes if the encode is deleted. + * Ex: /uploads/encodes + */ + 'destination_root' => '', + + /** + * Settings that can be applied uniquely to each video instance. + */ + 'presets' => [ + + '1080p' => [ + 'title' => '1080p (quality: 2)', + 'settings' => [ + 'quality' => 2, + 'height' => '1080', + ], + ], + + '1080pq3' => [ + 'title' => '1080p (quality: 3)', + 'settings' => [ + 'quality' => 3, + 'height' => '1080', + ], + ], + + '720p' => [ + 'title' => '1080p (quality: 2)', + 'settings' => [ + 'quality' => 2, + 'height' => '720', + ], + ], + + ], + + /** + * A class that implements the Bkwld\Decoy\Input\EncodingProviders\EncoderInterface + * interface and contains the logic to push a video encode request to service + * provider and handle the responses + */ + 'provider' => '\Bkwld\Decoy\Input\EncodingProviders\Zencoder', + +]; diff --git a/example/config/decoy/site.php b/example/config/decoy/site.php index 3d23d597..476cac3f 100644 --- a/example/config/decoy/site.php +++ b/example/config/decoy/site.php @@ -1,4 +1,4 @@ - 'Viewer - Can only read.', ], - /** - * Permissions rules. These are described in more detail in the README. - * - * @var array - */ - 'permissions' => [ - 'viewer' => [ - 'can' => [ - 'manage.articles', - ], - 'cant' => [ - 'destroy.articles', - ] - ], - ], + /** + * Permissions rules. These are described in more detail in the README. + * + * @var array + */ + 'permissions' => [ + 'viewer' => [ + 'can' => [ + 'manage.articles', + ], + 'cant' => [ + 'destroy.articles', + ] + ], + ], /** * A hash of localization slugs and readable labels for all the locales for this @@ -99,8 +99,8 @@ * @return boolean */ // 'log_changes' => true, - 'log_changes' => function($model, $action, $admin_id) { + 'log_changes' => function ($model, $action, $admin_id) { return true; }, -); +]; diff --git a/example/config/queue.php b/example/config/queue.php index d0f732a6..549322ed 100644 --- a/example/config/queue.php +++ b/example/config/queue.php @@ -11,7 +11,7 @@ | API, giving you convenient access to each back-end using the same | syntax for each one. Here you may set the default queue driver. | - | Supported: "null", "sync", "database", "beanstalkd", "sqs", "redis" + | Supported: "sync", "database", "beanstalkd", "sqs", "redis", "null" | */ @@ -38,14 +38,14 @@ 'driver' => 'database', 'table' => 'jobs', 'queue' => 'default', - 'expire' => 60, + 'retry_after' => 90, ], 'beanstalkd' => [ 'driver' => 'beanstalkd', 'host' => 'localhost', 'queue' => 'default', - 'ttr' => 60, + 'retry_after' => 90, ], 'sqs' => [ @@ -61,7 +61,7 @@ 'driver' => 'redis', 'connection' => 'default', 'queue' => 'default', - 'expire' => 60, + 'retry_after' => 90, ], ], diff --git a/example/config/services.php b/example/config/services.php index 287b1186..4460f0ec 100644 --- a/example/config/services.php +++ b/example/config/services.php @@ -8,7 +8,7 @@ |-------------------------------------------------------------------------- | | This file is for storing the credentials for third party services such - | as Stripe, Mailgun, Mandrill, and others. This file provides a sane + | as Stripe, Mailgun, SparkPost and others. This file provides a sane | default location for this type of information, allowing packages | to have a conventional place to find your various credentials. | diff --git a/example/config/session.php b/example/config/session.php index b501055b..e2779ad8 100644 --- a/example/config/session.php +++ b/example/config/session.php @@ -85,6 +85,19 @@ 'table' => 'sessions', + /* + |-------------------------------------------------------------------------- + | Session Cache Store + |-------------------------------------------------------------------------- + | + | When using the "apc" or "memcached" session drivers, you may specify a + | cache store that should be used for these sessions. This value must + | correspond with one of the application's configured cache stores. + | + */ + + 'store' => null, + /* |-------------------------------------------------------------------------- | Session Sweeping Lottery @@ -135,7 +148,7 @@ | */ - 'domain' => null, + 'domain' => env('SESSION_DOMAIN', null), /* |-------------------------------------------------------------------------- @@ -148,7 +161,7 @@ | */ - 'secure' => false, + 'secure' => env('SESSION_SECURE_COOKIE', false), /* |-------------------------------------------------------------------------- diff --git a/example/database/migrations/2014_08_25_144559_encodables_table.php b/example/database/migrations/2014_08_25_144559_encodables_table.php index 63e8ea74..e2a87331 100644 --- a/example/database/migrations/2014_08_25_144559_encodables_table.php +++ b/example/database/migrations/2014_08_25_144559_encodables_table.php @@ -3,39 +3,41 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class EncodablesTable extends Migration { +class EncodablesTable extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() { - Schema::create('encodings', function(Blueprint $table) { - $table->engine = 'InnoDB'; - $table->increments('id'); - $table->string('encodable_type'); - $table->string('encodable_id'); // String for Elements - $table->string('encodable_attribute'); - $table->string('status')->index(); - $table->string('job_id')->nullable()->index(); - $table->text('outputs')->nullable(); - $table->text('message')->nullable(); - $table->timestamps(); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('encodings', function (Blueprint $table) { + $table->engine = 'InnoDB'; + $table->increments('id'); + $table->string('encodable_type'); + $table->string('encodable_id'); // String for Elements + $table->string('encodable_attribute'); + $table->string('status')->index(); + $table->string('job_id')->nullable()->index(); + $table->text('outputs')->nullable(); + $table->text('message')->nullable(); + $table->timestamps(); - $table->index(['encodable_id', 'encodable_type', 'encodable_attribute']); - $table->index(['encodable_type', 'encodable_id', 'encodable_attribute']); - $table->index(['encodable_attribute', 'encodable_id', 'encodable_type']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() { - Schema::drop('encodings'); - } + $table->index(['encodable_id', 'encodable_type', 'encodable_attribute']); + $table->index(['encodable_type', 'encodable_id', 'encodable_attribute']); + $table->index(['encodable_attribute', 'encodable_id', 'encodable_type']); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('encodings'); + } } diff --git a/example/database/migrations/2014_10_12_000000_create_users_table.php b/example/database/migrations/2014_10_12_000000_create_users_table.php index 59aa01a5..55574ee4 100644 --- a/example/database/migrations/2014_10_12_000000_create_users_table.php +++ b/example/database/migrations/2014_10_12_000000_create_users_table.php @@ -1,5 +1,6 @@ string('email')->index(); $table->string('token')->index(); - $table->timestamp('created_at'); + $table->timestamp('created_at')->nullable(); }); } diff --git a/example/database/migrations/2014_11_04_090719_elements_table.php b/example/database/migrations/2014_11_04_090719_elements_table.php index daf796d3..db9989ee 100644 --- a/example/database/migrations/2014_11_04_090719_elements_table.php +++ b/example/database/migrations/2014_11_04_090719_elements_table.php @@ -3,35 +3,36 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class ElementsTable extends Migration { - - /** - * Run the migrations. - * - * @return void - */ - public function up() { - Schema::create('elements', function($table){ - $table->engine = 'InnoDB'; - - $table->string('key'); - $table->string('type'); - $table->mediumtext('value')->nullable(); - $table->string('locale'); - - $table->primary(['key', 'locale']); - $table->index(['locale', 'key']); - - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() { - Schema::drop('elements'); - } - +class ElementsTable extends Migration +{ + + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('elements', function ($table) { + $table->engine = 'InnoDB'; + + $table->string('key'); + $table->string('type'); + $table->mediumtext('value')->nullable(); + $table->string('locale'); + + $table->primary(['key', 'locale']); + $table->index(['locale', 'key']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('elements'); + } } diff --git a/example/database/migrations/2015_04_15_161242_create_admins.php b/example/database/migrations/2015_04_15_161242_create_admins.php index c6dcab71..d2570fc7 100644 --- a/example/database/migrations/2015_04_15_161242_create_admins.php +++ b/example/database/migrations/2015_04_15_161242_create_admins.php @@ -3,43 +3,44 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateAdmins extends Migration { - - /** - * Run the migrations. - * - * @return void - */ - public function up() { - - // Adapted from: - // https://scotch.io/tutorials/simple-and-easy-laravel-login-authentication - Schema::create('admins', function(Blueprint $table) { - $table->engine = 'InnoDB'; - $table->increments('id'); - - $table->string('first_name'); - $table->string('last_name'); - $table->string('email')->index(); - $table->string('password'); - $table->string('image')->nullable(); - $table->string('role'); - $table->text('permissions')->nullable(); - $table->rememberToken(); - $table->boolean('active'); - - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('admins'); - } - +class CreateAdmins extends Migration +{ + + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + + // Adapted from: + // https://scotch.io/tutorials/simple-and-easy-laravel-login-authentication + Schema::create('admins', function (Blueprint $table) { + $table->engine = 'InnoDB'; + $table->increments('id'); + + $table->string('first_name'); + $table->string('last_name'); + $table->string('email')->index(); + $table->string('password'); + $table->string('image')->nullable(); + $table->string('role'); + $table->text('permissions')->nullable(); + $table->rememberToken(); + $table->boolean('active'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('admins'); + } } diff --git a/example/database/migrations/2015_06_08_133737_create_changes.php b/example/database/migrations/2015_06_08_133737_create_changes.php index 82322171..77ba54b2 100644 --- a/example/database/migrations/2015_06_08_133737_create_changes.php +++ b/example/database/migrations/2015_06_08_133737_create_changes.php @@ -3,46 +3,47 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateChanges extends Migration { - - /** - * Run the migrations. - * - * @return void - */ - public function up() { - Schema::create('changes', function($table) { - $table->engine = 'InnoDB'; - $table->increments('id'); - - $table->string('model'); - $table->string('key'); - $table->string('action'); - $table->string('title')->nullable(); - $table->longText('changed')->nullable(); - - $table->integer('admin_id')->unsigned(); - $table->longText('meta')->nullable(); - $table->boolean('deleted')->nullable(); - $table->timestamps(); - - $table->index(['model', 'key']); - $table->index(['key', 'model']); - $table->index(['action', 'created_at']); - $table->index(['created_at', 'action']); - $table->index(['deleted', 'created_at']); - $table->foreign('admin_id')->references('id')->on('admins')->onUpdate('cascade')->onDelete('cascade'); - - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() { - Schema::drop('changes'); - } - +class CreateChanges extends Migration +{ + + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('changes', function ($table) { + $table->engine = 'InnoDB'; + $table->increments('id'); + + $table->string('model'); + $table->string('key'); + $table->string('action'); + $table->string('title')->nullable(); + $table->longText('changed')->nullable(); + + $table->integer('admin_id')->unsigned(); + $table->longText('meta')->nullable(); + $table->boolean('deleted')->nullable(); + $table->timestamps(); + + $table->index(['model', 'key']); + $table->index(['key', 'model']); + $table->index(['action', 'created_at']); + $table->index(['created_at', 'action']); + $table->index(['deleted', 'created_at']); + $table->foreign('admin_id')->references('id')->on('admins')->onUpdate('cascade')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('changes'); + } } diff --git a/example/database/migrations/2015_07_07_160435_create_redirect_rules.php b/example/database/migrations/2015_07_07_160435_create_redirect_rules.php index e67b6ac0..20a535e3 100644 --- a/example/database/migrations/2015_07_07_160435_create_redirect_rules.php +++ b/example/database/migrations/2015_07_07_160435_create_redirect_rules.php @@ -3,34 +3,36 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateRedirectRules extends Migration { +class CreateRedirectRules extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() { - Schema::create('redirect_rules', function(Blueprint $table) { - $table->engine = 'InnoDB'; - $table->increments('id'); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('redirect_rules', function (Blueprint $table) { + $table->engine = 'InnoDB'; + $table->increments('id'); - $table->string('from')->index(); - $table->string('to'); - $table->string('code'); - $table->string('label')->nullable(); + $table->string('from')->index(); + $table->string('to'); + $table->string('code'); + $table->string('label')->nullable(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() { - Schema::drop('redirect_rules'); - } + $table->timestamps(); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('redirect_rules'); + } } diff --git a/example/database/migrations/2016_01_14_220627_create_images.php b/example/database/migrations/2016_01_14_220627_create_images.php index d71a3430..68a80cf1 100644 --- a/example/database/migrations/2016_01_14_220627_create_images.php +++ b/example/database/migrations/2016_01_14_220627_create_images.php @@ -5,45 +5,45 @@ class CreateImages extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('images', function (Blueprint $table) { - $table->engine = 'InnoDB'; - $table->increments('id'); - - $table->string('imageable_type'); - $table->string('imageable_id'); - - $table->string('file'); - $table->string('file_type'); - $table->string('file_size'); - - $table->string('name')->nullable(); // Key used to refer to it in code - $table->string('title')->nullable(); // Alt title - $table->text('crop_box')->nullable(); - $table->string('focal_point')->nullable(); - - $table->integer('width')->unsigned(); - $table->integer('height')->unsigned(); - $table->timestamps(); - - $table->index(['imageable_type', 'imageable_id']); - $table->index(['imageable_id', 'imageable_type']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('images'); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('images', function (Blueprint $table) { + $table->engine = 'InnoDB'; + $table->increments('id'); + + $table->string('imageable_type'); + $table->string('imageable_id'); + + $table->string('file'); + $table->string('file_type'); + $table->string('file_size'); + + $table->string('name')->nullable(); // Key used to refer to it in code + $table->string('title')->nullable(); // Alt title + $table->text('crop_box')->nullable(); + $table->string('focal_point')->nullable(); + + $table->integer('width')->unsigned(); + $table->integer('height')->unsigned(); + $table->timestamps(); + + $table->index(['imageable_type', 'imageable_id']); + $table->index(['imageable_id', 'imageable_type']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('images'); + } } diff --git a/example/database/migrations/2017_03_22_202910_create_tags.php b/example/database/migrations/2017_03_22_202910_create_tags.php index b0eafc4e..4faca82e 100644 --- a/example/database/migrations/2017_03_22_202910_create_tags.php +++ b/example/database/migrations/2017_03_22_202910_create_tags.php @@ -25,7 +25,6 @@ public function up() ->onUpdate('cascade') ->onDelete('cascade'); }); - } /** diff --git a/example/database/migrations/2017_03_24_224708_create_recipes.php b/example/database/migrations/2017_03_24_224708_create_recipes.php index 67c4bf86..20f147a5 100644 --- a/example/database/migrations/2017_03_24_224708_create_recipes.php +++ b/example/database/migrations/2017_03_24_224708_create_recipes.php @@ -20,7 +20,7 @@ public function up() $table->string('file')->nullable(); $table->string('locale'); - $table->string('locale_group')->index(); + $table->string('locale_group')->index(); $table->boolean('public')->index(); $table->timestamps(); }); diff --git a/example/gulpfile.js b/example/gulpfile.js index dc6f1ebb..442dd3fd 100644 --- a/example/gulpfile.js +++ b/example/gulpfile.js @@ -1,4 +1,6 @@ -var elixir = require('laravel-elixir'); +const elixir = require('laravel-elixir'); + +require('laravel-elixir-vue-2'); /* |-------------------------------------------------------------------------- @@ -11,6 +13,7 @@ var elixir = require('laravel-elixir'); | */ -elixir(function(mix) { - mix.sass('app.scss'); +elixir(mix => { + mix.sass('app.scss') + .webpack('app.js'); }); diff --git a/example/package.json b/example/package.json index c4a056b6..e9993aa8 100644 --- a/example/package.json +++ b/example/package.json @@ -5,8 +5,14 @@ "dev": "gulp watch" }, "devDependencies": { + "bootstrap-sass": "^3.3.7", "gulp": "^3.9.1", - "laravel-elixir": "^5.0.0", - "bootstrap-sass": "^3.0.0" + "jquery": "^3.1.0", + "laravel-elixir": "^6.0.0-9", + "laravel-elixir-vue-2": "^0.2.0", + "laravel-elixir-webpack-official": "^1.0.2", + "lodash": "^4.16.2", + "vue": "^2.0.1", + "vue-resource": "^1.0.3" } } diff --git a/example/resources/lang/en/validation.php b/example/resources/lang/en/validation.php index b1e61204..73b49d08 100644 --- a/example/resources/lang/en/validation.php +++ b/example/resources/lang/en/validation.php @@ -34,9 +34,11 @@ 'different' => 'The :attribute and :other must be different.', 'digits' => 'The :attribute must be :digits digits.', 'digits_between' => 'The :attribute must be between :min and :max digits.', + 'dimensions' => 'The :attribute has invalid image dimensions.', 'distinct' => 'The :attribute field has a duplicate value.', 'email' => 'The :attribute must be a valid email address.', 'exists' => 'The selected :attribute is invalid.', + 'file' => 'The :attribute must be a file.', 'filled' => 'The :attribute field is required.', 'image' => 'The :attribute must be an image.', 'in' => 'The selected :attribute is invalid.', @@ -51,6 +53,7 @@ 'array' => 'The :attribute may not have more than :max items.', ], 'mimes' => 'The :attribute must be a file of type: :values.', + 'mimetypes' => 'The :attribute must be a file of type: :values.', 'min' => [ 'numeric' => 'The :attribute must be at least :min.', 'file' => 'The :attribute must be at least :min kilobytes.', @@ -78,6 +81,7 @@ 'string' => 'The :attribute must be a string.', 'timezone' => 'The :attribute must be a valid zone.', 'unique' => 'The :attribute has already been taken.', + 'uploaded' => 'The :attribute failed to upload.', 'url' => 'The :attribute format is invalid.', /* diff --git a/example/routes/api.php b/example/routes/api.php new file mode 100644 index 00000000..6b907f39 --- /dev/null +++ b/example/routes/api.php @@ -0,0 +1,18 @@ +user(); +})->middleware('auth:api'); diff --git a/example/routes/console.php b/example/routes/console.php new file mode 100644 index 00000000..75dd0cde --- /dev/null +++ b/example/routes/console.php @@ -0,0 +1,18 @@ +comment(Inspiring::quote()); +})->describe('Display an inspiring quote'); diff --git a/example/app/Http/routes.php b/example/routes/web.php similarity index 87% rename from example/app/Http/routes.php rename to example/routes/web.php index 6834e1ed..c6511171 100644 --- a/example/app/Http/routes.php +++ b/example/routes/web.php @@ -15,6 +15,6 @@ return view('welcome'); }); -Route::get('article/{slug}', ['as' => 'article', function($slug) { +Route::get('article/{slug}', ['as' => 'article', function ($slug) { return 'hello'; }]); diff --git a/tests/Integration/AdminTest.php b/tests/Integration/AdminTest.php index 05359e83..faa6fb60 100644 --- a/tests/Integration/AdminTest.php +++ b/tests/Integration/AdminTest.php @@ -109,7 +109,7 @@ public function testResetPasswordFormIndex() 'created_at' => Carbon::now(), ]); - $response = $this->get('admin/reset/'.$token); + $response = $this->get('admin/password/reset/'.$token); $this->assertResponseOk(); } @@ -129,7 +129,7 @@ public function testResetPasswordFormSave() 'created_at' => Carbon::now(), ]); - $response = $this->post('admin/reset/'.$token, [ + $response = $this->post('admin/password/reset/'.$token, [ 'email' => 'test@domain.com', 'password' => 'farting', 'password_confirmation' => 'farting', diff --git a/tests/Integration/FileTest.php b/tests/Integration/FileTest.php index ad3e2955..9dcd000c 100644 --- a/tests/Integration/FileTest.php +++ b/tests/Integration/FileTest.php @@ -91,6 +91,7 @@ public function testImageUploadStore() '_save' => 'save', ]), [], $files); + $this->assertResponseStatus(302); $article = Article::findBySlug('example-title'); $this->assertNotEmpty($article->img()->url); }