├── public ├── favicon.ico ├── robots.txt ├── .DS_Store ├── .htaccess ├── css │ ├── parsley.css │ ├── styles.css │ └── select2.min.css ├── web.config ├── index.php └── js │ └── parsley.min.js ├── app ├── Listeners │ └── .gitkeep ├── Policies │ └── .gitkeep ├── Events │ └── Event.php ├── Http │ ├── Requests │ │ └── Request.php │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── VerifyCsrfToken.php │ │ ├── RedirectIfAuthenticated.php │ │ └── Authenticate.php │ ├── Controllers │ │ ├── Controller.php │ │ ├── BlogController.php │ │ ├── Auth │ │ │ ├── PasswordController.php │ │ │ └── AuthController.php │ │ ├── PagesController.php │ │ ├── CategoryController.php │ │ ├── TagController.php │ │ ├── CommentsController.php │ │ └── PostController.php │ ├── Kernel.php │ └── routes.php ├── Comment.php ├── Tag.php ├── Category.php ├── Post.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php ├── User.php ├── Jobs │ └── Job.php ├── Console │ ├── Commands │ │ └── Inspire.php │ └── Kernel.php └── Exceptions │ └── Handler.php ├── database ├── seeds │ ├── .gitkeep │ └── DatabaseSeeder.php ├── migrations │ ├── .gitkeep │ ├── 2016_05_30_153615_create_tags_table.php │ ├── 2016_03_20_162017_add_slug_to_users.php │ ├── 2016_04_28_021908_create_categories_table.php │ ├── 2016_02_06_175142_create_posts_table.php │ ├── 2016_08_15_000718_add_image_col_to_posts.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2016_04_28_022255_add_category_id_to_posts.php │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2016_05_30_155417_create_post_tag_table.php │ └── 2016_07_16_173641_create_comments_table.php ├── .gitignore └── factories │ └── ModelFactory.php ├── resources ├── views │ ├── vendor │ │ └── .gitkeep │ ├── .DS_Store │ ├── partials │ │ ├── _footer.blade.php │ │ ├── _javascript.blade.php │ │ ├── _messages.blade.php │ │ ├── _head.blade.php │ │ └── _nav.blade.php │ ├── emails │ │ └── contact.blade.php │ ├── auth │ │ ├── emails │ │ │ └── password.blade.php │ │ ├── login.blade.php │ │ ├── passwords │ │ │ ├── email.blade.php │ │ │ └── reset.blade.php │ │ └── register.blade.php │ ├── tags │ │ ├── edit.blade.php │ │ ├── index.blade.php │ │ └── show.blade.php │ ├── main.blade.php │ ├── pages │ │ ├── about.blade.php │ │ ├── contact.blade.php │ │ └── welcome.blade.php │ ├── comments │ │ ├── delete.blade.php │ │ └── edit.blade.php │ ├── blog │ │ ├── index.blade.php │ │ └── single.blade.php │ ├── categories │ │ └── index.blade.php │ ├── errors │ │ └── 503.blade.php │ └── posts │ │ ├── index.blade.php │ │ ├── create.blade.php │ │ ├── edit.blade.php │ │ └── show.blade.php ├── assets │ └── sass │ │ └── app.scss └── lang │ └── en │ ├── pagination.php │ ├── auth.php │ ├── passwords.php │ └── validation.php ├── storage ├── app │ └── .gitignore ├── logs │ └── .gitignore └── framework │ ├── cache │ └── .gitignore │ ├── views │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── bootstrap ├── cache │ └── .gitignore ├── autoload.php └── app.php ├── .gitattributes ├── .gitignore ├── package.json ├── .env.example ├── tests ├── ExampleTest.php └── TestCase.php ├── gulpfile.js ├── server.php ├── phpunit.xml ├── config ├── compile.php ├── services.php ├── view.php ├── broadcasting.php ├── purifier.php ├── cache.php ├── queue.php ├── filesystems.php ├── auth.php ├── mail.php ├── database.php ├── session.php └── app.php ├── composer.json ├── artisan └── readme.md /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/Listeners/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/Policies/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /database/seeds/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /database/migrations/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /resources/views/vendor/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.less linguist-vendored 4 | -------------------------------------------------------------------------------- /public/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacurtis/laravel-blog-tutorial/HEAD/public/.DS_Store -------------------------------------------------------------------------------- /resources/assets/sass/app.scss: -------------------------------------------------------------------------------- 1 | // @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap"; 2 | 3 | -------------------------------------------------------------------------------- /app/Events/Event.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Copyright Jacurtis - All Rights Reserved

-------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | compiled.php 4 | services.json 5 | events.scanned.php 6 | routes.scanned.php 7 | down 8 | -------------------------------------------------------------------------------- /resources/views/emails/contact.blade.php: -------------------------------------------------------------------------------- 1 |

You Have a New Contact Via the Contact Form

2 | 3 |
4 | {{ $bodyMessage }} 5 |
6 | 7 |

Sent via {{ $email }}

-------------------------------------------------------------------------------- /app/Http/Requests/Request.php: -------------------------------------------------------------------------------- 1 | 2 | {{ $link }} -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "devDependencies": { 4 | "gulp": "^3.8.8" 5 | }, 6 | "dependencies": { 7 | "laravel-elixir": "^4.0.0", 8 | "bootstrap-sass": "^3.0.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /app/Comment.php: -------------------------------------------------------------------------------- 1 | belongsTo('App\Post'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/Tag.php: -------------------------------------------------------------------------------- 1 | belongsToMany('App\Post'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/Category.php: -------------------------------------------------------------------------------- 1 | hasMany('App\Post'); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UserTableSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | belongsTo('App\Category'); 12 | } 13 | 14 | public function tags() 15 | { 16 | return $this->belongsToMany('App\Tag'); 17 | } 18 | 19 | public function comments() 20 | { 21 | return $this->hasMany('App\Comment'); 22 | } 23 | } -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_ENV=local 2 | APP_DEBUG=true 3 | APP_KEY=SomeRandomString 4 | 5 | DB_HOST=localhost 6 | DB_DATABASE=homestead 7 | DB_USERNAME=homestead 8 | DB_PASSWORD=secret 9 | 10 | CACHE_DRIVER=file 11 | SESSION_DRIVER=file 12 | QUEUE_DRIVER=sync 13 | 14 | REDIS_HOST=localhost 15 | REDIS_PASSWORD=null 16 | REDIS_PORT=6379 17 | 18 | MAIL_DRIVER=smtp 19 | MAIL_HOST=mailtrap.io 20 | MAIL_PORT=2525 21 | MAIL_USERNAME=null 22 | MAIL_PASSWORD=null 23 | MAIL_ENCRYPTION=null 24 | -------------------------------------------------------------------------------- /resources/views/partials/_javascript.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/views/tags/edit.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', "| Edit Tag") 4 | 5 | @section('content') 6 | 7 | {{ Form::model($tag, ['route' => ['tags.update', $tag->id], 'method' => "PUT"]) }} 8 | 9 | {{ Form::label('name', "Title:") }} 10 | {{ Form::text('name', null, ['class' => 'form-control']) }} 11 | 12 | {{ Form::submit('Save Changes', ['class' => 'btn btn-success', 'style' => 'margin-top:20px;']) }} 13 | {{ Form::close() }} 14 | 15 | @endsection -------------------------------------------------------------------------------- /resources/views/partials/_messages.blade.php: -------------------------------------------------------------------------------- 1 | @if (Session::has('success')) 2 | 3 | 6 | 7 | @endif 8 | 9 | @if (count($errors) > 0) 10 | 11 | 19 | 20 | @endif -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes If Not A Folder... 9 | RewriteCond %{REQUEST_FILENAME} !-d 10 | RewriteRule ^(.*)/$ /$1 [L,R=301] 11 | 12 | # Handle Front Controller... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_FILENAME} !-f 15 | RewriteRule ^ index.php [L] 16 | 17 | -------------------------------------------------------------------------------- /tests/ExampleTest.php: -------------------------------------------------------------------------------- 1 | visit('/') 17 | ->see('Laravel 5'); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /resources/views/main.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @include('partials._head') 5 | 6 | 7 | 8 | 9 | @include('partials._nav') 10 | 11 |
12 | @include('partials._messages') 13 | 14 | @yield('content') 15 | 16 | @include('partials._footer') 17 | 18 |
19 | 20 | @include('partials._javascript') 21 | 22 | @yield('scripts') 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /resources/views/pages/about.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| About') 4 | 5 | @section('content') 6 |
7 |
8 |

About Me

9 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis aspernatur quas quibusdam veniam sunt animi, est quos optio explicabo deleniti inventore unde minus, tempore enim ratione praesentium, cumque, dolores nesciunt?

10 |
11 |
12 | 13 | @endsection 14 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); 22 | 23 | return $app; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /app/Http/Controllers/BlogController.php: -------------------------------------------------------------------------------- 1 | withPosts($posts); 17 | } 18 | 19 | public function getSingle($slug) { 20 | // fetch from the DB based on slug 21 | $post = Post::where('slug', '=', $slug)->first(); 22 | 23 | // return the view and pass in the post object 24 | return view('blog.single')->withPost($post); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resources/views/comments/delete.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| DELETE COMMENT?') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

DELETE THIS COMMENT?

10 |

11 | Name: {{ $comment->name }}
12 | Email: {{ $comment->email }}
13 | Comment: {{ $comment->comment }} 14 |

15 | 16 | {{ Form::open(['route' => ['comments.destroy', $comment->id], 'method' => 'DELETE']) }} 17 | {{ Form::submit('YES DELETE THIS COMMENT', ['class' => 'btn btn-lg btn-block btn-danger']) }} 18 | {{ Form::close() }} 19 |
20 |
21 | 22 | @endsection -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /database/factories/ModelFactory.php: -------------------------------------------------------------------------------- 1 | define(App\User::class, function (Faker\Generator $faker) { 15 | return [ 16 | 'name' => $faker->name, 17 | 'email' => $faker->email, 18 | 'password' => bcrypt(str_random(10)), 19 | 'remember_token' => str_random(10), 20 | ]; 21 | }); 22 | -------------------------------------------------------------------------------- /database/migrations/2016_05_30_153615_create_tags_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('tags'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Console/Commands/Inspire.php: -------------------------------------------------------------------------------- 1 | comment(PHP_EOL.Inspiring::quote().PHP_EOL); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2016_03_20_162017_add_slug_to_users.php: -------------------------------------------------------------------------------- 1 | string('slug')->unique()->after('body'); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | * 23 | * @return void 24 | */ 25 | public function down() 26 | { 27 | Schema::table('posts', function($table) { 28 | $table->dropColumn('slug'); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | ->hourly(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/migrations/2016_04_28_021908_create_categories_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('categories'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /public/css/parsley.css: -------------------------------------------------------------------------------- 1 | input.parsley-success, 2 | select.parsley-success, 3 | textarea.parsley-success { 4 | color: #468847; 5 | background-color: #DFF0D8; 6 | border: 1px solid #D6E9C6; 7 | } 8 | 9 | input.parsley-error, 10 | select.parsley-error, 11 | textarea.parsley-error { 12 | color: #B94A48; 13 | background-color: #F2DEDE; 14 | border: 1px solid #EED3D7; 15 | } 16 | 17 | .parsley-errors-list { 18 | margin: 2px 0 3px; 19 | padding: 0; 20 | list-style-type: none; 21 | font-size: 0.9em; 22 | line-height: 0.9em; 23 | opacity: 0; 24 | 25 | transition: all .3s ease-in; 26 | -o-transition: all .3s ease-in; 27 | -moz-transition: all .3s ease-in; 28 | -webkit-transition: all .3s ease-in; 29 | } 30 | 31 | .parsley-errors-list.filled { 32 | opacity: 1; 33 | } 34 | -------------------------------------------------------------------------------- /public/css/styles.css: -------------------------------------------------------------------------------- 1 | .btn-h1-spacing { 2 | margin-top: 18px; 3 | } 4 | 5 | .form-spacing-top { 6 | margin-top: 30px; 7 | } 8 | 9 | .comment { 10 | margin-bottom: 45px; 11 | } 12 | 13 | .author-image { 14 | width: 50px; 15 | height: 50px; 16 | border-radius: 50%; 17 | float: left; 18 | } 19 | 20 | .author-name { 21 | float: left; 22 | margin-left: 15px; 23 | } 24 | 25 | .author-name>h4 { 26 | margin: 5px 0px; 27 | 28 | } 29 | 30 | .author-time { 31 | font-size: 11px; 32 | font-style: italic; 33 | color: #aaa; 34 | } 35 | 36 | .comment-content { 37 | clear: both; 38 | margin-left: 65px; 39 | font-size: 16px; 40 | line-height: 1.3em; 41 | } 42 | 43 | .comments-title { 44 | margin-bottom:45px; 45 | } 46 | 47 | .comments-title>span { 48 | margin-right: 15px; 49 | } 50 | -------------------------------------------------------------------------------- /database/migrations/2016_02_06_175142_create_posts_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('title'); 18 | $table->text('body'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::drop('posts'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2016_08_15_000718_add_image_col_to_posts.php: -------------------------------------------------------------------------------- 1 | string('image')->nullable()->after('slug'); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | * 23 | * @return void 24 | */ 25 | public function down() 26 | { 27 | Schema::table('posts', function (Blueprint $table) { 28 | $table->dropColumn('image'); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | guest()) { 21 | if ($request->ajax()) { 22 | return response('Unauthorized.', 401); 23 | } else { 24 | return redirect()->guest('auth/login'); 25 | } 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 17 | $table->string('token')->index(); 18 | $table->timestamp('created_at'); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('password_resets'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_04_28_022255_add_category_id_to_posts.php: -------------------------------------------------------------------------------- 1 | integer('category_id')->nullable()->after('slug')->unsigned(); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | * 23 | * @return void 24 | */ 25 | public function down() 26 | { 27 | Schema::table('posts', function (Blueprint $table) { 28 | $table->dropColumn('category_id'); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /resources/views/auth/login.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Login') 4 | 5 | @section('content') 6 | 7 |
8 |
9 | {!! Form::open() !!} 10 | 11 | {{ Form::label('email', 'Email:') }} 12 | {{ Form::email('email', null, ['class' => 'form-control']) }} 13 | 14 | {{ Form::label('password', "Password:") }} 15 | {{ Form::password('password', ['class' => 'form-control']) }} 16 | 17 |
18 | {{ Form::checkbox('remember') }}{{ Form::label('remember', "Remember Me") }} 19 | 20 |
21 | {{ Form::submit('Login', ['class' => 'btn btn-primary btn-block']) }} 22 | 23 |

Forgot My Password 24 | 25 | 26 | {!! Form::close() !!} 27 |

28 |
29 | 30 | @endsection -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any application authentication / authorization services. 21 | * 22 | * @param \Illuminate\Contracts\Auth\Access\Gate $gate 23 | * @return void 24 | */ 25 | public function boot(GateContract $gate) 26 | { 27 | $this->registerPolicies($gate); 28 | 29 | // 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six characters and match the confirmation.', 17 | 'reset' => 'Your password has been reset!', 18 | 'sent' => 'We have e-mailed your password reset link!', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that e-mail address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'App\Listeners\EventListener', 18 | ], 19 | ]; 20 | 21 | /** 22 | * Register any other events for your application. 23 | * 24 | * @param \Illuminate\Contracts\Events\Dispatcher $events 25 | * @return void 26 | */ 27 | public function boot(DispatcherContract $events) 28 | { 29 | parent::boot($events); 30 | 31 | // 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->string('email')->unique(); 19 | $table->string('password', 60); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::drop('users'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /resources/views/auth/passwords/email.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Forgot my Password') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |
10 |
Reset Password
11 | 12 |
13 | @if (session('status')) 14 |
15 | {{ session('status') }} 16 |
17 | @endif 18 | 19 | {!! Form::open(['url' => 'password/email', 'method' => "POST"]) !!} 20 | 21 | {{ Form::label('email', 'Email Address:') }} 22 | {{ Form::email('email', null, ['class' => 'form-control']) }} 23 | 24 | {{ Form::submit('Reset Password', ['class' => 'btn btn-primary']) }} 25 | 26 | {{ Form::close() }} 27 | 28 |
29 |
30 |
31 |
32 | 33 | @endsection -------------------------------------------------------------------------------- /resources/views/auth/register.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Register') 4 | 5 | @section('content') 6 | 7 |
8 |
9 | {!! Form::open() !!} 10 | 11 | {{ Form::label('name', "Name:") }} 12 | {{ Form::text('name', null, ['class' => 'form-control']) }} 13 | 14 | {{ Form::label('email', 'Email:') }} 15 | {{ Form::email('email', null, ['class' => 'form-control']) }} 16 | 17 | {{ Form::label('password', 'Password:') }} 18 | {{ Form::password('password', ['class' => 'form-control']) }} 19 | 20 | {{ Form::label('password_confirmation', 'Confirm Password:') }} 21 | {{ Form::password('password_confirmation', ['class' => 'form-control']) }} 22 | 23 | {{ Form::submit('Register', ['class' => 'btn btn-primary btn-block form-spacing-top']) }} 24 | 25 | {!! Form::close() !!} 26 |
27 |
28 | 29 | @endsection -------------------------------------------------------------------------------- /resources/views/blog/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Blog') 4 | 5 | @section('content') 6 | 7 | 8 |
9 |
10 |

Blog

11 |
12 |
13 | 14 | @foreach ($posts as $post) 15 |
16 |
17 |

{{ $post->title }}

18 |
Published: {{ date('M j, Y', strtotime($post->created_at)) }}
19 | 20 |

{{ substr(strip_tags($post->body), 0, 250) }}{{ strlen(strip_tags($post->body)) > 250 ? '...' : "" }}

21 | 22 | Read More 23 |
24 |
25 |
26 | @endforeach 27 | 28 |
29 |
30 |
31 | {!! $posts->links() !!} 32 |
33 |
34 |
35 | 36 | 37 | @endsection 38 | -------------------------------------------------------------------------------- /resources/views/comments/edit.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Edit Comment') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

Edit Comment

10 | 11 | {{ Form::model($comment, ['route' => ['comments.update', $comment->id], 'method' => 'PUT']) }} 12 | 13 | {{ Form::label('name', 'Name:') }} 14 | {{ Form::text('name', null, ['class' => 'form-control', 'disabled' => '']) }} 15 | 16 | {{ Form::label('email', 'Email:') }} 17 | {{ Form::text('email', null, ['class' => 'form-control', 'disabled' => '']) }} 18 | 19 | {{ Form::label('comment', 'Comment:') }} 20 | {{ Form::textarea('comment', null, ['class' => 'form-control']) }} 21 | 22 | {{ Form::submit('Update Comment', ['class' => 'btn btn-block btn-success', 'style' => 'margin-top: 15px;']) }} 23 | 24 | {{ Form::close() }} 25 |
26 |
27 | 28 | @endsection -------------------------------------------------------------------------------- /database/migrations/2016_05_30_155417_create_post_tag_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->integer('post_id')->unsigned(); 18 | $table->foreign('post_id')->references('id')->on('posts'); 19 | 20 | $table->integer('tag_id')->unsigned(); 21 | $table->foreign('tag_id')->references('id')->on('tags'); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::drop('post_tag'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/ 14 | 15 | 16 | 17 | 18 | app/ 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /resources/views/partials/_head.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Laravel Blog @yield('title') 7 | 8 | 9 | 10 | {{ Html::style('css/styles.css') }} 11 | 12 | @yield('stylesheets') 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /resources/views/auth/passwords/reset.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Forgot my Password') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |
10 |
Reset Password
11 | 12 |
13 | 14 | {!! Form::open(['url' => 'password/reset', 'method' => "POST"]) !!} 15 | 16 | {{ Form::hidden('token', $token) }} 17 | 18 | {{ Form::label('email', 'Email Address:') }} 19 | {{ Form::email('email', $email, ['class' => 'form-control']) }} 20 | 21 | {{ Form::label('password', 'New Password:') }} 22 | {{ Form::password('password', ['class' => 'form-control']) }} 23 | 24 | {{ Form::label('password_confirmation', 'Confirm New Password:') }} 25 | {{ Form::password('password_confirmation', ['class' => 'form-control']) }} 26 | 27 | {{ Form::submit('Reset Password', ['class' => 'btn btn-primary']) }} 28 | 29 | {!! Form::close() !!} 30 | 31 |
32 |
33 |
34 |
35 | 36 | @endsection -------------------------------------------------------------------------------- /resources/views/tags/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| All Tags') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

Tags

10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | @foreach ($tags as $tag) 20 | 21 | 22 | 23 | 24 | @endforeach 25 | 26 |
#Name
{{ $tag->id }}{{ $tag->name }}
27 |
28 | 29 |
30 |
31 | {!! Form::open(['route' => 'tags.store', 'method' => 'POST']) !!} 32 |

New Tag

33 | {{ Form::label('name', 'Name:') }} 34 | {{ Form::text('name', null, ['class' => 'form-control']) }} 35 | 36 | {{ Form::submit('Create New Tag', ['class' => 'btn btn-primary btn-block btn-h1-spacing']) }} 37 | 38 | {!! Form::close() !!} 39 |
40 |
41 |
42 | 43 | @endsection -------------------------------------------------------------------------------- /resources/views/categories/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| All Categories') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

Categories

10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | @foreach ($categories as $category) 20 | 21 | 22 | 23 | 24 | @endforeach 25 | 26 |
#Name
{{ $category->id }}{{ $category->name }}
27 |
28 | 29 |
30 |
31 | {!! Form::open(['route' => 'categories.store', 'method' => 'POST']) !!} 32 |

New Category

33 | {{ Form::label('name', 'Name:') }} 34 | {{ Form::text('name', null, ['class' => 'form-control']) }} 35 | 36 | {{ Form::submit('Create New Category', ['class' => 'btn btn-primary btn-block btn-h1-spacing']) }} 37 | 38 | {!! Form::close() !!} 39 |
40 |
41 |
42 | 43 | @endsection -------------------------------------------------------------------------------- /config/compile.php: -------------------------------------------------------------------------------- 1 | [ 17 | // 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled File Providers 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may list service providers which define a "compiles" function 26 | | that returns additional files that should be compiled, providing an 27 | | easy way to get common files from any packages you are utilizing. 28 | | 29 | */ 30 | 31 | 'providers' => [ 32 | // 33 | ], 34 | 35 | ]; 36 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | ], 21 | 22 | 'mandrill' => [ 23 | 'secret' => env('MANDRILL_SECRET'), 24 | ], 25 | 26 | 'ses' => [ 27 | 'key' => env('SES_KEY'), 28 | 'secret' => env('SES_SECRET'), 29 | 'region' => 'us-east-1', 30 | ], 31 | 32 | 'stripe' => [ 33 | 'model' => App\User::class, 34 | 'key' => env('STRIPE_KEY'), 35 | 'secret' => env('STRIPE_SECRET'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | realpath(base_path('resources/views')), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => realpath(storage_path('framework/views')), 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /database/migrations/2016_07_16_173641_create_comments_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->string('email'); 19 | $table->text('comment'); 20 | $table->boolean('approved'); 21 | $table->integer('post_id')->unsigned(); 22 | $table->timestamps(); 23 | }); 24 | 25 | Schema::table('comments', function ($table){ 26 | $table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade'); 27 | }); 28 | } 29 | 30 | /** 31 | * Reverse the migrations. 32 | * 33 | * @return void 34 | */ 35 | public function down() 36 | { 37 | Schema::dropForeign(['post_id']); 38 | Schema::drop('comments'); 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bootstrap/autoload.php: -------------------------------------------------------------------------------- 1 | group(['namespace' => $this->namespace], function ($router) { 41 | require app_path('Http/routes.php'); 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /resources/views/pages/contact.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Contact') 4 | 5 | @section('content') 6 |
7 |
8 |

Contact Me

9 |
10 |
11 | {{ csrf_field() }} 12 |
13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 |
21 | 22 |
23 | 24 | 25 |
26 | 27 | 28 |
29 |
30 |
31 | @endsection -------------------------------------------------------------------------------- /resources/views/errors/503.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Be right back. 5 | 6 | 7 | 8 | 39 | 40 | 41 |
42 |
43 |
Be right back.
44 |
45 |
46 | 47 | 48 | -------------------------------------------------------------------------------- /resources/views/pages/welcome.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Homepage') 4 | 5 | @section('content') 6 |
7 |
8 |
9 |

Welcome to My Blog!

10 |

Thank you so much for visiting. This is my test website built with Laravel. Please read my popular post!

11 |

Popular Post

12 |
13 |
14 |
15 | 16 |
17 |
18 | 19 | @foreach($posts as $post) 20 | 21 |
22 |

{{ $post->title }}

23 |

{{ substr(strip_tags($post->body), 0, 300) }}{{ strlen(strip_tags($post->body)) > 300 ? "..." : "" }}

24 | Read More 25 |
26 | 27 |
28 | 29 | @endforeach 30 | 31 |
32 | 33 |
34 |

Sidebar

35 |
36 |
37 | @stop -------------------------------------------------------------------------------- /resources/views/posts/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| All Posts') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

All Posts

10 |
11 | 12 |
13 | Create New Post 14 |
15 |
16 |
17 |
18 |
19 | 20 |
21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | @foreach ($posts as $post) 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | @endforeach 44 | 45 | 46 |
#TitleBodyCreated At
{{ $post->id }}{{ $post->title }}{{ substr(strip_tags($post->body), 0, 50) }}{{ strlen(strip_tags($post->body)) > 50 ? "..." : "" }}{{ date('M j, Y', strtotime($post->created_at)) }}View Edit
47 | 48 |
49 | {!! $posts->links(); !!} 50 |
51 |
52 |
53 | 54 | @stop -------------------------------------------------------------------------------- /resources/views/tags/show.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', "| $tag->name Tag") 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

{{ $tag->name }} Tag {{ $tag->posts()->count() }} Posts

10 |
11 |
12 | Edit 13 |
14 |
15 | {{ Form::open(['route' => ['tags.destroy', $tag->id], 'method' => 'DELETE']) }} 16 | {{ Form::submit('Delete', ['class' => 'btn btn-danger btn-block', 'style' => 'margin-top:20px;']) }} 17 | {{ Form::close() }} 18 |
19 |
20 | 21 |
22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | @foreach ($tag->posts as $post) 35 | 36 | 37 | 38 | 42 | 43 | 44 | @endforeach 45 | 46 |
#TitleTags
{{ $post->id }}{{ $post->title }}@foreach ($post->tags as $tag) 39 | {{ $tag->name }} 40 | @endforeach 41 | View
47 |
48 |
49 | 50 | @endsection -------------------------------------------------------------------------------- /app/Http/Controllers/PagesController.php: -------------------------------------------------------------------------------- 1 | limit(4)->get(); 16 | return view('pages.welcome')->withPosts($posts); 17 | } 18 | 19 | public function getAbout() { 20 | $first = 'Alex'; 21 | $last = 'Curtis'; 22 | 23 | $fullname = $first . " " . $last; 24 | $email = 'alex@jacurtis.com'; 25 | $data = []; 26 | $data['email'] = $email; 27 | $data['fullname'] = $fullname; 28 | return view('pages.about')->withData($data); 29 | } 30 | 31 | public function getContact() { 32 | return view('pages.contact'); 33 | } 34 | 35 | public function postContact(Request $request) { 36 | $this->validate($request, [ 37 | 'email' => 'required|email', 38 | 'subject' => 'min:3', 39 | 'message' => 'min:10']); 40 | 41 | $data = array( 42 | 'email' => $request->email, 43 | 'subject' => $request->subject, 44 | 'bodyMessage' => $request->message 45 | ); 46 | 47 | Mail::send('emails.contact', $data, function($message) use ($data){ 48 | $message->from($data['email']); 49 | $message->to('hello@devmarketer.io'); 50 | $message->subject($data['subject']); 51 | }); 52 | 53 | Session::flash('success', 'Your Email was Sent!'); 54 | 55 | return redirect('/'); 56 | } 57 | 58 | 59 | } -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'pusher'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Broadcast Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may define all of the broadcast connections that will be used 24 | | to broadcast events to other systems or over websockets. Samples of 25 | | each available type of connection are provided inside this array. 26 | | 27 | */ 28 | 29 | 'connections' => [ 30 | 31 | 'pusher' => [ 32 | 'driver' => 'pusher', 33 | 'key' => env('PUSHER_KEY'), 34 | 'secret' => env('PUSHER_SECRET'), 35 | 'app_id' => env('PUSHER_APP_ID'), 36 | 'options' => [ 37 | // 38 | ], 39 | ], 40 | 41 | 'redis' => [ 42 | 'driver' => 'redis', 43 | 'connection' => 'default', 44 | ], 45 | 46 | 'log' => [ 47 | 'driver' => 'log', 48 | ], 49 | 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": ["framework", "laravel"], 5 | "license": "MIT", 6 | "type": "project", 7 | "require": { 8 | "php": ">=5.5.9", 9 | "laravel/framework": "5.2.*", 10 | "laravelcollective/html": "5.2.*", 11 | "mews/purifier": "^2.0", 12 | "intervention/image": "^2.3" 13 | }, 14 | "require-dev": { 15 | "fzaninotto/faker": "~1.4", 16 | "mockery/mockery": "0.9.*", 17 | "phpunit/phpunit": "~4.0", 18 | "symfony/css-selector": "2.8.*|3.0.*", 19 | "symfony/dom-crawler": "2.8.*|3.0.*", 20 | "doctrine/dbal" : "*" 21 | }, 22 | "autoload": { 23 | "classmap": [ 24 | "database" 25 | ], 26 | "psr-4": { 27 | "App\\": "app/" 28 | } 29 | }, 30 | "autoload-dev": { 31 | "classmap": [ 32 | "tests/TestCase.php" 33 | ] 34 | }, 35 | "scripts": { 36 | "post-root-package-install": [ 37 | "php -r \"copy('.env.example', '.env');\"" 38 | ], 39 | "post-create-project-cmd": [ 40 | "php artisan key:generate" 41 | ], 42 | "post-install-cmd": [ 43 | "php artisan clear-compiled", 44 | "php artisan optimize" 45 | ], 46 | "pre-update-cmd": [ 47 | "php artisan clear-compiled" 48 | ], 49 | "post-update-cmd": [ 50 | "php artisan optimize" 51 | ] 52 | }, 53 | "config": { 54 | "preferred-install": "dist" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | [ 27 | \App\Http\Middleware\EncryptCookies::class, 28 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 29 | \Illuminate\Session\Middleware\StartSession::class, 30 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 31 | \App\Http\Middleware\VerifyCsrfToken::class, 32 | ], 33 | 34 | 'api' => [ 35 | 'throttle:60,1', 36 | ], 37 | ]; 38 | 39 | /** 40 | * The application's route middleware. 41 | * 42 | * These middleware may be assigned to groups or used individually. 43 | * 44 | * @var array 45 | */ 46 | protected $routeMiddleware = [ 47 | 'auth' => \App\Http\Middleware\Authenticate::class, 48 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 49 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 50 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 51 | ]; 52 | } 53 | -------------------------------------------------------------------------------- /config/purifier.php: -------------------------------------------------------------------------------- 1 | set('Core.Encoding', $this->config->get('purifier.encoding')); 7 | * $config->set('Cache.SerializerPath', $this->config->get('purifier.cachePath')); 8 | * if ( ! $this->config->get('purifier.finalize')) { 9 | * $config->autoFinalize = false; 10 | * } 11 | * $config->loadArray($this->getConfig()); 12 | * 13 | * You must NOT delete the default settings 14 | * anything in settings should be compacted with params that needed to instance HTMLPurifier_Config. 15 | * 16 | * @link http://htmlpurifier.org/live/configdoc/plain.html 17 | */ 18 | 19 | return [ 20 | 'encoding' => 'UTF-8', 21 | 'finalize' => true, 22 | 'cachePath' => storage_path('app/purifier'), 23 | 'cacheFileMode' => 0755, 24 | 'settings' => [ 25 | 'default' => [ 26 | 'HTML.Doctype' => 'XHTML 1.0 Strict', 27 | 'HTML.Allowed' => 'div,b,strong,i,em,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src],h1,h2,h3,h4,h5,h6', 28 | 'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align', 29 | 'AutoFormat.AutoParagraph' => false, 30 | 'AutoFormat.RemoveEmpty' => true, 31 | ], 32 | 'test' => [ 33 | 'Attr.EnableID' => true 34 | ], 35 | "youtube" => [ 36 | "HTML.SafeIframe" => 'true', 37 | "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%", 38 | ], 39 | ], 40 | 41 | ]; 42 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 32 | 33 | $status = $kernel->handle( 34 | $input = new Symfony\Component\Console\Input\ArgvInput, 35 | new Symfony\Component\Console\Output\ConsoleOutput 36 | ); 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Shutdown The Application 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Once Artisan has finished running. We will fire off the shutdown events 44 | | so that any final work may be done by the application before we shut 45 | | down the process. This is the last thing to happen to the request. 46 | | 47 | */ 48 | 49 | $kernel->terminate($input, $status); 50 | 51 | exit($status); 52 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | /* 11 | |-------------------------------------------------------------------------- 12 | | Register The Auto Loader 13 | |-------------------------------------------------------------------------- 14 | | 15 | | Composer provides a convenient, automatically generated class loader for 16 | | our application. We just need to utilize it! We'll simply require it 17 | | into the script here so that we don't have to worry about manual 18 | | loading any of our classes later on. It feels nice to relax. 19 | | 20 | */ 21 | 22 | require __DIR__.'/../bootstrap/autoload.php'; 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Turn On The Lights 27 | |-------------------------------------------------------------------------- 28 | | 29 | | We need to illuminate PHP development, so let us turn on the lights. 30 | | This bootstraps the framework and gets it ready for use, then it 31 | | will load up this application so that we can run it and send 32 | | the responses back to the browser and delight our users. 33 | | 34 | */ 35 | 36 | $app = require_once __DIR__.'/../bootstrap/app.php'; 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Run The Application 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Once we have the application, we can handle the incoming request 44 | | through the kernel, and send the associated response back to 45 | | the client's browser allowing them to enjoy the creative 46 | | and wonderful application we have prepared for them. 47 | | 48 | */ 49 | 50 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 51 | 52 | $response = $kernel->handle( 53 | $request = Illuminate\Http\Request::capture() 54 | ); 55 | 56 | $response->send(); 57 | 58 | $kernel->terminate($request, $response); 59 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/AuthController.php: -------------------------------------------------------------------------------- 1 | middleware('guest', ['except' => 'getLogout']); 41 | } 42 | 43 | /** 44 | * Get a validator for an incoming registration request. 45 | * 46 | * @param array $data 47 | * @return \Illuminate\Contracts\Validation\Validator 48 | */ 49 | protected function validator(array $data) 50 | { 51 | return Validator::make($data, [ 52 | 'name' => 'required|max:255', 53 | 'email' => 'required|email|max:255|unique:users', 54 | 'password' => 'required|confirmed|min:6', 55 | ]); 56 | } 57 | 58 | /** 59 | * Create a new user instance after a valid registration. 60 | * 61 | * @param array $data 62 | * @return User 63 | */ 64 | protected function create(array $data) 65 | { 66 | return User::create([ 67 | 'name' => $data['name'], 68 | 'email' => $data['email'], 69 | 'password' => bcrypt($data['password']), 70 | ]); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /resources/views/partials/_nav.blade.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /resources/views/posts/create.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Create New Post') 4 | 5 | @section('stylesheets') 6 | 7 | {!! Html::style('css/parsley.css') !!} 8 | {!! Html::style('css/select2.min.css') !!} 9 | 10 | 11 | 18 | 19 | @endsection 20 | 21 | @section('content') 22 | 23 |
24 |
25 |

Create New Post

26 |
27 | {!! Form::open(array('route' => 'posts.store', 'data-parsley-validate' => '', 'files' => true)) !!} 28 | {{ Form::label('title', 'Title:') }} 29 | {{ Form::text('title', null, array('class' => 'form-control', 'required' => '', 'maxlength' => '255')) }} 30 | 31 | {{ Form::label('slug', 'Slug:') }} 32 | {{ Form::text('slug', null, array('class' => 'form-control', 'required' => '', 'minlength' => '5', 'maxlength' => '255') ) }} 33 | 34 | {{ Form::label('category_id', 'Category:') }} 35 | 41 | 42 | 43 | {{ Form::label('tags', 'Tags:') }} 44 | 50 | 51 | {{ Form::label('featured_img', 'Upload a Featured Image') }} 52 | {{ Form::file('featured_img') }} 53 | 54 | {{ Form::label('body', "Post Body:") }} 55 | {{ Form::textarea('body', null, array('class' => 'form-control')) }} 56 | 57 | {{ Form::submit('Create Post', array('class' => 'btn btn-success btn-lg btn-block', 'style' => 'margin-top: 20px;')) }} 58 | {!! Form::close() !!} 59 |
60 |
61 | 62 | @endsection 63 | 64 | 65 | @section('scripts') 66 | 67 | {!! Html::script('js/parsley.min.js') !!} 68 | {!! Html::script('js/select2.min.js') !!} 69 | 70 | 73 | 74 | @endsection 75 | -------------------------------------------------------------------------------- /resources/views/blog/single.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | title); ?> 3 | @section('title', "| $titleTag") 4 | 5 | @section('content') 6 | 7 |
8 |
9 | @if(!empty($post->image)) 10 | 11 | @endif 12 |

{{ $post->title }}

13 |

{!! $post->body !!}

14 |
15 |

Posted In: {{ $post->category->name }}

16 |
17 |
18 | 19 |
20 |
21 |

{{ $post->comments()->count() }} Comments

22 | @foreach($post->comments as $comment) 23 |
24 |
25 | 26 | email))) . "?s=50&d=monsterid" }}" class="author-image"> 27 |
28 |

{{ $comment->name }}

29 |

{{ date('F dS, Y - g:iA' ,strtotime($comment->created_at)) }}

30 |
31 | 32 |
33 | 34 |
35 | {{ $comment->comment }} 36 |
37 | 38 |
39 | @endforeach 40 |
41 |
42 | 43 |
44 |
45 | {{ Form::open(['route' => ['comments.store', $post->id], 'method' => 'POST']) }} 46 | 47 |
48 |
49 | {{ Form::label('name', "Name:") }} 50 | {{ Form::text('name', null, ['class' => 'form-control']) }} 51 |
52 | 53 |
54 | {{ Form::label('email', 'Email:') }} 55 | {{ Form::text('email', null, ['class' => 'form-control']) }} 56 |
57 | 58 |
59 | {{ Form::label('comment', "Comment:") }} 60 | {{ Form::textarea('comment', null, ['class' => 'form-control', 'rows' => '5']) }} 61 | 62 | {{ Form::submit('Add Comment', ['class' => 'btn btn-success btn-block', 'style' => 'margin-top:15px;']) }} 63 |
64 |
65 | 66 | {{ Form::close() }} 67 |
68 |
69 | 70 | @endsection 71 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Cache Stores 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may define all of the cache "stores" for your application as 24 | | well as their drivers. You may even define multiple stores for the 25 | | same cache driver to group types of items stored in your caches. 26 | | 27 | */ 28 | 29 | 'stores' => [ 30 | 31 | 'apc' => [ 32 | 'driver' => 'apc', 33 | ], 34 | 35 | 'array' => [ 36 | 'driver' => 'array', 37 | ], 38 | 39 | 'database' => [ 40 | 'driver' => 'database', 41 | 'table' => 'cache', 42 | 'connection' => null, 43 | ], 44 | 45 | 'file' => [ 46 | 'driver' => 'file', 47 | 'path' => storage_path('framework/cache'), 48 | ], 49 | 50 | 'memcached' => [ 51 | 'driver' => 'memcached', 52 | 'servers' => [ 53 | [ 54 | 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100, 55 | ], 56 | ], 57 | ], 58 | 59 | 'redis' => [ 60 | 'driver' => 'redis', 61 | 'connection' => 'default', 62 | ], 63 | 64 | ], 65 | 66 | /* 67 | |-------------------------------------------------------------------------- 68 | | Cache Key Prefix 69 | |-------------------------------------------------------------------------- 70 | | 71 | | When utilizing a RAM based store such as APC or Memcached, there might 72 | | be other applications utilizing the same cache. So, we'll specify a 73 | | value to get prefixed to all our keys so we can avoid collisions. 74 | | 75 | */ 76 | 77 | 'prefix' => 'laravel', 78 | 79 | ]; 80 | -------------------------------------------------------------------------------- /resources/views/posts/edit.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Edit Blog Post') 4 | 5 | @section('stylesheets') 6 | 7 | {!! Html::style('css/select2.min.css') !!} 8 | 9 | 10 | 11 | 18 | 19 | @endsection 20 | 21 | @section('content') 22 | 23 |
24 | {!! Form::model($post, ['route' => ['posts.update', $post->id], 'method' => 'PUT']) !!} 25 |
26 | {{ Form::label('title', 'Title:') }} 27 | {{ Form::text('title', null, ["class" => 'form-control input-lg']) }} 28 | 29 | {{ Form::label('slug', 'Slug:', ['class' => 'form-spacing-top']) }} 30 | {{ Form::text('slug', null, ['class' => 'form-control']) }} 31 | 32 | {{ Form::label('category_id', "Category:", ['class' => 'form-spacing-top']) }} 33 | {{ Form::select('category_id', $categories, null, ['class' => 'form-control']) }} 34 | 35 | {{ Form::label('tags', 'Tags:', ['class' => 'form-spacing-top']) }} 36 | {{ Form::select('tags[]', $tags, null, ['class' => 'form-control select2-multi', 'multiple' => 'multiple']) }} 37 | 38 | {{ Form::label('body', "Body:", ['class' => 'form-spacing-top']) }} 39 | {{ Form::textarea('body', null, ['class' => 'form-control']) }} 40 |
41 | 42 |
43 |
44 |
45 |
Created At:
46 |
{{ date('M j, Y h:ia', strtotime($post->created_at)) }}
47 |
48 | 49 |
50 |
Last Updated:
51 |
{{ date('M j, Y h:ia', strtotime($post->updated_at)) }}
52 |
53 |
54 |
55 |
56 | {!! Html::linkRoute('posts.show', 'Cancel', array($post->id), array('class' => 'btn btn-danger btn-block')) !!} 57 |
58 |
59 | {{ Form::submit('Save Changes', ['class' => 'btn btn-success btn-block']) }} 60 |
61 |
62 | 63 |
64 |
65 | {!! Form::close() !!} 66 |
67 | 68 | @stop 69 | 70 | @section('scripts') 71 | 72 | {!! Html::script('js/select2.min.js') !!} 73 | 74 | 80 | 81 | @endsection -------------------------------------------------------------------------------- /app/Http/Controllers/CategoryController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 16 | } 17 | 18 | /** 19 | * Display a listing of the resource. 20 | * 21 | * @return \Illuminate\Http\Response 22 | */ 23 | public function index() 24 | { 25 | // display a view of all of our categories 26 | // it will also have a form to create a new category 27 | 28 | $categories = Category::all(); 29 | return view('categories.index')->withCategories($categories); 30 | 31 | } 32 | 33 | /** 34 | * Store a newly created resource in storage. 35 | * 36 | * @param \Illuminate\Http\Request $request 37 | * @return \Illuminate\Http\Response 38 | */ 39 | public function store(Request $request) 40 | { 41 | // Save a new category and then redirect back to index 42 | $this->validate($request, array( 43 | 'name' => 'required|max:255' 44 | )); 45 | 46 | $category = new Category; 47 | 48 | $category->name = $request->name; 49 | $category->save(); 50 | 51 | Session::flash('success', 'New Category has been created'); 52 | 53 | return redirect()->route('categories.index'); 54 | } 55 | 56 | /** 57 | * Display the specified resource. 58 | * 59 | * @param int $id 60 | * @return \Illuminate\Http\Response 61 | */ 62 | public function show($id) 63 | { 64 | // Display the category and all the posts in that category 65 | } 66 | 67 | /** 68 | * Show the form for editing the specified resource. 69 | * 70 | * @param int $id 71 | * @return \Illuminate\Http\Response 72 | */ 73 | public function edit($id) 74 | { 75 | // 76 | } 77 | 78 | /** 79 | * Update the specified resource in storage. 80 | * 81 | * @param \Illuminate\Http\Request $request 82 | * @param int $id 83 | * @return \Illuminate\Http\Response 84 | */ 85 | public function update(Request $request, $id) 86 | { 87 | // 88 | } 89 | 90 | /** 91 | * Remove the specified resource from storage. 92 | * 93 | * @param int $id 94 | * @return \Illuminate\Http\Response 95 | */ 96 | public function destroy($id) 97 | { 98 | // 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_DRIVER', 'sync'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Queue Connections 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may configure the connection information for each server that 27 | | is used by your application. A default configuration has been added 28 | | for each back-end shipped with Laravel. You are free to add more. 29 | | 30 | */ 31 | 32 | 'connections' => [ 33 | 34 | 'sync' => [ 35 | 'driver' => 'sync', 36 | ], 37 | 38 | 'database' => [ 39 | 'driver' => 'database', 40 | 'table' => 'jobs', 41 | 'queue' => 'default', 42 | 'expire' => 60, 43 | ], 44 | 45 | 'beanstalkd' => [ 46 | 'driver' => 'beanstalkd', 47 | 'host' => 'localhost', 48 | 'queue' => 'default', 49 | 'ttr' => 60, 50 | ], 51 | 52 | 'sqs' => [ 53 | 'driver' => 'sqs', 54 | 'key' => 'your-public-key', 55 | 'secret' => 'your-secret-key', 56 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', 57 | 'queue' => 'your-queue-name', 58 | 'region' => 'us-east-1', 59 | ], 60 | 61 | 'redis' => [ 62 | 'driver' => 'redis', 63 | 'connection' => 'default', 64 | 'queue' => 'default', 65 | 'expire' => 60, 66 | ], 67 | 68 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Failed Queue Jobs 73 | |-------------------------------------------------------------------------- 74 | | 75 | | These options configure the behavior of failed queue job logging so you 76 | | can control which database and table are used to store the jobs that 77 | | have failed. You may change them to any database / table you wish. 78 | | 79 | */ 80 | 81 | 'failed' => [ 82 | 'database' => env('DB_CONNECTION', 'mysql'), 83 | 'table' => 'failed_jobs', 84 | ], 85 | 86 | ]; 87 | -------------------------------------------------------------------------------- /app/Http/routes.php: -------------------------------------------------------------------------------- 1 | ['web']], function () { 27 | // Authentication Routes 28 | Route::get('auth/login', ['as' => 'login', 'uses' => 'Auth\AuthController@getLogin']); 29 | Route::post('auth/login', 'Auth\AuthController@postLogin'); 30 | Route::get('auth/logout', ['as' => 'logout', 'uses' => 'Auth\AuthController@getLogout']); 31 | 32 | // Registration Routes 33 | Route::get('auth/register', 'Auth\AuthController@getRegister'); 34 | Route::post('auth/register', 'Auth\AuthController@postRegister'); 35 | 36 | // Password Reset Routes 37 | Route::get('password/reset/{token?}', 'Auth\PasswordController@showResetForm'); 38 | Route::post('password/email', 'Auth\PasswordController@sendResetLinkEmail'); 39 | Route::post('password/reset', 'Auth\PasswordController@reset'); 40 | 41 | // Categories 42 | Route::resource('categories', 'CategoryController', ['except' => ['create']]); 43 | Route::resource('tags', 'TagController', ['except' => ['create']]); 44 | 45 | // Comments 46 | Route::post('comments/{post_id}', ['uses' => 'CommentsController@store', 'as' => 'comments.store']); 47 | Route::get('comments/{id}/edit', ['uses' => 'CommentsController@edit', 'as' => 'comments.edit']); 48 | Route::put('comments/{id}', ['uses' => 'CommentsController@update', 'as' => 'comments.update']); 49 | Route::delete('comments/{id}', ['uses' => 'CommentsController@destroy', 'as' => 'comments.destroy']); 50 | Route::get('comments/{id}/delete', ['uses' => 'CommentsController@delete', 'as' => 'comments.delete']); 51 | 52 | 53 | Route::get('blog/{slug}', ['as' => 'blog.single', 'uses' => 'BlogController@getSingle'])->where('slug', '[\w\d\-\_]+'); 54 | Route::get('blog', ['uses' => 'BlogController@getIndex', 'as' => 'blog.index']); 55 | Route::get('contact', 'PagesController@getContact'); 56 | Route::post('contact', 'PagesController@postContact'); 57 | Route::get('about', 'PagesController@getAbout'); 58 | Route::get('/', 'PagesController@getIndex'); 59 | Route::resource('posts', 'PostController'); 60 | }); 61 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | 'local', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Default Cloud Filesystem Disk 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Many applications store files both locally and in the cloud. For this 26 | | reason, you may specify a default "cloud" driver here. This driver 27 | | will be bound as the Cloud disk implementation in the container. 28 | | 29 | */ 30 | 31 | 'cloud' => 's3', 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Filesystem Disks 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Here you may configure as many filesystem "disks" as you wish, and you 39 | | may even configure multiple disks of the same driver. Defaults have 40 | | been setup for each driver as an example of the required options. 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'ftp' => [ 52 | 'driver' => 'ftp', 53 | 'host' => 'ftp.example.com', 54 | 'username' => 'your-username', 55 | 'password' => 'your-password', 56 | 57 | // Optional FTP Settings... 58 | // 'port' => 21, 59 | // 'root' => '', 60 | // 'passive' => true, 61 | // 'ssl' => true, 62 | // 'timeout' => 30, 63 | ], 64 | 65 | 's3' => [ 66 | 'driver' => 's3', 67 | 'key' => 'your-key', 68 | 'secret' => 'your-secret', 69 | 'region' => 'your-region', 70 | 'bucket' => 'your-bucket', 71 | ], 72 | 73 | 'rackspace' => [ 74 | 'driver' => 'rackspace', 75 | 'username' => 'your-username', 76 | 'key' => 'your-key', 77 | 'container' => 'your-container', 78 | 'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/', 79 | 'region' => 'IAD', 80 | 'url_type' => 'publicURL', 81 | ], 82 | 83 | ], 84 | 85 | ]; 86 | -------------------------------------------------------------------------------- /resources/views/posts/show.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| View Post') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

{{ $post->title }}

10 | 11 |

{!! $post->body !!}

12 | 13 |
14 | 15 |
16 | @foreach ($post->tags as $tag) 17 | {{ $tag->name }} 18 | @endforeach 19 |
20 | 21 |
22 |

Comments {{ $post->comments()->count() }} total

23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | @foreach ($post->comments as $comment) 36 | 37 | 38 | 39 | 40 | 44 | 45 | @endforeach 46 | 47 |
NameEmailComment
{{ $comment->name }}{{ $comment->email }}{{ $comment->comment }} 41 | 42 | 43 |
48 |
49 |
50 | 51 |
52 |
53 |
54 | 55 |

{{ route('blog.single', $post->slug) }}

56 |
57 | 58 |
59 | 60 |

{{ $post->category->name }}

61 |
62 | 63 |
64 | 65 |

{{ date('M j, Y h:ia', strtotime($post->created_at)) }}

66 |
67 | 68 |
69 | 70 |

{{ date('M j, Y h:ia', strtotime($post->updated_at)) }}

71 |
72 |
73 |
74 |
75 | {!! Html::linkRoute('posts.edit', 'Edit', array($post->id), array('class' => 'btn btn-primary btn-block')) !!} 76 |
77 |
78 | {!! Form::open(['route' => ['posts.destroy', $post->id], 'method' => 'DELETE']) !!} 79 | 80 | {!! Form::submit('Delete', ['class' => 'btn btn-danger btn-block']) !!} 81 | 82 | {!! Form::close() !!} 83 |
84 |
85 | 86 |
87 |
88 | {{ Html::linkRoute('posts.index', '<< See All Posts', array(), ['class' => 'btn btn-default btn-block btn-h1-spacing']) }} 89 |
90 |
91 | 92 |
93 |
94 |
95 | 96 | @endsection -------------------------------------------------------------------------------- /app/Http/Controllers/TagController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 16 | } 17 | 18 | /** 19 | * Display a listing of the resource. 20 | * 21 | * @return \Illuminate\Http\Response 22 | */ 23 | public function index() 24 | { 25 | $tags = Tag::all(); 26 | return view('tags.index')->withTags($tags); 27 | } 28 | 29 | /** 30 | * Store a newly created resource in storage. 31 | * 32 | * @param \Illuminate\Http\Request $request 33 | * @return \Illuminate\Http\Response 34 | */ 35 | public function store(Request $request) 36 | { 37 | $this->validate($request, array('name' => 'required|max:255')); 38 | $tag = new Tag; 39 | $tag->name = $request->name; 40 | $tag->save(); 41 | 42 | Session::flash('success', 'New Tag was successfully created!'); 43 | 44 | return redirect()->route('tags.index'); 45 | } 46 | 47 | /** 48 | * Display the specified resource. 49 | * 50 | * @param int $id 51 | * @return \Illuminate\Http\Response 52 | */ 53 | public function show($id) 54 | { 55 | $tag = Tag::find($id); 56 | return view('tags.show')->withTag($tag); 57 | } 58 | 59 | /** 60 | * Show the form for editing the specified resource. 61 | * 62 | * @param int $id 63 | * @return \Illuminate\Http\Response 64 | */ 65 | public function edit($id) 66 | { 67 | $tag = Tag::find($id); 68 | return view('tags.edit')->withTag($tag); 69 | } 70 | 71 | /** 72 | * Update the specified resource in storage. 73 | * 74 | * @param \Illuminate\Http\Request $request 75 | * @param int $id 76 | * @return \Illuminate\Http\Response 77 | */ 78 | public function update(Request $request, $id) 79 | { 80 | $tag = Tag::find($id); 81 | 82 | $this->validate($request, ['name' => 'required|max:255']); 83 | 84 | $tag->name = $request->name; 85 | $tag->save(); 86 | 87 | Session::flash('success', 'Successfully saved your new tag!'); 88 | 89 | return redirect()->route('tags.show', $tag->id); 90 | } 91 | 92 | /** 93 | * Remove the specified resource from storage. 94 | * 95 | * @param int $id 96 | * @return \Illuminate\Http\Response 97 | */ 98 | public function destroy($id) 99 | { 100 | $tag = Tag::find($id); 101 | $tag->posts()->detach(); 102 | 103 | $tag->delete(); 104 | 105 | Session::flash('success', 'Tag was deleted successfully'); 106 | 107 | return redirect()->route('tags.index'); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/Http/Controllers/CommentsController.php: -------------------------------------------------------------------------------- 1 | middleware('auth', ['except' => 'store']); 17 | } 18 | 19 | /** 20 | * Store a newly created resource in storage. 21 | * 22 | * @param \Illuminate\Http\Request $request 23 | * @return \Illuminate\Http\Response 24 | */ 25 | public function store(Request $request, $post_id) 26 | { 27 | $this->validate($request, array( 28 | 'name' => 'required|max:255', 29 | 'email' => 'required|email|max:255', 30 | 'comment' => 'required|min:5|max:2000' 31 | )); 32 | 33 | $post = Post::find($post_id); 34 | 35 | $comment = new Comment(); 36 | $comment->name = $request->name; 37 | $comment->email = $request->email; 38 | $comment->comment = $request->comment; 39 | $comment->approved = true; 40 | $comment->post()->associate($post); 41 | 42 | $comment->save(); 43 | 44 | Session::flash('success', 'Comment was added'); 45 | 46 | return redirect()->route('blog.single', [$post->slug]); 47 | } 48 | 49 | 50 | /** 51 | * Show the form for editing the specified resource. 52 | * 53 | * @param int $id 54 | * @return \Illuminate\Http\Response 55 | */ 56 | public function edit($id) 57 | { 58 | $comment = Comment::find($id); 59 | return view('comments.edit')->withComment($comment); 60 | } 61 | 62 | /** 63 | * Update the specified resource in storage. 64 | * 65 | * @param \Illuminate\Http\Request $request 66 | * @param int $id 67 | * @return \Illuminate\Http\Response 68 | */ 69 | public function update(Request $request, $id) 70 | { 71 | $comment = Comment::find($id); 72 | 73 | $this->validate($request, array('comment' => 'required')); 74 | 75 | $comment->comment = $request->comment; 76 | $comment->save(); 77 | 78 | Session::flash('success', 'Comment updated'); 79 | 80 | return redirect()->route('posts.show', $comment->post->id); 81 | } 82 | 83 | public function delete($id) 84 | { 85 | $comment = Comment::find($id); 86 | return view('comments.delete')->withComment($comment); 87 | } 88 | 89 | /** 90 | * Remove the specified resource from storage. 91 | * 92 | * @param int $id 93 | * @return \Illuminate\Http\Response 94 | */ 95 | public function destroy($id) 96 | { 97 | $comment = Comment::find($id); 98 | $post_id = $comment->post->id; 99 | $comment->delete(); 100 | 101 | Session::flash('success', 'Deleted Comment'); 102 | 103 | return redirect()->route('posts.show', $post_id); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'token', 46 | 'provider' => 'users', 47 | ], 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | User Providers 53 | |-------------------------------------------------------------------------- 54 | | 55 | | All authentication drivers have a user provider. This defines how the 56 | | users are actually retrieved out of your database or other storage 57 | | mechanisms used by this application to persist your user's data. 58 | | 59 | | If you have multiple user tables or models you may configure multiple 60 | | sources which represent each model / table. These sources may then 61 | | be assigned to any extra authentication guards you have defined. 62 | | 63 | | Supported: "database", "eloquent" 64 | | 65 | */ 66 | 67 | 'providers' => [ 68 | 'users' => [ 69 | 'driver' => 'eloquent', 70 | 'model' => App\User::class, 71 | ], 72 | 73 | // 'users' => [ 74 | // 'driver' => 'database', 75 | // 'table' => 'users', 76 | // ], 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Resetting Passwords 82 | |-------------------------------------------------------------------------- 83 | | 84 | | Here you may set the options for resetting passwords including the view 85 | | that is your password reset e-mail. You may also set the name of the 86 | | table that maintains all of the reset tokens for your application. 87 | | 88 | | You may specify multiple password reset configurations if you have more 89 | | than one user table or model in the application and you want to have 90 | | separate password reset settings based on the specific user types. 91 | | 92 | | The expire time is the number of minutes that the reset token should be 93 | | considered valid. This security feature keeps tokens short-lived so 94 | | they have less time to be guessed. You may change this as needed. 95 | | 96 | */ 97 | 98 | 'passwords' => [ 99 | 'users' => [ 100 | 'provider' => 'users', 101 | 'email' => 'auth.emails.password', 102 | 'table' => 'password_resets', 103 | 'expire' => 60, 104 | ], 105 | ], 106 | 107 | ]; 108 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # How To Build a (Basic) Blog with Laravel 2 | 3 | #### A YouTube Series by DevMarketer 4 | 5 | --- 6 | 7 | Full Playlist for the "How to Build a Blog with Laravel" Series: [Watch FREE on YouTube](https://www.youtube.com/playlist?list=PLwAKR305CRO-Q90J---jXVzbOd4CDRbVx) 8 | 9 | 10 | Laravel is one of the fastest growing and most popular frameworks on the internet right now. In this series we not only explore what makes Laravel great, but learn concepts of CRUD (Create, Read, Update, Delete), MVC (Model, View, Controller), and other web technologies to create a blog application built on top of Laravel. 11 | 12 | This series is almost 50 parts in length and spans almost 20 hours of learning. All of it is provided free of charge in the hope of helping new web developers grow and learn from this oppourtunity. 13 | 14 | This project is sponsored and opperated by DevMarketer.io who's goal is to provide educational materials to help people *Build and Grow Their Next Great Idea*. Not only do you need to understand how to build great software applications, but you must also learn business and marketing concepts in order to turn a great idea into a great business. 15 | 16 | ## Subscribe and Follow 17 | 18 | Be sure to follow along with all our videos on the [YouTube DevMarketer Channel](https://www.youtube.com/channel/UC6kwT7-jjZHHF1s7vCfg2CA?sub_confirmation=1) 19 | 20 | You can also get the most of our community by joining us on our hub at [DevMarketer.io](http://DevMarketer.io) which includes: 21 | 22 | - Forums 23 | - Blog 24 | - Free eBooks 25 | - Other content 26 | 27 | ## Known Bugs 28 | 29 | This is a long series teaching how to buid a blog system. Everything is caught on video which greatly slows down the development process. Also with so many skills needing to be taught in such a short period of time, many bugs will naturally arise as they do in any development project. What makes things tricky is that after a video goes live, it is difficult to highlight and impliment bug fixes. Source code needs to stay in sync with the videos, many of which do not highlight these bugs fixes. 30 | 31 | The solution is to create a bug log of known bugs and known resolutions that can be fixed at a later time. 32 | 33 | - **Part 24:** On line 3 of our `resources/views/blog/single.blade.php` file we call `$post->title` without escaping the data (or sanitizing it prior to saving in the DB). **This makes the application vulnerable to XSS.** 34 | 35 | - Solution: the `$post->title` should be wrapped in `htmlspecialchars()` like this: `htmlspecialchars($post->title)`. [View the issue on GitHub](https://github.com/jacurtis/laravel-blog-tutorial/issues/1). 36 | 37 | 38 | - **Part 38:** When a user leaves the tag multi-select box empty upon creating a new tag, an error occurs because we do not check if the tag field is empty like we do when updating a tag. 39 | 40 | - Solution: Add an `if` statement to check if the tag field has anything in it, if it does, then sync, otherwise do nothing. 41 | 42 | 43 | ## Feedback 44 | 45 | Thank you for all the great feedback so far. If you have further questions you can either create an issue on the item here on github that we can discuss via comments, or you can reach out to me on either Twitter or Email. 46 | 47 | Twitter: [Twitter @_jacurtis](http://twitter.com/_jacurtis) (Be sure to follow me too) 48 | 49 | Email: hello@devmarketer.io 50 | 51 | ## Hire Me 52 | 53 | I personally provide consulting services for **project management** and **marketing**. 54 | 55 | My 10 years of experience running fast growth companies can benefit any company looking to grow quickly and efficiently. I focus not only on growth but also on setting up pro-active systems to ensure that growth can be maintained. Many companies have suffered under large growth scales, but with the right systems in place we can grow without compromising company quality. 56 | 57 | If you are looking to start a web development project I am happy to work with you as a contract project manager. I am very skilled in working directly with executive teams to understand vision and to pass that onto development teams to maximize business ROI and efficiency. 58 | 59 | For all requests or quotes on Marketing or Project Management consulting, please email me at business@jacurtis.com 60 | 61 | 62 | 63 | ### License 64 | 65 | This project and the underlying Laravel framework are open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_DRIVER', 'smtp'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | SMTP Host Address 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may provide the host address of the SMTP server used by your 26 | | applications. A default option is provided that is compatible with 27 | | the Mailgun mail service which will provide reliable deliveries. 28 | | 29 | */ 30 | 31 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | SMTP Host Port 36 | |-------------------------------------------------------------------------- 37 | | 38 | | This is the SMTP port used by your application to deliver e-mails to 39 | | users of the application. Like the host we have set this value to 40 | | stay compatible with the Mailgun e-mail application by default. 41 | | 42 | */ 43 | 44 | 'port' => env('MAIL_PORT', 587), 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Global "From" Address 49 | |-------------------------------------------------------------------------- 50 | | 51 | | You may wish for all e-mails sent by your application to be sent from 52 | | the same address. Here, you may specify a name and address that is 53 | | used globally for all e-mails that are sent by your application. 54 | | 55 | */ 56 | 57 | 'from' => ['address' => 'noreply@jacurtis.com', 'name' => 'Laravel Application'], 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | E-Mail Encryption Protocol 62 | |-------------------------------------------------------------------------- 63 | | 64 | | Here you may specify the encryption protocol that should be used when 65 | | the application send e-mail messages. A sensible default using the 66 | | transport layer security protocol should provide great security. 67 | | 68 | */ 69 | 70 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 71 | 72 | /* 73 | |-------------------------------------------------------------------------- 74 | | SMTP Server Username 75 | |-------------------------------------------------------------------------- 76 | | 77 | | If your SMTP server requires a username for authentication, you should 78 | | set it here. This will get used to authenticate with your server on 79 | | connection. You may also set the "password" value below this one. 80 | | 81 | */ 82 | 83 | 'username' => env('MAIL_USERNAME'), 84 | 85 | /* 86 | |-------------------------------------------------------------------------- 87 | | SMTP Server Password 88 | |-------------------------------------------------------------------------- 89 | | 90 | | Here you may set the password required by your SMTP server to send out 91 | | messages from your application. This will be given to the server on 92 | | connection so that the application will be able to send messages. 93 | | 94 | */ 95 | 96 | 'password' => env('MAIL_PASSWORD'), 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Sendmail System Path 101 | |-------------------------------------------------------------------------- 102 | | 103 | | When using the "sendmail" driver to send e-mails, we will need to know 104 | | the path to where Sendmail lives on this server. A default path has 105 | | been provided here, which will work well on most of your systems. 106 | | 107 | */ 108 | 109 | 'sendmail' => '/usr/sbin/sendmail -bs', 110 | 111 | ]; 112 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | PDO::FETCH_CLASS, 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Database Connection Name 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may specify which of the database connections below you wish 24 | | to use as your default connection for all database work. Of course 25 | | you may use many connections at once using the Database library. 26 | | 27 | */ 28 | 29 | 'default' => env('DB_CONNECTION', 'mysql'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Database Connections 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here are each of the database connections setup for your application. 37 | | Of course, examples of configuring each database platform that is 38 | | supported by Laravel is shown below to make development simple. 39 | | 40 | | 41 | | All database work in Laravel is done through the PHP PDO facilities 42 | | so make sure you have the driver for your particular database of 43 | | choice installed on your machine before you begin development. 44 | | 45 | */ 46 | 47 | 'connections' => [ 48 | 49 | 'sqlite' => [ 50 | 'driver' => 'sqlite', 51 | 'database' => database_path('database.sqlite'), 52 | 'prefix' => '', 53 | ], 54 | 55 | 'mysql' => [ 56 | 'driver' => 'mysql', 57 | 'host' => env('DB_HOST', 'localhost'), 58 | 'database' => env('DB_DATABASE', 'forge'), 59 | 'username' => env('DB_USERNAME', 'forge'), 60 | 'password' => env('DB_PASSWORD', ''), 61 | 'charset' => 'utf8', 62 | 'collation' => 'utf8_unicode_ci', 63 | 'prefix' => '', 64 | 'strict' => false, 65 | ], 66 | 67 | 'pgsql' => [ 68 | 'driver' => 'pgsql', 69 | 'host' => env('DB_HOST', 'localhost'), 70 | 'database' => env('DB_DATABASE', 'forge'), 71 | 'username' => env('DB_USERNAME', 'forge'), 72 | 'password' => env('DB_PASSWORD', ''), 73 | 'charset' => 'utf8', 74 | 'prefix' => '', 75 | 'schema' => 'public', 76 | ], 77 | 78 | 'sqlsrv' => [ 79 | 'driver' => 'sqlsrv', 80 | 'host' => env('DB_HOST', 'localhost'), 81 | 'database' => env('DB_DATABASE', 'forge'), 82 | 'username' => env('DB_USERNAME', 'forge'), 83 | 'password' => env('DB_PASSWORD', ''), 84 | 'charset' => 'utf8', 85 | 'prefix' => '', 86 | ], 87 | 88 | ], 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Migration Repository Table 93 | |-------------------------------------------------------------------------- 94 | | 95 | | This table keeps track of all the migrations that have already run for 96 | | your application. Using this information, we can determine which of 97 | | the migrations on disk haven't actually been run in the database. 98 | | 99 | */ 100 | 101 | 'migrations' => 'migrations', 102 | 103 | /* 104 | |-------------------------------------------------------------------------- 105 | | Redis Databases 106 | |-------------------------------------------------------------------------- 107 | | 108 | | Redis is an open source, fast, and advanced key-value store that also 109 | | provides a richer set of commands than a typical key-value systems 110 | | such as APC or Memcached. Laravel makes it easy to dig right in. 111 | | 112 | */ 113 | 114 | 'redis' => [ 115 | 116 | 'cluster' => false, 117 | 118 | 'default' => [ 119 | 'host' => env('REDIS_HOST', 'localhost'), 120 | 'password' => env('REDIS_PASSWORD', null), 121 | 'port' => env('REDIS_PORT', 6379), 122 | 'database' => 0, 123 | ], 124 | 125 | ], 126 | 127 | ]; 128 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Session Lifetime 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify the number of minutes that you wish the session 27 | | to be allowed to remain idle before it expires. If you want them 28 | | to immediately expire on the browser closing, set that option. 29 | | 30 | */ 31 | 32 | 'lifetime' => 120, 33 | 34 | 'expire_on_close' => false, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Session Encryption 39 | |-------------------------------------------------------------------------- 40 | | 41 | | This option allows you to easily specify that all of your session data 42 | | should be encrypted before it is stored. All encryption will be run 43 | | automatically by Laravel and you can use the Session like normal. 44 | | 45 | */ 46 | 47 | 'encrypt' => false, 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Session File Location 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When using the native session driver, we need a location where session 55 | | files may be stored. A default has been set for you but a different 56 | | location may be specified. This is only needed for file sessions. 57 | | 58 | */ 59 | 60 | 'files' => storage_path('framework/sessions'), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Session Database Connection 65 | |-------------------------------------------------------------------------- 66 | | 67 | | When using the "database" or "redis" session drivers, you may specify a 68 | | connection that should be used to manage these sessions. This should 69 | | correspond to a connection in your database configuration options. 70 | | 71 | */ 72 | 73 | 'connection' => null, 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Session Database Table 78 | |-------------------------------------------------------------------------- 79 | | 80 | | When using the "database" session driver, you may specify the table we 81 | | should use to manage the sessions. Of course, a sensible default is 82 | | provided for you; however, you are free to change this as needed. 83 | | 84 | */ 85 | 86 | 'table' => 'sessions', 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Session Sweeping Lottery 91 | |-------------------------------------------------------------------------- 92 | | 93 | | Some session drivers must manually sweep their storage location to get 94 | | rid of old sessions from storage. Here are the chances that it will 95 | | happen on a given request. By default, the odds are 2 out of 100. 96 | | 97 | */ 98 | 99 | 'lottery' => [2, 100], 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Session Cookie Name 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Here you may change the name of the cookie used to identify a session 107 | | instance by ID. The name specified here will get used every time a 108 | | new session cookie is created by the framework for every driver. 109 | | 110 | */ 111 | 112 | 'cookie' => 'laravel_session', 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Session Cookie Path 117 | |-------------------------------------------------------------------------- 118 | | 119 | | The session cookie path determines the path for which the cookie will 120 | | be regarded as available. Typically, this will be the root path of 121 | | your application but you are free to change this when necessary. 122 | | 123 | */ 124 | 125 | 'path' => '/', 126 | 127 | /* 128 | |-------------------------------------------------------------------------- 129 | | Session Cookie Domain 130 | |-------------------------------------------------------------------------- 131 | | 132 | | Here you may change the domain of the cookie used to identify a session 133 | | in your application. This will determine which domains the cookie is 134 | | available to in your application. A sensible default has been set. 135 | | 136 | */ 137 | 138 | 'domain' => null, 139 | 140 | /* 141 | |-------------------------------------------------------------------------- 142 | | HTTPS Only Cookies 143 | |-------------------------------------------------------------------------- 144 | | 145 | | By setting this option to true, session cookies will only be sent back 146 | | to the server if the browser has a HTTPS connection. This will keep 147 | | the cookie from being sent to you if it can not be done securely. 148 | | 149 | */ 150 | 151 | 'secure' => false, 152 | 153 | ]; 154 | -------------------------------------------------------------------------------- /resources/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => 'The :attribute is not a valid URL.', 18 | 'after' => 'The :attribute must be a date after :date.', 19 | 'alpha' => 'The :attribute may only contain letters.', 20 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', 21 | 'alpha_num' => 'The :attribute may only contain letters and numbers.', 22 | 'array' => 'The :attribute must be an array.', 23 | 'before' => 'The :attribute must be a date before :date.', 24 | 'between' => [ 25 | 'numeric' => 'The :attribute must be between :min and :max.', 26 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 27 | 'string' => 'The :attribute must be between :min and :max characters.', 28 | 'array' => 'The :attribute must have between :min and :max items.', 29 | ], 30 | 'boolean' => 'The :attribute field must be true or false.', 31 | 'confirmed' => 'The :attribute confirmation does not match.', 32 | 'date' => 'The :attribute is not a valid date.', 33 | 'date_format' => 'The :attribute does not match the format :format.', 34 | 'different' => 'The :attribute and :other must be different.', 35 | 'digits' => 'The :attribute must be :digits digits.', 36 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 37 | 'email' => 'The :attribute must be a valid email address.', 38 | 'exists' => 'The selected :attribute is invalid.', 39 | 'filled' => 'The :attribute field is required.', 40 | 'image' => 'The :attribute must be an image.', 41 | 'in' => 'The selected :attribute is invalid.', 42 | 'integer' => 'The :attribute must be an integer.', 43 | 'ip' => 'The :attribute must be a valid IP address.', 44 | 'json' => 'The :attribute must be a valid JSON string.', 45 | 'max' => [ 46 | 'numeric' => 'The :attribute may not be greater than :max.', 47 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 48 | 'string' => 'The :attribute may not be greater than :max characters.', 49 | 'array' => 'The :attribute may not have more than :max items.', 50 | ], 51 | 'mimes' => 'The :attribute must be a file of type: :values.', 52 | 'min' => [ 53 | 'numeric' => 'The :attribute must be at least :min.', 54 | 'file' => 'The :attribute must be at least :min kilobytes.', 55 | 'string' => 'The :attribute must be at least :min characters.', 56 | 'array' => 'The :attribute must have at least :min items.', 57 | ], 58 | 'not_in' => 'The selected :attribute is invalid.', 59 | 'numeric' => 'The :attribute must be a number.', 60 | 'regex' => 'The :attribute format is invalid.', 61 | 'required' => 'The :attribute field is required.', 62 | 'required_if' => 'The :attribute field is required when :other is :value.', 63 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 64 | 'required_with' => 'The :attribute field is required when :values is present.', 65 | 'required_with_all' => 'The :attribute field is required when :values is present.', 66 | 'required_without' => 'The :attribute field is required when :values is not present.', 67 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 68 | 'same' => 'The :attribute and :other must match.', 69 | 'size' => [ 70 | 'numeric' => 'The :attribute must be :size.', 71 | 'file' => 'The :attribute must be :size kilobytes.', 72 | 'string' => 'The :attribute must be :size characters.', 73 | 'array' => 'The :attribute must contain :size items.', 74 | ], 75 | 'string' => 'The :attribute must be a string.', 76 | 'timezone' => 'The :attribute must be a valid zone.', 77 | 'unique' => 'The :attribute has already been taken.', 78 | 'url' => 'The :attribute format is invalid.', 79 | 80 | /* 81 | |-------------------------------------------------------------------------- 82 | | Custom Validation Language Lines 83 | |-------------------------------------------------------------------------- 84 | | 85 | | Here you may specify custom validation messages for attributes using the 86 | | convention "attribute.rule" to name the lines. This makes it quick to 87 | | specify a specific custom language line for a given attribute rule. 88 | | 89 | */ 90 | 91 | 'custom' => [ 92 | 'attribute-name' => [ 93 | 'rule-name' => 'custom-message', 94 | ], 95 | ], 96 | 97 | /* 98 | |-------------------------------------------------------------------------- 99 | | Custom Validation Attributes 100 | |-------------------------------------------------------------------------- 101 | | 102 | | The following language lines are used to swap attribute place-holders 103 | | with something more reader friendly such as E-Mail Address instead 104 | | of "email". This simply helps us make messages a little cleaner. 105 | | 106 | */ 107 | 108 | 'attributes' => [], 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /app/Http/Controllers/PostController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 21 | } 22 | /** 23 | * Display a listing of the resource. 24 | * 25 | * @return \Illuminate\Http\Response 26 | */ 27 | public function index() 28 | { 29 | $posts = Post::orderBy('id', 'desc')->paginate(10); 30 | return view('posts.index')->withPosts($posts); 31 | } 32 | 33 | /** 34 | * Show the form for creating a new resource. 35 | * 36 | * @return \Illuminate\Http\Response 37 | */ 38 | public function create() 39 | { 40 | $categories = Category::all(); 41 | $tags = Tag::all(); 42 | return view('posts.create')->withCategories($categories)->withTags($tags); 43 | } 44 | 45 | /** 46 | * Store a newly created resource in storage. 47 | * 48 | * @param \Illuminate\Http\Request $request 49 | * @return \Illuminate\Http\Response 50 | */ 51 | public function store(Request $request) 52 | { 53 | // validate the data 54 | $this->validate($request, array( 55 | 'title' => 'required|max:255', 56 | 'slug' => 'required|alpha_dash|min:5|max:255|unique:posts,slug', 57 | 'category_id' => 'required|integer', 58 | 'body' => 'required' 59 | )); 60 | 61 | // store in the database 62 | $post = new Post; 63 | 64 | $post->title = $request->title; 65 | $post->slug = $request->slug; 66 | $post->category_id = $request->category_id; 67 | $post->body = Purifier::clean($request->body); 68 | 69 | if ($request->hasFile('featured_img')) { 70 | $image = $request->file('featured_img'); 71 | $filename = time() . '.' . $image->getClientOriginalExtension(); 72 | $location = public_path('images/' . $filename); 73 | Image::make($image)->resize(800, 400)->save($location); 74 | 75 | $post->image = $filename; 76 | } 77 | 78 | $post->save(); 79 | 80 | $post->tags()->sync($request->tags, false); 81 | 82 | Session::flash('success', 'The blog post was successfully save!'); 83 | 84 | return redirect()->route('posts.show', $post->id); 85 | } 86 | 87 | /** 88 | * Display the specified resource. 89 | * 90 | * @param int $id 91 | * @return \Illuminate\Http\Response 92 | */ 93 | public function show($id) 94 | { 95 | $post = Post::find($id); 96 | return view('posts.show')->withPost($post); 97 | } 98 | 99 | /** 100 | * Show the form for editing the specified resource. 101 | * 102 | * @param int $id 103 | * @return \Illuminate\Http\Response 104 | */ 105 | public function edit($id) 106 | { 107 | // find the post in the database and save as a var 108 | $post = Post::find($id); 109 | $categories = Category::all(); 110 | $cats = array(); 111 | foreach ($categories as $category) { 112 | $cats[$category->id] = $category->name; 113 | } 114 | 115 | $tags = Tag::all(); 116 | $tags2 = array(); 117 | foreach ($tags as $tag) { 118 | $tags2[$tag->id] = $tag->name; 119 | } 120 | // return the view and pass in the var we previously created 121 | return view('posts.edit')->withPost($post)->withCategories($cats)->withTags($tags2); 122 | } 123 | 124 | /** 125 | * Update the specified resource in storage. 126 | * 127 | * @param \Illuminate\Http\Request $request 128 | * @param int $id 129 | * @return \Illuminate\Http\Response 130 | */ 131 | public function update(Request $request, $id) 132 | { 133 | // Validate the data 134 | $post = Post::find($id); 135 | 136 | if ($request->input('slug') == $post->slug) { 137 | $this->validate($request, array( 138 | 'title' => 'required|max:255', 139 | 'category_id' => 'required|integer', 140 | 'body' => 'required' 141 | )); 142 | } else { 143 | $this->validate($request, array( 144 | 'title' => 'required|max:255', 145 | 'slug' => 'required|alpha_dash|min:5|max:255|unique:posts,slug', 146 | 'category_id' => 'required|integer', 147 | 'body' => 'required' 148 | )); 149 | } 150 | 151 | // Save the data to the database 152 | $post = Post::find($id); 153 | 154 | $post->title = $request->input('title'); 155 | $post->slug = $request->input('slug'); 156 | $post->category_id = $request->input('category_id'); 157 | $post->body = Purifier::clean($request->input('body')); 158 | 159 | $post->save(); 160 | 161 | if (isset($request->tags)) { 162 | $post->tags()->sync($request->tags); 163 | } else { 164 | $post->tags()->sync(array()); 165 | } 166 | 167 | 168 | // set flash data with success message 169 | Session::flash('success', 'This post was successfully saved.'); 170 | 171 | // redirect with flash data to posts.show 172 | return redirect()->route('posts.show', $post->id); 173 | } 174 | 175 | /** 176 | * Remove the specified resource from storage. 177 | * 178 | * @param int $id 179 | * @return \Illuminate\Http\Response 180 | */ 181 | public function destroy($id) 182 | { 183 | $post = Post::find($id); 184 | $post->tags()->detach(); 185 | 186 | $post->tags()->detach(); 187 | 188 | $post->delete(); 189 | 190 | Session::flash('success', 'The post was successfully deleted.'); 191 | return redirect()->route('posts.index'); 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_ENV', 'production'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Debug Mode 21 | |-------------------------------------------------------------------------- 22 | | 23 | | When your application is in debug mode, detailed error messages with 24 | | stack traces will be shown on every error that occurs within your 25 | | application. If disabled, a simple generic error page is shown. 26 | | 27 | */ 28 | 29 | 'debug' => env('APP_DEBUG', false), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application URL 34 | |-------------------------------------------------------------------------- 35 | | 36 | | This URL is used by the console to properly generate URLs when using 37 | | the Artisan command line tool. You should set this to the root of 38 | | your application so that it is used when running Artisan tasks. 39 | | 40 | */ 41 | 42 | 'url' => 'http://localhost', 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application Timezone 47 | |-------------------------------------------------------------------------- 48 | | 49 | | Here you may specify the default timezone for your application, which 50 | | will be used by the PHP date and date-time functions. We have gone 51 | | ahead and set this to a sensible default for you out of the box. 52 | | 53 | */ 54 | 55 | 'timezone' => 'UTC', 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Locale Configuration 60 | |-------------------------------------------------------------------------- 61 | | 62 | | The application locale determines the default locale that will be used 63 | | by the translation service provider. You are free to set this value 64 | | to any of the locales which will be supported by the application. 65 | | 66 | */ 67 | 68 | 'locale' => 'en', 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Application Fallback Locale 73 | |-------------------------------------------------------------------------- 74 | | 75 | | The fallback locale determines the locale to use when the current one 76 | | is not available. You may change the value to correspond to any of 77 | | the language folders that are provided through your application. 78 | | 79 | */ 80 | 81 | 'fallback_locale' => 'en', 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Encryption Key 86 | |-------------------------------------------------------------------------- 87 | | 88 | | This key is used by the Illuminate encrypter service and should be set 89 | | to a random, 32 character string, otherwise these encrypted strings 90 | | will not be safe. Please do this before deploying an application! 91 | | 92 | */ 93 | 94 | 'key' => env('APP_KEY'), 95 | 96 | 'cipher' => 'AES-256-CBC', 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Logging Configuration 101 | |-------------------------------------------------------------------------- 102 | | 103 | | Here you may configure the log settings for your application. Out of 104 | | the box, Laravel uses the Monolog PHP logging library. This gives 105 | | you a variety of powerful log handlers / formatters to utilize. 106 | | 107 | | Available Settings: "single", "daily", "syslog", "errorlog" 108 | | 109 | */ 110 | 111 | 'log' => env('APP_LOG', 'single'), 112 | 113 | /* 114 | |-------------------------------------------------------------------------- 115 | | Autoloaded Service Providers 116 | |-------------------------------------------------------------------------- 117 | | 118 | | The service providers listed here will be automatically loaded on the 119 | | request to your application. Feel free to add your own services to 120 | | this array to grant expanded functionality to your applications. 121 | | 122 | */ 123 | 124 | 'providers' => [ 125 | 126 | /* 127 | * Laravel Framework Service Providers... 128 | */ 129 | Illuminate\Auth\AuthServiceProvider::class, 130 | Illuminate\Broadcasting\BroadcastServiceProvider::class, 131 | Illuminate\Bus\BusServiceProvider::class, 132 | Illuminate\Cache\CacheServiceProvider::class, 133 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, 134 | Illuminate\Cookie\CookieServiceProvider::class, 135 | Illuminate\Database\DatabaseServiceProvider::class, 136 | Illuminate\Encryption\EncryptionServiceProvider::class, 137 | Illuminate\Filesystem\FilesystemServiceProvider::class, 138 | Illuminate\Foundation\Providers\FoundationServiceProvider::class, 139 | Illuminate\Hashing\HashServiceProvider::class, 140 | Illuminate\Mail\MailServiceProvider::class, 141 | Illuminate\Pagination\PaginationServiceProvider::class, 142 | Illuminate\Pipeline\PipelineServiceProvider::class, 143 | Illuminate\Queue\QueueServiceProvider::class, 144 | Illuminate\Redis\RedisServiceProvider::class, 145 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, 146 | Illuminate\Session\SessionServiceProvider::class, 147 | Illuminate\Translation\TranslationServiceProvider::class, 148 | Illuminate\Validation\ValidationServiceProvider::class, 149 | Illuminate\View\ViewServiceProvider::class, 150 | Collective\Html\HtmlServiceProvider::class, 151 | Mews\Purifier\PurifierServiceProvider::class, 152 | 153 | /* 154 | * Application Service Providers... 155 | */ 156 | App\Providers\AppServiceProvider::class, 157 | App\Providers\AuthServiceProvider::class, 158 | App\Providers\EventServiceProvider::class, 159 | App\Providers\RouteServiceProvider::class, 160 | 161 | Intervention\Image\ImageServiceProvider::class, 162 | 163 | ], 164 | 165 | /* 166 | |-------------------------------------------------------------------------- 167 | | Class Aliases 168 | |-------------------------------------------------------------------------- 169 | | 170 | | This array of class aliases will be registered when this application 171 | | is started. However, feel free to register as many as you wish as 172 | | the aliases are "lazy" loaded so they don't hinder performance. 173 | | 174 | */ 175 | 176 | 'aliases' => [ 177 | 178 | 'App' => Illuminate\Support\Facades\App::class, 179 | 'Artisan' => Illuminate\Support\Facades\Artisan::class, 180 | 'Auth' => Illuminate\Support\Facades\Auth::class, 181 | 'Blade' => Illuminate\Support\Facades\Blade::class, 182 | 'Cache' => Illuminate\Support\Facades\Cache::class, 183 | 'Config' => Illuminate\Support\Facades\Config::class, 184 | 'Cookie' => Illuminate\Support\Facades\Cookie::class, 185 | 'Crypt' => Illuminate\Support\Facades\Crypt::class, 186 | 'DB' => Illuminate\Support\Facades\DB::class, 187 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 188 | 'Event' => Illuminate\Support\Facades\Event::class, 189 | 'File' => Illuminate\Support\Facades\File::class, 190 | 'Gate' => Illuminate\Support\Facades\Gate::class, 191 | 'Hash' => Illuminate\Support\Facades\Hash::class, 192 | 'Lang' => Illuminate\Support\Facades\Lang::class, 193 | 'Log' => Illuminate\Support\Facades\Log::class, 194 | 'Mail' => Illuminate\Support\Facades\Mail::class, 195 | 'Password' => Illuminate\Support\Facades\Password::class, 196 | 'Queue' => Illuminate\Support\Facades\Queue::class, 197 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, 198 | 'Redis' => Illuminate\Support\Facades\Redis::class, 199 | 'Request' => Illuminate\Support\Facades\Request::class, 200 | 'Response' => Illuminate\Support\Facades\Response::class, 201 | 'Route' => Illuminate\Support\Facades\Route::class, 202 | 'Schema' => Illuminate\Support\Facades\Schema::class, 203 | 'Session' => Illuminate\Support\Facades\Session::class, 204 | 'Storage' => Illuminate\Support\Facades\Storage::class, 205 | 'URL' => Illuminate\Support\Facades\URL::class, 206 | 'Validator' => Illuminate\Support\Facades\Validator::class, 207 | 'View' => Illuminate\Support\Facades\View::class, 208 | 'Form' => Collective\Html\FormFacade::class, 209 | 'Html' => Collective\Html\HtmlFacade::class, 210 | 'Purifier' => Mews\Purifier\Facades\Purifier::class, 211 | 'Image' => Intervention\Image\Facades\Image::class 212 | ], 213 | 214 | ]; 215 | -------------------------------------------------------------------------------- /public/css/select2.min.css: -------------------------------------------------------------------------------- 1 | .select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb} 2 | -------------------------------------------------------------------------------- /public/js/parsley.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Parsley.js 3 | * Version 2.3.2 - built Wed, Feb 10th 2016, 7:37 pm 4 | * http://parsleyjs.org 5 | * Guillaume Potier - 6 | * Marc-Andre Lafortune - 7 | * MIT Licensed 8 | */ 9 | function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,i=Array(e.length);t1)throw Error("Second argument not supported");if("object"!=typeof t)throw TypeError("Argument must be an object");e.prototype=t;var i=new e;return e.prototype=null,i}}()},a=s,o={namespace:"data-parsley-",inputs:"input, textarea, select",excluded:"input[type=button], input[type=submit], input[type=reset], input[type=hidden]",priorityEnabled:!0,multiple:null,group:null,uiEnabled:!0,validationThreshold:3,focus:"first",trigger:!1,triggerAfterFailure:"input",errorClass:"parsley-error",successClass:"parsley-success",classHandler:function(e){},errorsContainer:function(e){},errorsWrapper:'
    ',errorTemplate:"
  • "},l=function(){};l.prototype={asyncSupport:!0,actualizeOptions:function(){return a.attr(this.$element,this.options.namespace,this.domOptions),this.parent&&this.parent.actualizeOptions&&this.parent.actualizeOptions(),this},_resetOptions:function(e){this.domOptions=a.objectCreate(this.parent.options),this.options=a.objectCreate(this.domOptions);for(var t in e)e.hasOwnProperty(t)&&(this.options[t]=e[t]);this.actualizeOptions()},_listeners:null,on:function(e,t){this._listeners=this._listeners||{};var i=this._listeners[e]=this._listeners[e]||[];return i.push(t),this},subscribe:function(t,i){e.listenTo(this,t.toLowerCase(),i)},off:function(e,t){var i=this._listeners&&this._listeners[e];if(i)if(t)for(var n=i.length;n--;)i[n]===t&&i.splice(n,1);else delete this._listeners[e];return this},unsubscribe:function(t,i){e.unsubscribeTo(this,t.toLowerCase())},trigger:function(e,t,i){t=t||this;var n,r=this._listeners&&this._listeners[e];if(r)for(var s=r.length;s--;)if(n=r[s].call(t,t,i),n===!1)return n;return this.parent?this.parent.trigger(e,t,i):!0},reset:function(){if("ParsleyForm"!==this.__class__)return this._resetUI(),this._trigger("reset");for(var e=0;e3&&(i=[].slice.call(arguments,1,-1)),this.fn.call(this,t,i);if(e.isArray(t)){if(!this.validateMultiple)throw"Validator `"+this.name+"` does not handle multiple values";return this.validateMultiple.apply(this,arguments)}if(this.validateNumber)return isNaN(t)?!1:(arguments[0]=parseFloat(arguments[0]),this.validateNumber.apply(this,arguments));if(this.validateString)return this.validateString.apply(this,arguments);throw"Validator `"+this.name+"` only handles multiple values"},parseRequirements:function(t,i){if("string"!=typeof t)return e.isArray(t)?t:[t];var n=this.requirementType;if(e.isArray(n)){for(var r=d(t,n.length),s=0;s0},validateString:function(e){return/\S/.test(e)},priority:512},type:{validateString:function(e,t){var i=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],n=i.step,r=void 0===n?"1":n,s=i.base,a=void 0===s?0:s,o=m[t];if(!o)throw new Error("validator type `"+t+"` is not supported");if(!o.test(e))return!1;if("number"===t&&!/^any$/i.test(r||"")){var l=Number(e),u=Math.max(g(r),g(a));if(g(l)>u)return!1;var d=function(e){return Math.round(e*Math.pow(10,u))};if((d(l)-d(a))%d(r)!=0)return!1}return!0},requirementType:{"":"string",step:"string",base:"number"},priority:256},pattern:{validateString:function(e,t){return t.test(e)},requirementType:"regexp",priority:64},minlength:{validateString:function(e,t){return e.length>=t},requirementType:"integer",priority:30},maxlength:{validateString:function(e,t){return e.length<=t},requirementType:"integer",priority:30},length:{validateString:function(e,t,i){return e.length>=t&&e.length<=i},requirementType:["integer","integer"],priority:30},mincheck:{validateMultiple:function(e,t){return e.length>=t},requirementType:"integer",priority:30},maxcheck:{validateMultiple:function(e,t){return e.length<=t},requirementType:"integer",priority:30},check:{validateMultiple:function(e,t,i){return e.length>=t&&e.length<=i},requirementType:["integer","integer"],priority:30},min:{validateNumber:function(e,t){return e>=t},requirementType:"number",priority:30},max:{validateNumber:function(e,t){return t>=e},requirementType:"number",priority:30},range:{validateNumber:function(e,t,i){return e>=t&&i>=e},requirementType:["number","number"],priority:30},equalto:{validateString:function(t,i){var n=e(i);return n.length?t===n.val():t===i},priority:256}}};var y={},v=function T(e,t,i){for(var n=[],r=[],s=0;s0&&"undefined"==typeof t.options.noFocus&&(this._focusedField=t.$element,"first"===this.options.focus))break}return null===this._focusedField?null:this._focusedField.focus()},_destroyUI:function(){this.$element.off(".Parsley")}},y.Field={_reflowUI:function(){if(this._buildUI(),this._ui){var e=v(this.validationResult,this._ui.lastValidationResult);this._ui.lastValidationResult=this.validationResult,this._manageStatusClass(),this._manageErrorsMessages(e),this._actualizeTriggers(),!e.kept.length&&!e.added.length||this._failedOnce||(this._failedOnce=!0,this._actualizeTriggers())}},getErrorsMessages:function(){if(!0===this.validationResult)return[];for(var e=[],t=0;t0?this._errorClass():this._resetClass()},_manageErrorsMessages:function(t){if("undefined"==typeof this.options.errorsMessagesDisabled){if("undefined"!=typeof this.options.errorMessage)return t.added.length||t.kept.length?(this._insertErrorWrapper(),0===this._ui.$errorsWrapper.find(".parsley-custom-error-message").length&&this._ui.$errorsWrapper.append(e(this.options.errorTemplate).addClass("parsley-custom-error-message")),this._ui.$errorsWrapper.addClass("filled").find(".parsley-custom-error-message").html(this.options.errorMessage)):this._ui.$errorsWrapper.removeClass("filled").find(".parsley-custom-error-message").remove();for(var i=0;i').appendTo(this.$element)),i.attr({name:t.attr("name"),value:t.attr("value")})}this.$element.trigger(e.extend(e.Event("submit"),{parsley:!0}))}},validate:function(t){if(arguments.length>=1&&!e.isPlainObject(t)){a.warnOnce("Calling validate on a parsley form without passing arguments as an object is deprecated.");var i=_slice.call(arguments),n=i[0],r=i[1],s=i[2];t={group:n,force:r,event:s}}return w[this.whenValidate(t).state()]},whenValidate:function(){var t=this,i=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=i.group,r=i.force,s=i.event;this.submitEvent=s,s&&(this.submitEvent=e.extend({},s,{preventDefault:function(){a.warnOnce("Using `this.submitEvent.preventDefault()` is deprecated; instead, call `this.validationResult = false`"),t.validationResult=!1}})),this.validationResult=!0,this._trigger("validate"),this._refreshFields();var o=this._withoutReactualizingFormOptions(function(){return e.map(t.fields,function(e){return e.whenValidate({force:r,group:n})})}),l=function(){var i=e.Deferred();return!1===t.validationResult&&i.reject(),i.resolve().promise()};return e.when.apply(e,_toConsumableArray(o)).done(function(){t._trigger("success")}).fail(function(){t.validationResult=!1,t.focus(),t._trigger("error")}).always(function(){t._trigger("validated")}).pipe(l,l)},isValid:function(t){if(arguments.length>=1&&!e.isPlainObject(t)){a.warnOnce("Calling isValid on a parsley form without passing arguments as an object is deprecated.");var i=_slice.call(arguments),n=i[0],r=i[1];t={group:n,force:r}}return w[this.whenValid(t).state()]},whenValid:function(){var t=this,i=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=i.group,r=i.force;this._refreshFields();var s=this._withoutReactualizingFormOptions(function(){return e.map(t.fields,function(e){return e.whenValid({group:n,force:r})})});return e.when.apply(e,_toConsumableArray(s))},_refreshFields:function(){return this.actualizeOptions()._bindFields()},_bindFields:function(){var t=this,i=this.fields;return this.fields=[],this.fieldsMappedById={},this._withoutReactualizingFormOptions(function(){t.$element.find(t.options.inputs).not(t.options.excluded).each(function(e,i){var n=new window.Parsley.Factory(i,{},t);"ParsleyField"!==n.__class__&&"ParsleyFieldMultiple"!==n.__class__||!0===n.options.excluded||"undefined"==typeof t.fieldsMappedById[n.__class__+"-"+n.__id__]&&(t.fieldsMappedById[n.__class__+"-"+n.__id__]=n,t.fields.push(n))}),e(i).not(t.fields).each(function(e,t){t._trigger("reset")})}),this},_withoutReactualizingFormOptions:function(e){var t=this.actualizeOptions;this.actualizeOptions=function(){return this};var i=e();return this.actualizeOptions=t,i},_trigger:function(e){return this.trigger("form:"+e)}};var b=function(t,i,n,r,s){if(!/ParsleyField/.test(t.__class__))throw new Error("ParsleyField or ParsleyFieldMultiple instance expected");var a=window.Parsley._validatorRegistry.validators[i],o=new f(a);e.extend(this,{validator:o,name:i,requirements:n,priority:r||t.options[i+"Priority"]||o.priority,isDomConstraint:!0===s}),this._parseRequirements(t.options)},F=function(e){var t=e[0].toUpperCase();return t+e.slice(1)};b.prototype={validate:function(e,t){var i=this.requirementList.slice(0);return i.unshift(e),i.push(t),this.validator.validate.apply(this.validator,i)},_parseRequirements:function(e){var t=this;this.requirementList=this.validator.parseRequirements(this.requirements,function(i){return e[t.name+F(i)]})}};var C=function(t,i,n,r){this.__class__="ParsleyField",this.__id__=a.generateID(),this.$element=e(t),"undefined"!=typeof r&&(this.parent=r),this.options=n,this.domOptions=i,this.constraints=[],this.constraintsByName={},this.validationResult=[],this._bindConstraints()},$={pending:null,resolved:!0,rejected:!1};C.prototype={validate:function(t){arguments.length>=1&&!e.isPlainObject(t)&&(a.warnOnce("Calling validate on a parsley field without passing arguments as an object is deprecated."),t={options:t});var i=this.whenValidate(t);if(!i)return!0;switch(i.state()){case"pending":return null;case"resolved":return!0;case"rejected":return this.validationResult}},whenValidate:function(){var e=this,t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],i=t.force,n=t.group;return this.refreshConstraints(),!n||this._isInGroup(n)?(this.value=this.getValue(),this._trigger("validate"),this.whenValid({force:i,value:this.value,_refreshed:!0}).always(function(){e._reflowUI()}).done(function(){e._trigger("success")}).fail(function(){e._trigger("error")}).always(function(){e._trigger("validated")})):void 0},hasConstraints:function(){return 0!==this.constraints.length},needsValidation:function(e){return"undefined"==typeof e&&(e=this.getValue()),e.length||this._isRequired()||"undefined"!=typeof this.options.validateIfEmpty?!0:!1},_isInGroup:function(t){return e.isArray(this.options.group)?-1!==e.inArray(t,this.options.group):this.options.group===t},isValid:function(t){if(arguments.length>=1&&!e.isPlainObject(t)){a.warnOnce("Calling isValid on a parsley field without passing arguments as an object is deprecated.");var i=_slice.call(arguments),n=i[0],r=i[1];t={force:n,value:r}}var s=this.whenValid(t);return s?$[s.state()]:!0},whenValid:function(){var t=this,i=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=i.force,r=void 0===n?!1:n,s=i.value,a=i.group,o=i._refreshed;if(o||this.refreshConstraints(),!a||this._isInGroup(a)){if(this.validationResult=!0,!this.hasConstraints())return e.when();if(("undefined"==typeof s||null===s)&&(s=this.getValue()),!this.needsValidation(s)&&!0!==r)return e.when();var l=this._getGroupedConstraints(),u=[];return e.each(l,function(i,n){var r=e.when.apply(e,_toConsumableArray(e.map(n,function(e){return t._validateConstraint(s,e)})));return u.push(r),"rejected"===r.state()?!1:void 0}),e.when.apply(e,u)}},_validateConstraint:function(t,i){var n=this,r=i.validate(t,this);return!1===r&&(r=e.Deferred().reject()),e.when(r).fail(function(e){!0===n.validationResult&&(n.validationResult=[]),n.validationResult.push({assert:i,errorMessage:"string"==typeof e&&e})})},getValue:function(){var e;return e="function"==typeof this.options.value?this.options.value(this):"undefined"!=typeof this.options.value?this.options.value:this.$element.val(),"undefined"==typeof e||null===e?"":this._handleWhitespace(e)},refreshConstraints:function(){return this.actualizeOptions()._bindConstraints()},addConstraint:function(e,t,i,n){if(window.Parsley._validatorRegistry.validators[e]){var r=new b(this,e,t,i,n);"undefined"!==this.constraintsByName[r.name]&&this.removeConstraint(r.name),this.constraints.push(r),this.constraintsByName[r.name]=r}return this},removeConstraint:function(e){for(var t=0;t1){var i=[];return this.each(function(){i.push(e(this).parsley(t))}),i}return e(this).length?new E(this,t):void a.warn("You must bind Parsley on an existing element.")},"undefined"==typeof window.ParsleyExtend&&(window.ParsleyExtend={}),M.options=e.extend(a.objectCreate(o),window.ParsleyConfig),window.ParsleyConfig=M.options,window.Parsley=window.psly=M,window.ParsleyUtils=a;var O=window.Parsley._validatorRegistry=new c(window.ParsleyConfig.validators,window.ParsleyConfig.i18n);window.ParsleyValidator={},e.each("setLocale addCatalog addMessage addMessages getErrorMessage formatMessage addValidator updateValidator removeValidator".split(" "),function(t,i){window.Parsley[i]=e.proxy(O,i),window.ParsleyValidator[i]=function(){var e;return a.warnOnce("Accessing the method '"+i+"' through ParsleyValidator is deprecated. Simply call 'window.Parsley."+i+"(...)'"),(e=window.Parsley)[i].apply(e,arguments)}}),window.Parsley.UI=y,window.ParsleyUI={removeError:function(e,t,i){var n=!0!==i;return a.warnOnce("Accessing ParsleyUI is deprecated. Call 'removeError' on the instance directly."),e.removeError(t,{updateClass:n})},getErrorsMessages:function(e){return a.warnOnce("Accessing ParsleyUI is deprecated. Call 'getErrorsMessages' on the instance directly."),e.getErrorsMessages()}},e.each("addError updateError".split(" "),function(e,t){window.ParsleyUI[t]=function(e,i,n,r,s){var o=!0!==s;return a.warnOnce("Accessing ParsleyUI is deprecated. Call '"+t+"' on the instance directly."),e[t](i,{message:n,assert:r,updateClass:o})}}),!1!==window.ParsleyConfig.autoBind&&e(function(){e("[data-parsley-validate]").length&&e("[data-parsley-validate]").parsley()});var A=e({}),R=function(){a.warnOnce("Parsley's pubsub module is deprecated; use the 'on' and 'off' methods on parsley instances or window.Parsley")},D="parsley:";e.listen=function(e,n){var r;if(R(),"object"==typeof arguments[1]&&"function"==typeof arguments[2]&&(r=arguments[1],n=arguments[2]),"function"!=typeof n)throw new Error("Wrong parameters");window.Parsley.on(i(e),t(n,r))},e.listenTo=function(e,n,r){if(R(),!(e instanceof x||e instanceof _))throw new Error("Must give Parsley instance");if("string"!=typeof n||"function"!=typeof r)throw new Error("Wrong parameters");e.on(i(n),t(r))},e.unsubscribe=function(e,t){if(R(),"string"!=typeof e||"function"!=typeof t)throw new Error("Wrong arguments");window.Parsley.off(i(e),t.parsleyAdaptedCallback)},e.unsubscribeTo=function(e,t){if(R(),!(e instanceof x||e instanceof _))throw new Error("Must give Parsley instance");e.off(i(t))},e.unsubscribeAll=function(t){R(),window.Parsley.off(i(t)),e("form,input,textarea,select").each(function(){var n=e(this).data("Parsley");n&&n.off(i(t))})},e.emit=function(e,t){var n;R();var r=t instanceof x||t instanceof _,s=Array.prototype.slice.call(arguments,r?2:1);s.unshift(i(e)),r||(t=window.Parsley),(n=t).trigger.apply(n,_toConsumableArray(s))};e.extend(!0,M,{asyncValidators:{"default":{fn:function(e){return e.status>=200&&e.status<300},url:!1},reverse:{fn:function(e){return e.status<200||e.status>=300},url:!1}},addAsyncValidator:function(e,t,i,n){return M.asyncValidators[e]={fn:t,url:i||!1,options:n||{}},this}}),M.addValidator("remote",{requirementType:{"":"string",validator:"string",reverse:"boolean",options:"object"},validateString:function(t,i,n,r){var s,a,o={},l=n.validator||(!0===n.reverse?"reverse":"default");if("undefined"==typeof M.asyncValidators[l])throw new Error("Calling an undefined async validator: `"+l+"`");i=M.asyncValidators[l].url||i,i.indexOf("{value}")>-1?i=i.replace("{value}",encodeURIComponent(t)):o[r.$element.attr("name")||r.$element.attr("id")]=t;var u=e.extend(!0,n.options||{},M.asyncValidators[l].options);s=e.extend(!0,{},{url:i,data:o,type:"GET"},u),r.trigger("field:ajaxoptions",r,s),a=e.param(s),"undefined"==typeof M._remoteCache&&(M._remoteCache={});var d=M._remoteCache[a]=M._remoteCache[a]||e.ajax(s),h=function(){var t=M.asyncValidators[l].fn.call(r,d,i,n);return t||(t=e.Deferred().reject()),e.when(t)};return d.then(h,h)},priority:-1}),M.on("form:submit",function(){M._remoteCache={}}),window.ParsleyExtend.addAsyncValidator=function(){return ParsleyUtils.warnOnce("Accessing the method `addAsyncValidator` through an instance is deprecated. Simply call `Parsley.addAsyncValidator(...)`"),M.addAsyncValidator.apply(M,arguments)},M.addMessages("en",{defaultMessage:"This value seems to be invalid.",type:{email:"This value should be a valid email.",url:"This value should be a valid url.",number:"This value should be a valid number.",integer:"This value should be a valid integer.",digits:"This value should be digits.",alphanum:"This value should be alphanumeric."},notblank:"This value should not be blank.",required:"This value is required.",pattern:"This value seems to be invalid.",min:"This value should be greater than or equal to %s.",max:"This value should be lower than or equal to %s.",range:"This value should be between %s and %s.",minlength:"This value is too short. It should have %s characters or more.",maxlength:"This value is too long. It should have %s characters or fewer.",length:"This value length is invalid. It should be between %s and %s characters long.",mincheck:"You must select at least %s choices.",maxcheck:"You must select %s choices or fewer.",check:"You must select between %s and %s choices.",equalto:"This value should be the same."}),M.setLocale("en");var q=M;return q}); 11 | //# sourceMappingURL=parsley.min.js.map 12 | --------------------------------------------------------------------------------