├── .editorconfig ├── .env.example ├── .gitattributes ├── .gitignore ├── .styleci.yml ├── app ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php ├── Filters │ └── PostsFilter.php ├── Http │ ├── Controllers │ │ ├── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── RegisterController.php │ │ │ ├── ResetPasswordController.php │ │ │ └── VerificationController.php │ │ ├── AuthController.php │ │ ├── CategoriesController.php │ │ ├── CommentsController.php │ │ ├── Controller.php │ │ ├── DashboardController.php │ │ ├── HomeController.php │ │ ├── PostsController.php │ │ └── TagsController.php │ ├── Kernel.php │ ├── Middleware │ │ ├── Authenticate.php │ │ ├── CheckForMaintenanceMode.php │ │ ├── EncryptCookies.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustProxies.php │ │ └── VerifyCsrfToken.php │ ├── Requests │ │ └── PostRequest.php │ └── Resources │ │ ├── CategoryResource.php │ │ ├── CommentRessource.php │ │ ├── PostCollection.php │ │ ├── PostResource.php │ │ └── TagResource.php ├── Models │ ├── Category.php │ ├── Comment.php │ ├── Post.php │ └── Tag.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php └── User.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── database.php ├── filesystems.php ├── hashing.php ├── jwt.php ├── logging.php ├── mail.php ├── queue.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ ├── CategoryFactory.php │ ├── CommentFactory.php │ ├── PostFactory.php │ ├── TagFactory.php │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2019_06_05_201200_create_categories_table.php │ ├── 2019_06_05_201221_create_posts_table.php │ ├── 2019_06_15_065429_create_comments_table.php │ └── 2019_07_06_093648_create_tags_table.php └── seeds │ ├── DatabaseSeeder.php │ ├── PostsTableSeeder.php │ └── UsersTableSeeder.php ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── cover.jpg ├── css │ └── app.css ├── favicon.ico ├── fonts │ └── vendor │ │ └── @fortawesome │ │ └── fontawesome-free │ │ ├── webfa-brands-400.eot │ │ ├── webfa-brands-400.svg │ │ ├── webfa-brands-400.ttf │ │ ├── webfa-brands-400.woff │ │ ├── webfa-brands-400.woff2 │ │ ├── webfa-regular-400.eot │ │ ├── webfa-regular-400.svg │ │ ├── webfa-regular-400.ttf │ │ ├── webfa-regular-400.woff │ │ ├── webfa-regular-400.woff2 │ │ ├── webfa-solid-900.eot │ │ ├── webfa-solid-900.svg │ │ ├── webfa-solid-900.ttf │ │ ├── webfa-solid-900.woff │ │ └── webfa-solid-900.woff2 ├── index.php ├── js │ └── app.js ├── mix-manifest.json ├── robots.txt └── web.config ├── readme.md ├── resources ├── js │ ├── App.vue │ ├── Pages │ │ ├── Admin │ │ │ ├── Categories │ │ │ │ ├── CategoriesCreate.vue │ │ │ │ ├── CategoriesEdit.vue │ │ │ │ └── CategoriesIndex.vue │ │ │ ├── Comments │ │ │ │ └── CommentsIndex.vue │ │ │ ├── Dashboard.vue │ │ │ ├── Login.vue │ │ │ ├── Posts │ │ │ │ ├── PostsCreate.vue │ │ │ │ ├── PostsEdit.vue │ │ │ │ └── PostsIndex.vue │ │ │ └── Tags │ │ │ │ ├── TagsEdit.vue │ │ │ │ └── TagsIndex.vue │ │ ├── Blog │ │ │ ├── CategoryIndex.vue │ │ │ ├── PostShow.vue │ │ │ ├── PostsIndex.vue │ │ │ └── TagIndex.vue │ │ ├── Layouts │ │ │ ├── AdminLayout.vue │ │ │ ├── AdminPartials │ │ │ │ ├── Breadcrumb.vue │ │ │ │ ├── Navbar.vue │ │ │ │ └── Sidebar.vue │ │ │ ├── BlogLayout.vue │ │ │ ├── BlogPartials │ │ │ │ ├── Aside.vue │ │ │ │ ├── Footer.vue │ │ │ │ └── Navbar.vue │ │ │ └── LoginLayout.vue │ │ └── NotFound.vue │ ├── Utilities │ │ ├── Auth.js │ │ ├── Errors.js │ │ ├── Flash.vue │ │ ├── InputTag.vue │ │ └── Storage.js │ ├── app.js │ ├── bootstrap.js │ ├── components │ │ ├── Categories.vue │ │ ├── Comments.vue │ │ ├── Comments │ │ │ ├── Comment.vue │ │ │ ├── CommentForm.vue │ │ │ └── CommentModal.vue │ │ ├── CoverUploader.vue │ │ ├── Pagination.vue │ │ ├── Post.vue │ │ ├── PostSearch.vue │ │ ├── Tag.vue │ │ └── admin │ │ │ └── Posts.vue │ ├── lib │ │ └── datatable │ │ │ ├── datatable-bs4.min.css │ │ │ ├── datatable-bs4.min.js │ │ │ └── datatable.js │ ├── mixins │ │ ├── AddToken.js │ │ ├── AuthMiddleware.js │ │ ├── RedirectIfAuthenticated.js │ │ └── authenticated.js │ ├── routes │ │ ├── admin.js │ │ ├── public.js │ │ └── routes.js │ └── store │ │ ├── modules │ │ ├── auth.js │ │ └── categories.js │ │ └── store.js ├── lang │ └── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php ├── sass │ ├── _blog.scss │ ├── _custom-bootstrap.scss │ ├── _login.scss │ ├── _variables.scss │ └── app.scss └── views │ └── layouts │ └── app.blade.php ├── routes ├── api.php ├── channels.php ├── console.php └── web.php ├── server.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ ├── .gitignore │ │ └── data │ │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── tests ├── CreatesApplication.php ├── Feature │ ├── AuthTest.php │ ├── CreateCategoriesTest.php │ ├── CreateCommentsTest.php │ ├── CreatePostsTest.php │ ├── ManageTagsTest.php │ ├── ViewCategoriesTest.php │ └── ViewPostsTest.php ├── TestCase.php ├── Unit │ ├── CategoryTest.php │ ├── CommentTest.php │ ├── PostTest.php │ └── TagTest.php └── Utils │ └── helpers.php ├── webpack.mix.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.yml] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=homestead 13 | DB_USERNAME=homestead 14 | DB_PASSWORD=secret 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=file 20 | SESSION_LIFETIME=120 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_DRIVER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | 33 | AWS_ACCESS_KEY_ID= 34 | AWS_SECRET_ACCESS_KEY= 35 | AWS_DEFAULT_REGION=us-east-1 36 | AWS_BUCKET= 37 | 38 | PUSHER_APP_ID= 39 | PUSHER_APP_KEY= 40 | PUSHER_APP_SECRET= 41 | PUSHER_APP_CLUSTER=mt1 42 | 43 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 44 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 45 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | .env 7 | .phpunit.result.cache 8 | Homestead.json 9 | Homestead.yaml 10 | npm-debug.log 11 | yarn-error.log 12 | /.idea -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | php: 2 | preset: laravel 3 | disabled: 4 | - unused_use 5 | finder: 6 | not-name: 7 | - index.php 8 | - server.php 9 | js: 10 | finder: 11 | not-name: 12 | - webpack.mix.js 13 | css: true 14 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | 31 | /** 32 | * Register the commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | $this->load(__DIR__.'/Commands'); 39 | 40 | require base_path('routes/console.php'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | filters = collect($this->filters); 16 | } 17 | 18 | /** 19 | * @param $request 20 | * @param $builder 21 | * @return mixed 22 | */ 23 | public function apply ($request, $builder) 24 | { 25 | $this->builder = $builder; 26 | $this->request = collect($request); 27 | 28 | foreach ($this->request as $filterKey => $value) { 29 | if($this->filters->contains($filterKey) && method_exists($this, $filterKey)) { 30 | $this->builder = $this->$filterKey($value); 31 | } 32 | } 33 | 34 | return $this->builder; 35 | } 36 | 37 | /** 38 | * @param $value 39 | * @return mixed 40 | */ 41 | protected function search($value) 42 | { 43 | return $this->builder->search($value)->take(5); 44 | } 45 | 46 | /** 47 | * @return mixed 48 | */ 49 | protected function popular() 50 | { 51 | $this->builder->getQuery()->orders = null; 52 | 53 | return $this->builder->orderBy("visits", "DESC"); 54 | } 55 | 56 | 57 | } -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 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', 'string', 'max:255'], 53 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 54 | 'password' => ['required', 'string', 'min:8', 'confirmed'], 55 | ]); 56 | } 57 | 58 | /** 59 | * Create a new user instance after a valid registration. 60 | * 61 | * @param array $data 62 | * @return \App\User 63 | */ 64 | protected function create(array $data) 65 | { 66 | return User::create([ 67 | 'name' => $data['name'], 68 | 'email' => $data['email'], 69 | 'password' => Hash::make($data['password']), 70 | ]); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/VerificationController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 38 | $this->middleware('signed')->only('verify'); 39 | $this->middleware('throttle:6,1')->only('verify', 'resend'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/Http/Controllers/AuthController.php: -------------------------------------------------------------------------------- 1 | middleware('auth:api', ['except' => ['login']]); 17 | } 18 | 19 | /** 20 | * Get a JWT via given credentials. 21 | * 22 | * @return \Illuminate\Http\JsonResponse 23 | */ 24 | public function login() 25 | { 26 | $credentials = request()->validate([ 27 | "email" => "required|email", 28 | "password" => "required" 29 | ]); 30 | 31 | 32 | if (! $token = auth()->attempt($credentials)) { 33 | return response()->json(['errors' => ["email" => ["Credentials are not valid"] ]], 401); 34 | } 35 | 36 | return $this->respondWithToken($token); 37 | } 38 | 39 | /** 40 | * Get the authenticated User. 41 | * 42 | * @return \Illuminate\Http\JsonResponse 43 | */ 44 | public function me() 45 | { 46 | return response()->json(auth()->user()); 47 | } 48 | 49 | /** 50 | * Log the user out (Invalidate the token). 51 | * 52 | * @return \Illuminate\Http\JsonResponse 53 | */ 54 | public function logout() 55 | { 56 | auth()->logout(); 57 | 58 | return response()->json(['message' => 'Successfully logged out']); 59 | } 60 | 61 | /** 62 | * Refresh a token. 63 | * 64 | * @return \Illuminate\Http\JsonResponse 65 | */ 66 | public function refresh() 67 | { 68 | return $this->respondWithToken(auth()->refresh()); 69 | } 70 | 71 | /** 72 | * Get the token array structure. 73 | * 74 | * @param string $token 75 | * 76 | * @return \Illuminate\Http\JsonResponse 77 | */ 78 | protected function respondWithToken($token) 79 | { 80 | return response()->json([ 81 | 'access_token' => $token, 82 | 'token_type' => 'bearer', 83 | 'expires_in' => auth()->factory()->getTTL() * 60 84 | ]); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/Http/Controllers/CategoriesController.php: -------------------------------------------------------------------------------- 1 | middleware("api")->only(["store", "update", "destroy"]); 16 | } 17 | 18 | /** 19 | * Give a collection of categories 20 | * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection 21 | */ 22 | public function index() 23 | { 24 | $categories = Category::all(); 25 | 26 | return CategoryResource::collection($categories); 27 | } 28 | 29 | /** 30 | * @param Request $request 31 | * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection 32 | * 33 | */ 34 | public function store(Request $request) 35 | { 36 | $request->validate([ "names" => "required" ]); 37 | 38 | $categoriesNames = explode(",", $request->get("names")); 39 | 40 | $categoriesSaved = Category::register($categoriesNames); 41 | 42 | return CategoryResource::collection($categoriesSaved); 43 | } 44 | 45 | /** 46 | * @param Category $category 47 | * @return CategoryResource 48 | */ 49 | public function show(Category $category) 50 | { 51 | return new CategoryResource($category); 52 | } 53 | 54 | /** 55 | * @param Request $request 56 | * @param Category $category 57 | * @return CategoryResource 58 | */ 59 | public function update(Request $request, Category $category) 60 | { 61 | $request->validate([ "name" => "required|max:255"]); 62 | 63 | if($request->name !== $category->name) { 64 | $request->validate(["name" => "unique:categories"]); 65 | } 66 | 67 | $category->update([ 68 | "name" => $request->name, 69 | "slug" => Str::slug($request->name) 70 | ]); 71 | 72 | return new CategoryResource($category); 73 | } 74 | 75 | /** 76 | * @param Category $category 77 | * @return \Illuminate\Http\JsonResponse 78 | * @throws \Exception 79 | */ 80 | public function destroy(Category $category) 81 | { 82 | $category->delete(); 83 | 84 | return response()->json([], 204); 85 | } 86 | 87 | 88 | public function getPosts(Category $category) 89 | { 90 | $posts = $category->posts()->latest()->paginate(7); 91 | 92 | return new PostCollection($posts); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /app/Http/Controllers/CommentsController.php: -------------------------------------------------------------------------------- 1 | middleware("api")->only(["index"]); 17 | } 18 | 19 | /** 20 | * See all the comments resource 21 | * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection 22 | */ 23 | public function index() 24 | { 25 | $comments = Comment::latest()->get(); 26 | 27 | return response()->json(["data" => $comments]); 28 | } 29 | 30 | /** 31 | * Show a comment resource 32 | * @param Comment $comment 33 | * @return \Illuminate\Http\JsonResponse 34 | */ 35 | public function show(Comment $comment) 36 | { 37 | return response()->json(["data" => $comment], 200); 38 | } 39 | 40 | /** 41 | * @param Category $category 42 | * @param Post $post 43 | * @return CommentRessource 44 | */ 45 | public function store(Category $category, Post $post) 46 | { 47 | $data = request()->validate([ 48 | "author_name" => "required|min:1", 49 | "author_email" => "required|email", 50 | "content" => "required|min:2" 51 | ]); 52 | 53 | $comment = $post->comments()->create($data); 54 | 55 | return new CommentRessource($comment); 56 | } 57 | 58 | 59 | /** 60 | * Delete a comment resource 61 | * @param Comment $comment 62 | * @return \Illuminate\Http\JsonResponse 63 | * @throws \Exception 64 | */ 65 | public function destroy(Comment $comment) 66 | { 67 | $comment->delete(); 68 | 69 | return response()->json([], 200); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | orderBy('visits', 'DESC')->take(5)->get(); 19 | $latestComments = Comment::with('post')->take(5)->get(); 20 | 21 | return response()->json([ 22 | 'data' => compact('postsCount', 'commentsCount', 'viewsCount', 'popularPosts', 'latestComments') 23 | ]); 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Controllers/HomeController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 17 | } 18 | 19 | /** 20 | * Show the application dashboard. 21 | * 22 | * @return \Illuminate\Contracts\Support\Renderable 23 | */ 24 | public function index() 25 | { 26 | return view('home'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Controllers/TagsController.php: -------------------------------------------------------------------------------- 1 | middleware('api')->only(["update", "destroy"]); 16 | } 17 | 18 | /** 19 | * Display a listing of the resource. 20 | * 21 | * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection 22 | */ 23 | public function index() 24 | { 25 | return TagResource::collection( 26 | Tag::withCount("posts")->get() 27 | ); 28 | } 29 | 30 | 31 | /** 32 | * Display the tag resource. 33 | * 34 | * @param Tag $tag 35 | * @return TagResource 36 | */ 37 | public function show(Tag $tag) 38 | { 39 | return new TagResource($tag); 40 | } 41 | 42 | /** 43 | * Update the tag resource. 44 | * 45 | * @param \Illuminate\Http\Request $request 46 | * @param Tag $tag 47 | * @return TagResource 48 | */ 49 | public function update(Request $request, Tag $tag) 50 | { 51 | $request->validate(["name" => "required"]); 52 | if($request->name !== $tag->name) { 53 | $request->validate(["name" => "unique:tags"]); 54 | } 55 | 56 | $tag->update([ 57 | "name" => $request->name, 58 | "title" => Str::slug($request->name) 59 | ]); 60 | 61 | return new TagResource($tag); 62 | } 63 | 64 | /** 65 | * Remove a tag resource. 66 | * 67 | * @param Tag $tag 68 | * @return \Illuminate\Http\JsonResponse 69 | * @throws \Exception 70 | */ 71 | public function destroy(Tag $tag) 72 | { 73 | $tag->delete(); 74 | 75 | return response()->json([], 204); 76 | } 77 | 78 | 79 | /** 80 | * @param Tag $tag 81 | * @return PostCollection 82 | */ 83 | public function getPosts(Tag $tag) 84 | { 85 | $posts = $tag->posts()->online()->paginate(10); 86 | 87 | return new PostCollection($posts); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | [ 31 | \App\Http\Middleware\EncryptCookies::class, 32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 33 | \Illuminate\Session\Middleware\StartSession::class, 34 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 36 | \App\Http\Middleware\VerifyCsrfToken::class, 37 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 38 | ], 39 | 40 | 'api' => [ 41 | 'throttle:60,1', 42 | 'bindings', 43 | ], 44 | ]; 45 | 46 | /** 47 | * The application's route middleware. 48 | * 49 | * These middleware may be assigned to groups or used individually. 50 | * 51 | * @var array 52 | */ 53 | protected $routeMiddleware = [ 54 | 'auth' => \App\Http\Middleware\Authenticate::class, 55 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 56 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 57 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 58 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 59 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 60 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 61 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 62 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 63 | ]; 64 | 65 | /** 66 | * The priority-sorted list of middleware. 67 | * 68 | * This forces non-global middleware to always be in the given order. 69 | * 70 | * @var array 71 | */ 72 | protected $middlewarePriority = [ 73 | \Illuminate\Session\Middleware\StartSession::class, 74 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 75 | \App\Http\Middleware\Authenticate::class, 76 | \Illuminate\Session\Middleware\AuthenticateSession::class, 77 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 78 | \Illuminate\Auth\Middleware\Authorize::class, 79 | ]; 80 | } 81 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/CheckForMaintenanceMode.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/home'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | reformatData(); 28 | 29 | $rules = [ 30 | "title" => "required|max:200", 31 | "content" => "required", 32 | "category_id" => "required|exists:categories,id", 33 | "cover" => ["nullable"], 34 | "tags" => "required" 35 | ]; 36 | 37 | if($this->method() == "POST") { 38 | $rules["cover"][0] = ["required", "image"]; 39 | } 40 | 41 | if($this->method() === "PUT" && $this->cover !== null) { 42 | $rules["cover"][] = "image"; 43 | } 44 | 45 | return $rules; 46 | } 47 | 48 | public function data() 49 | { 50 | return $this->merge([ 51 | "slug" => Str::slug($this->get("title")), 52 | "user_id" => auth()->id(), 53 | "online" => $this->get("online") === "true" 54 | ])->only(["title", "slug", "content", "user_id", "category_id", "online"]); 55 | } 56 | 57 | /** 58 | * Reformat data format send through ajax t 59 | * 60 | */ 61 | private function reformatData(): void 62 | { 63 | if($this->cover === "null") { 64 | $this->merge([ "cover"=> null ]); 65 | } 66 | } 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /app/Http/Resources/CategoryResource.php: -------------------------------------------------------------------------------- 1 | $this->id, 19 | "name" => $this->name, 20 | "slug" => $this->slug, 21 | "posts_count" => $this->posts()->count() 22 | ]; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/Http/Resources/CommentRessource.php: -------------------------------------------------------------------------------- 1 | $this->id, 19 | "author_name" => $this->author_name, 20 | "content" => $this->content, 21 | "created_at" => $this->created_at->diffForHumans(), 22 | "description" => $this->description 23 | ]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/Http/Resources/PostCollection.php: -------------------------------------------------------------------------------- 1 | $this->collection 20 | ]; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Http/Resources/PostResource.php: -------------------------------------------------------------------------------- 1 | $this->id, 19 | "title" => $this->title, 20 | "slug" => $this->slug, 21 | "description" => $this->description, 22 | "content" => $this->content, 23 | "created_at" => $this->created_at->diffForHumans(), 24 | "category" => new CategoryResource($this->category), 25 | "online" => !! $this->online, 26 | "creator" => $this->creator, 27 | "cover_path" => $this->cover_path, 28 | "visits_count" => $this->visits, 29 | "comments" => CommentRessource::collection($this->whenLoaded("comments")), 30 | "tags" => TagResource::collection($this->tags()->get()) 31 | ]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Http/Resources/TagResource.php: -------------------------------------------------------------------------------- 1 | $this->id, 19 | "name" => $this->name, 20 | "slug" => $this->slug, 21 | "posts_count" => $this->posts_count 22 | ]; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/Models/Category.php: -------------------------------------------------------------------------------- 1 | hasMany(Post::class); 21 | } 22 | 23 | public static function register(array $names) : Collection 24 | { 25 | $categoriesSaved = collect([]); 26 | 27 | $names = array_unique($names); 28 | $categoriesNames = static::getCategoriesToRegister($names); 29 | 30 | foreach ($categoriesNames as $name) { 31 | $categoriesSaved[] = static::create([ 32 | "name" => $name, 33 | "slug" => Str::slug($name) 34 | ]); 35 | } 36 | 37 | return $categoriesSaved; 38 | } 39 | 40 | public static function getCategoriesToRegister(array $names) : array 41 | { 42 | $existingCategoriesNames = static::whereIn("name", $names)->pluck("name"); 43 | 44 | return array_filter($names, function ($name) use ($existingCategoriesNames) { 45 | return ! $existingCategoriesNames->contains($name); 46 | }); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/Models/Comment.php: -------------------------------------------------------------------------------- 1 | attributes["content"], 0, 30) . "..."; 20 | } 21 | 22 | public function post() 23 | { 24 | return $this->belongsTo(Post::class); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Models/Post.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class, "user_id"); 24 | } 25 | 26 | /** 27 | * Relationship between a post with a category 28 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo 29 | */ 30 | public function category() 31 | { 32 | return $this->belongsTo(Category::class); 33 | } 34 | 35 | /** 36 | * Relationship post with tags 37 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany 38 | */ 39 | public function tags() 40 | { 41 | return $this->belongsToMany(Tag::class); 42 | } 43 | 44 | /** 45 | * Relationship between a post with comments 46 | * @return \Illuminate\Database\Eloquent\Relations\HasMany 47 | */ 48 | public function comments() 49 | { 50 | return $this->hasMany(Comment::class)->latest(); 51 | } 52 | 53 | public function getDescriptionAttribute() 54 | { 55 | return substr($this->content, 0, 70) . "..."; 56 | } 57 | 58 | public function scopeSearch($query, $value) 59 | { 60 | return $query->where("title", "LIKE", "%$value%"); 61 | } 62 | 63 | public function getCoverAttribute() 64 | { 65 | $parts = explode("/", $this->cover_path); 66 | 67 | return end($parts); 68 | } 69 | 70 | public function scopeOnline($query, $condition = true) 71 | { 72 | return $query->where(["online" => $condition]); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /app/Models/Tag.php: -------------------------------------------------------------------------------- 1 | belongsToMany(Post::class); 25 | } 26 | 27 | /** 28 | * Add tags 29 | * @param array $tagNames 30 | * @return Collection 31 | */ 32 | public static function add(array $tagNames) : Collection 33 | { 34 | $tagNames = array_unique($tagNames); 35 | 36 | $tagToInsert = static::getTagToInsert($tagNames); 37 | 38 | static::addMany($tagToInsert); 39 | 40 | return static::whereIn("name", $tagNames)->pluck("id"); 41 | } 42 | 43 | /** 44 | * Filter existing tags to add tags that have not been created yet 45 | * @param array $tagNames 46 | * @return array 47 | */ 48 | private static function getTagToInsert(array $tagNames) 49 | { 50 | $existingTags = static::whereIn("name", $tagNames)->pluck("name"); 51 | 52 | return array_filter($tagNames, function ($name) use ($existingTags) { 53 | return ! $existingTags->contains($name) && $name !== ""; 54 | }); 55 | } 56 | 57 | /** 58 | * Add many tags at once 59 | * @param array $tags 60 | */ 61 | private static function addMany(array $tags) : void 62 | { 63 | $tagsToInsert = array_map(function($name) { 64 | return [ 65 | "name" => $name, 66 | "slug" => Str::slug($name) 67 | ]; 68 | }, $tags); 69 | 70 | static::insert($tagsToInsert); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | parent::boot(); 31 | 32 | // 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 39 | 40 | $this->mapWebRoutes(); 41 | 42 | // 43 | } 44 | 45 | /** 46 | * Define the "web" routes for the application. 47 | * 48 | * These routes all receive session state, CSRF protection, etc. 49 | * 50 | * @return void 51 | */ 52 | protected function mapWebRoutes() 53 | { 54 | Route::middleware('web') 55 | ->namespace($this->namespace) 56 | ->group(base_path('routes/web.php')); 57 | } 58 | 59 | /** 60 | * Define the "api" routes for the application. 61 | * 62 | * These routes are typically stateless. 63 | * 64 | * @return void 65 | */ 66 | protected function mapApiRoutes() 67 | { 68 | Route::prefix('api') 69 | ->middleware('api') 70 | ->namespace($this->namespace) 71 | ->group(base_path('routes/api.php')); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/User.php: -------------------------------------------------------------------------------- 1 | 'datetime', 39 | ]; 40 | 41 | /** 42 | * Get the identifier that will be stored in the subject claim of the JWT. 43 | * 44 | * @return mixed 45 | */ 46 | public function getJWTIdentifier() 47 | { 48 | return $this->getKey(); 49 | } 50 | 51 | /** 52 | * Return a key value array, containing any custom claims to be added to the JWT. 53 | * 54 | * @return array 55 | */ 56 | public function getJWTCustomClaims() 57 | { 58 | return []; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The Laravel Framework.", 5 | "keywords": [ 6 | "framework", 7 | "laravel" 8 | ], 9 | "license": "MIT", 10 | "require": { 11 | "php": "^7.1.3", 12 | "fideloper/proxy": "^4.0", 13 | "laravel/framework": "5.8.*", 14 | "laravel/tinker": "^1.0", 15 | "tymon/jwt-auth": "~1.0.0-rc.2" 16 | }, 17 | "require-dev": { 18 | "beyondcode/laravel-dump-server": "^1.0", 19 | "filp/whoops": "^2.0", 20 | "fzaninotto/faker": "^1.4", 21 | "mockery/mockery": "^1.0", 22 | "nunomaduro/collision": "^3.0", 23 | "phpunit/phpunit": "^7.5" 24 | }, 25 | "config": { 26 | "optimize-autoloader": true, 27 | "preferred-install": "dist", 28 | "sort-packages": true 29 | }, 30 | "extra": { 31 | "laravel": { 32 | "dont-discover": [] 33 | } 34 | }, 35 | "autoload": { 36 | "psr-4": { 37 | "App\\": "app/" 38 | }, 39 | "classmap": [ 40 | "database/seeds", 41 | "database/factories" 42 | ] 43 | }, 44 | "autoload-dev": { 45 | "psr-4": { 46 | "Tests\\": "tests/" 47 | }, 48 | "files": ["tests/Utils/helpers.php"] 49 | }, 50 | "minimum-stability": "dev", 51 | "prefer-stable": true, 52 | "scripts": { 53 | "post-autoload-dump": [ 54 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 55 | "@php artisan package:discover --ansi" 56 | ], 57 | "post-root-package-install": [ 58 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 59 | ], 60 | "post-create-project-cmd": [ 61 | "@php artisan key:generate --ansi" 62 | ] 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'encrypted' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Cache Stores 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may define all of the cache "stores" for your application as 29 | | well as their drivers. You may even define multiple stores for the 30 | | same cache driver to group types of items stored in your caches. 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'apc' => [ 37 | 'driver' => 'apc', 38 | ], 39 | 40 | 'array' => [ 41 | 'driver' => 'array', 42 | ], 43 | 44 | 'database' => [ 45 | 'driver' => 'database', 46 | 'table' => 'cache', 47 | 'connection' => null, 48 | ], 49 | 50 | 'file' => [ 51 | 'driver' => 'file', 52 | 'path' => storage_path('framework/cache/data'), 53 | ], 54 | 55 | 'memcached' => [ 56 | 'driver' => 'memcached', 57 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 58 | 'sasl' => [ 59 | env('MEMCACHED_USERNAME'), 60 | env('MEMCACHED_PASSWORD'), 61 | ], 62 | 'options' => [ 63 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 64 | ], 65 | 'servers' => [ 66 | [ 67 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 68 | 'port' => env('MEMCACHED_PORT', 11211), 69 | 'weight' => 100, 70 | ], 71 | ], 72 | ], 73 | 74 | 'redis' => [ 75 | 'driver' => 'redis', 76 | 'connection' => 'cache', 77 | ], 78 | 79 | 'dynamodb' => [ 80 | 'driver' => 'dynamodb', 81 | 'key' => env('AWS_ACCESS_KEY_ID'), 82 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 83 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 84 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 85 | ], 86 | 87 | ], 88 | 89 | /* 90 | |-------------------------------------------------------------------------- 91 | | Cache Key Prefix 92 | |-------------------------------------------------------------------------- 93 | | 94 | | When utilizing a RAM based store such as APC or Memcached, there might 95 | | be other applications utilizing the same cache. So, we'll specify a 96 | | value to get prefixed to all our keys so we can avoid collisions. 97 | | 98 | */ 99 | 100 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), 101 | 102 | ]; 103 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Cloud Filesystem Disk 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Many applications store files both locally and in the cloud. For this 24 | | reason, you may specify a default "cloud" driver here. This driver 25 | | will be bound as the Cloud disk implementation in the container. 26 | | 27 | */ 28 | 29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Filesystem Disks 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may configure as many filesystem "disks" as you wish, and you 37 | | may even configure multiple disks of the same driver. Defaults have 38 | | been setup for each driver as an example of the required options. 39 | | 40 | | Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace" 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'url' => env('APP_URL').'/storage', 55 | 'visibility' => 'public', 56 | ], 57 | 58 | 's3' => [ 59 | 'driver' => 's3', 60 | 'key' => env('AWS_ACCESS_KEY_ID'), 61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 62 | 'region' => env('AWS_DEFAULT_REGION'), 63 | 'bucket' => env('AWS_BUCKET'), 64 | 'url' => env('AWS_URL'), 65 | ], 66 | 67 | ], 68 | 69 | ]; 70 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 1024, 48 | 'threads' => 2, 49 | 'time' => 2, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Log Channels 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may configure the log channels for your application. Out of 27 | | the box, Laravel uses the Monolog PHP logging library. This gives 28 | | you a variety of powerful log handlers / formatters to utilize. 29 | | 30 | | Available Drivers: "single", "daily", "slack", "syslog", 31 | | "errorlog", "monolog", 32 | | "custom", "stack" 33 | | 34 | */ 35 | 36 | 'channels' => [ 37 | 'stack' => [ 38 | 'driver' => 'stack', 39 | 'channels' => ['daily'], 40 | 'ignore_exceptions' => false, 41 | ], 42 | 43 | 'single' => [ 44 | 'driver' => 'single', 45 | 'path' => storage_path('logs/laravel.log'), 46 | 'level' => 'debug', 47 | ], 48 | 49 | 'daily' => [ 50 | 'driver' => 'daily', 51 | 'path' => storage_path('logs/laravel.log'), 52 | 'level' => 'debug', 53 | 'days' => 14, 54 | ], 55 | 56 | 'slack' => [ 57 | 'driver' => 'slack', 58 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 59 | 'username' => 'Laravel Log', 60 | 'emoji' => ':boom:', 61 | 'level' => 'critical', 62 | ], 63 | 64 | 'papertrail' => [ 65 | 'driver' => 'monolog', 66 | 'level' => 'debug', 67 | 'handler' => SyslogUdpHandler::class, 68 | 'handler_with' => [ 69 | 'host' => env('PAPERTRAIL_URL'), 70 | 'port' => env('PAPERTRAIL_PORT'), 71 | ], 72 | ], 73 | 74 | 'stderr' => [ 75 | 'driver' => 'monolog', 76 | 'handler' => StreamHandler::class, 77 | 'formatter' => env('LOG_STDERR_FORMATTER'), 78 | 'with' => [ 79 | 'stream' => 'php://stderr', 80 | ], 81 | ], 82 | 83 | 'syslog' => [ 84 | 'driver' => 'syslog', 85 | 'level' => 'debug', 86 | ], 87 | 88 | 'errorlog' => [ 89 | 'driver' => 'errorlog', 90 | 'level' => 'debug', 91 | ], 92 | ], 93 | 94 | ]; 95 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'retry_after' => 90, 49 | 'block_for' => 0, 50 | ], 51 | 52 | 'sqs' => [ 53 | 'driver' => 'sqs', 54 | 'key' => env('AWS_ACCESS_KEY_ID'), 55 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 56 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 57 | 'queue' => env('SQS_QUEUE', 'your-queue-name'), 58 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 59 | ], 60 | 61 | 'redis' => [ 62 | 'driver' => 'redis', 63 | 'connection' => 'default', 64 | 'queue' => env('REDIS_QUEUE', 'default'), 65 | 'retry_after' => 90, 66 | 'block_for' => null, 67 | ], 68 | 69 | ], 70 | 71 | /* 72 | |-------------------------------------------------------------------------- 73 | | Failed Queue Jobs 74 | |-------------------------------------------------------------------------- 75 | | 76 | | These options configure the behavior of failed queue job logging so you 77 | | can control which database and table are used to store the jobs that 78 | | have failed. You may change them to any database / table you wish. 79 | | 80 | */ 81 | 82 | 'failed' => [ 83 | 'database' => env('DB_CONNECTION', 'mysql'), 84 | 'table' => 'failed_jobs', 85 | ], 86 | 87 | ]; 88 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | 'sparkpost' => [ 34 | 'secret' => env('SPARKPOST_SECRET'), 35 | ], 36 | 37 | 'stripe' => [ 38 | 'model' => App\User::class, 39 | 'key' => env('STRIPE_KEY'), 40 | 'secret' => env('STRIPE_SECRET'), 41 | 'webhook' => [ 42 | 'secret' => env('STRIPE_WEBHOOK_SECRET'), 43 | 'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300), 44 | ], 45 | ], 46 | 47 | ]; 48 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('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' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | *.sqlite-journal 3 | -------------------------------------------------------------------------------- /database/factories/CategoryFactory.php: -------------------------------------------------------------------------------- 1 | define(Category::class, function (Faker $faker) { 9 | $name = $faker->word; 10 | return [ 11 | "name" => $name, 12 | "slug" => \Illuminate\Support\Str::slug($name) 13 | ]; 14 | }); 15 | -------------------------------------------------------------------------------- /database/factories/CommentFactory.php: -------------------------------------------------------------------------------- 1 | define(Comment::class, function (Faker $faker) { 9 | return [ 10 | "author_name" => $faker->name, 11 | "author_email" => $faker->email, 12 | "content" => $faker->paragraph, 13 | "post_id" => factory(\App\Models\Post::class)->create()->id 14 | ]; 15 | }); 16 | -------------------------------------------------------------------------------- /database/factories/PostFactory.php: -------------------------------------------------------------------------------- 1 | define(Post::class, function (Faker $faker) { 9 | $title = $faker->sentence("5"); 10 | return [ 11 | "title" => $title, 12 | "slug" => \Illuminate\Support\Str::slug($title), 13 | "content" => $faker->text, 14 | "category_id" => factory(\App\Models\Category::class)->create()->id, 15 | "user_id" => factory(\App\User::class)->create()->id, 16 | "online" => true, 17 | "cover_path" => asset("storage/covers/cover.jpg"), 18 | "visits" => 0 19 | ]; 20 | }); 21 | -------------------------------------------------------------------------------- /database/factories/TagFactory.php: -------------------------------------------------------------------------------- 1 | define(Tag::class, function (Faker $faker) { 9 | $name = $faker->word; 10 | 11 | return [ 12 | "name" => $name, 13 | "slug" => \Illuminate\Support\Str::slug($name) 14 | ]; 15 | }); 16 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(User::class, function (Faker $faker) { 20 | return [ 21 | 'name' => $faker->name, 22 | 'email' => $faker->unique()->safeEmail, 23 | 'email_verified_at' => now(), 24 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 25 | 'remember_token' => Str::random(10), 26 | ]; 27 | }); 28 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password'); 22 | $table->rememberToken(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2019_06_05_201200_create_categories_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->string("name"); 19 | $table->string("slug")->index(); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('categories'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2019_06_05_201221_create_posts_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->unsignedBigInteger("category_id"); 19 | $table->string("title"); 20 | $table->string("slug")->index(); 21 | $table->string("cover_path"); 22 | $table->longText("content"); 23 | $table->boolean("online")->default(1); 24 | $table->unsignedBigInteger("user_id"); 25 | $table->unsignedInteger("visits")->default(0); 26 | $table->timestamps(); 27 | 28 | $table->foreign("category_id")->references("id")->on("categories")->onDelete("cascade"); 29 | $table->foreign("user_id")->references("id")->on("users")->onDelete("cascade"); 30 | }); 31 | } 32 | 33 | /** 34 | * Reverse the migrations. 35 | * 36 | * @return void 37 | */ 38 | public function down() 39 | { 40 | Schema::dropIfExists('posts'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /database/migrations/2019_06_15_065429_create_comments_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->string('author_name'); 19 | $table->string("author_email"); 20 | $table->text("content"); 21 | $table->unsignedBigInteger("post_id"); 22 | $table->timestamps(); 23 | 24 | $table->foreign("post_id")->references("id")->on("posts")->onDelete("cascade"); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('comments'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /database/migrations/2019_07_06_093648_create_tags_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->string("name"); 19 | $table->string("slug")->index(); 20 | $table->timestamps(); 21 | }); 22 | 23 | Schema::create('post_tag', function (Blueprint $table) { 24 | $table->unsignedBigInteger('post_id'); 25 | $table->unsignedBigInteger('tag_id'); 26 | 27 | $table->foreign("post_id")->references("id")->on("posts")->onDelete("cascade"); 28 | $table->foreign("tag_id")->references("id")->on("tags")->onDelete("cascade"); 29 | }); 30 | } 31 | 32 | /** 33 | * Reverse the migrations. 34 | * 35 | * @return void 36 | */ 37 | public function down() 38 | { 39 | Schema::dropIfExists('tags'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(PostsTableSeeder::class); 15 | $this->call(UsersTableSeeder::class); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /database/seeds/PostsTableSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 18 | 19 | for ($i = 0; $i < 20; $i++) { 20 | 21 | $category = \App\Models\Category::find(random_int(1, 5)); 22 | 23 | $title = $faker->sentence("5"); 24 | 25 | $post = $category->posts()->create([ 26 | "title" => $title, 27 | "slug" => \Illuminate\Support\Str::slug($title), 28 | "content" => $faker->text, 29 | "category_id" => random_int(1, 5), 30 | "user_id" => factory(\App\User::class)->create()->id, 31 | "online" => true, 32 | "cover_path" => $cover_path, 33 | "visits" => random_int(0, 50) 34 | ]); 35 | 36 | factory(\App\Models\Comment::class, random_int(0, 4))->create(["post_id" => $post->id]); 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /database/seeds/UsersTableSeeder.php: -------------------------------------------------------------------------------- 1 | create([ 15 | "name" => "John Doe", 16 | "email" => "john@example.com", 17 | "password" => bcrypt(123456) 18 | ]); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "npm run development -- --watch", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "axios": "^0.18", 14 | "bootstrap": "^4.1.0", 15 | "browser-sync": "^2.26.5", 16 | "browser-sync-webpack-plugin": "2.0.1", 17 | "cross-env": "^5.1", 18 | "jquery": "^3.5", 19 | "laravel-mix": "^4.0.7", 20 | "popper.js": "^1.12", 21 | "resolve-url-loader": "^2.3.1", 22 | "sass": "^1.15.2", 23 | "sass-loader": "^7.1.0", 24 | "vue": "^2.5.17", 25 | "vue-template-compiler": "^2.6.10" 26 | }, 27 | "dependencies": { 28 | "datatables.net": "^1.10.19", 29 | "mdbvue": "^5.5.0", 30 | "moment": "^2.24.0", 31 | "vue-router": "^3.0.6", 32 | "vue-simplemde": "^0.5.2", 33 | "vuex": "^3.1.1" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Unit 14 | 15 | 16 | 17 | ./tests/Feature 18 | 19 | 20 | 21 | 22 | ./app 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Handle Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /public/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/cover.jpg -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/favicon.ico -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.eot -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.ttf -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff2 -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.eot -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.ttf -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff2 -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.eot -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.ttf -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juvpengele/laravel-vue-spa-blog/c323ebeb12afc2faf3a07ff037c74e431dd30fca/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff2 -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | define('LARAVEL_START', microtime(true)); 11 | 12 | /* 13 | |-------------------------------------------------------------------------- 14 | | Register The Auto Loader 15 | |-------------------------------------------------------------------------- 16 | | 17 | | Composer provides a convenient, automatically generated class loader for 18 | | our application. We just need to utilize it! We'll simply require it 19 | | into the script here so that we don't have to worry about manual 20 | | loading any of our classes later on. It feels great to relax. 21 | | 22 | */ 23 | 24 | require __DIR__.'/../vendor/autoload.php'; 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | Turn On The Lights 29 | |-------------------------------------------------------------------------- 30 | | 31 | | We need to illuminate PHP development, so let us turn on the lights. 32 | | This bootstraps the framework and gets it ready for use, then it 33 | | will load up this application so that we can run it and send 34 | | the responses back to the browser and delight our users. 35 | | 36 | */ 37 | 38 | $app = require_once __DIR__.'/../bootstrap/app.php'; 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Run The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once we have the application, we can handle the incoming request 46 | | through the kernel, and send the associated response back to 47 | | the client's browser allowing them to enjoy the creative 48 | | and wonderful application we have prepared for them. 49 | | 50 | */ 51 | 52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 53 | 54 | $response = $kernel->handle( 55 | $request = Illuminate\Http\Request::capture() 56 | ); 57 | 58 | $response->send(); 59 | 60 | $kernel->terminate($request, $response); 61 | -------------------------------------------------------------------------------- /public/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/js/app.js": "/js/app.js?id=fa678d8d34d6fbb5585f", 3 | "/css/app.css": "/css/app.css?id=b24034478279ce7218cb" 4 | } 5 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /resources/js/App.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 35 | 36 | -------------------------------------------------------------------------------- /resources/js/Pages/Admin/Categories/CategoriesCreate.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 50 | 51 | -------------------------------------------------------------------------------- /resources/js/Pages/Admin/Categories/CategoriesEdit.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 70 | 71 | -------------------------------------------------------------------------------- /resources/js/Pages/Admin/Categories/CategoriesIndex.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 36 | -------------------------------------------------------------------------------- /resources/js/Pages/Admin/Login.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 75 | 76 | -------------------------------------------------------------------------------- /resources/js/Pages/Admin/Posts/PostsIndex.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | -------------------------------------------------------------------------------- /resources/js/Pages/Admin/Tags/TagsEdit.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 67 | 68 | -------------------------------------------------------------------------------- /resources/js/Pages/Admin/Tags/TagsIndex.vue: -------------------------------------------------------------------------------- 1 | 39 | 40 | 88 | -------------------------------------------------------------------------------- /resources/js/Pages/Blog/CategoryIndex.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 61 | 62 | -------------------------------------------------------------------------------- /resources/js/Pages/Blog/PostShow.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 59 | 60 | -------------------------------------------------------------------------------- /resources/js/Pages/Blog/PostsIndex.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 60 | 61 | -------------------------------------------------------------------------------- /resources/js/Pages/Blog/TagIndex.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 61 | 62 | -------------------------------------------------------------------------------- /resources/js/Pages/Layouts/AdminLayout.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 30 | 31 | -------------------------------------------------------------------------------- /resources/js/Pages/Layouts/AdminPartials/Breadcrumb.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | 23 | -------------------------------------------------------------------------------- /resources/js/Pages/Layouts/AdminPartials/Navbar.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 30 | 31 | -------------------------------------------------------------------------------- /resources/js/Pages/Layouts/AdminPartials/Sidebar.vue: -------------------------------------------------------------------------------- 1 | 71 | 72 | 78 | 79 | -------------------------------------------------------------------------------- /resources/js/Pages/Layouts/BlogLayout.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 26 | 27 | -------------------------------------------------------------------------------- /resources/js/Pages/Layouts/BlogPartials/Aside.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 30 | 31 | -------------------------------------------------------------------------------- /resources/js/Pages/Layouts/BlogPartials/Footer.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 18 | 19 | -------------------------------------------------------------------------------- /resources/js/Pages/Layouts/BlogPartials/Navbar.vue: -------------------------------------------------------------------------------- 1 | 38 | 39 | 51 | 52 | -------------------------------------------------------------------------------- /resources/js/Pages/Layouts/LoginLayout.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 10 | -------------------------------------------------------------------------------- /resources/js/Pages/NotFound.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | -------------------------------------------------------------------------------- /resources/js/Utilities/Auth.js: -------------------------------------------------------------------------------- 1 | import Storage from "./Storage"; 2 | 3 | class Auth { 4 | 5 | get loggedIn() { 6 | return Storage.has("access_token"); 7 | } 8 | 9 | get token() { 10 | return Storage.get("access_token") 11 | } 12 | 13 | login(payload) { 14 | const entries = Object.entries(payload); 15 | 16 | entries.forEach((item) => { 17 | Storage.record(item[0], item[1]) 18 | }); 19 | } 20 | 21 | logOut() { 22 | Storage.clear(); 23 | } 24 | 25 | } 26 | 27 | export default new Auth; -------------------------------------------------------------------------------- /resources/js/Utilities/Errors.js: -------------------------------------------------------------------------------- 1 | class Errors { 2 | 3 | constructor() { 4 | this.errors = {}; 5 | } 6 | 7 | has(key) { 8 | return this.errors.hasOwnProperty(key); 9 | } 10 | 11 | record(errors) { 12 | this.errors = errors; 13 | } 14 | 15 | get(key) { 16 | return this.errors[key][0]; 17 | } 18 | 19 | clear(key) { 20 | delete this.errors[key]; 21 | } 22 | 23 | clearAll() { 24 | this.errors = {}; 25 | } 26 | 27 | } 28 | 29 | export default Errors; -------------------------------------------------------------------------------- /resources/js/Utilities/Flash.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 19 | 20 | -------------------------------------------------------------------------------- /resources/js/Utilities/Storage.js: -------------------------------------------------------------------------------- 1 | class Storage { 2 | constructor() { 3 | this.storage = localStorage 4 | } 5 | 6 | record(key, value) { 7 | this.storage.setItem(key, value) 8 | } 9 | 10 | has(key) { 11 | return this.storage.getItem(key) !== null; 12 | } 13 | 14 | get(key) { 15 | return this.storage.getItem(key); 16 | } 17 | 18 | remove(key) { 19 | this.storage.removeItem(key) 20 | } 21 | 22 | clear() { 23 | this.storage.clear(); 24 | } 25 | 26 | } 27 | 28 | const storage = new Storage(); 29 | 30 | export default storage; -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import VueRouter from "vue-router"; 3 | import routes from "./routes/routes"; 4 | import store from "./store/store"; 5 | require('./bootstrap'); 6 | 7 | Vue.use(VueRouter); 8 | 9 | 10 | Vue.component('App', require('./App').default); 11 | 12 | //Helpers 13 | Vue.prototype.pluralize = (word, count) => { 14 | return parseInt(count) > 1 ? word + "s" : word; 15 | }; 16 | 17 | Vue.prototype.setDocumentTitle = function (title = "SPA Blog") { 18 | document.title = title; 19 | }; 20 | 21 | const app = new Vue({ 22 | el: '#app', 23 | router: new VueRouter({ routes, mode: "history" }), 24 | store 25 | }); 26 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support 3 | * for JavaScript based Bootstrap features such as modals and tabs. This 4 | * code may be modified to fit the specific needs of your application. 5 | */ 6 | 7 | try { 8 | window.Popper = require('popper.js').default; 9 | window.$ = window.jQuery = require('jquery'); 10 | 11 | require('bootstrap'); 12 | } catch (e) {} 13 | 14 | /** 15 | * We'll load the axios HTTP library which allows us to easily issue requests 16 | * to our Laravel back-end. This library automatically handles sending the 17 | * CSRF token as a header based on the value of the "XSRF" token cookie. 18 | */ 19 | 20 | window.axios = require('axios'); 21 | 22 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 23 | 24 | 25 | 26 | 27 | 28 | 29 | /** 30 | * Next we will register the CSRF Token as a common header with Axios so that 31 | * all outgoing HTTP requests automatically have it attached. This is just 32 | * a simple convenience so we don't have to attach every token manually. 33 | */ 34 | 35 | let token = document.head.querySelector('meta[name="csrf-token"]'); 36 | 37 | if (token) { 38 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 39 | } else { 40 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 41 | } 42 | 43 | /** 44 | * Echo exposes an expressive API for subscribing to channels and listening 45 | * for events that are broadcast by Laravel. Echo and event broadcasting 46 | * allows your team to easily build robust real-time web applications. 47 | */ 48 | 49 | // import Echo from 'laravel-echo' 50 | 51 | // window.Pusher = require('pusher-js'); 52 | 53 | // window.Echo = new Echo({ 54 | // broadcaster: 'pusher', 55 | // key: process.env.MIX_PUSHER_APP_KEY, 56 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 57 | // encrypted: true 58 | // }); 59 | 60 | $(document).ready(function() { 61 | 62 | 63 | // $(".datatable").DataTable(); 64 | }); 65 | -------------------------------------------------------------------------------- /resources/js/components/Categories.vue: -------------------------------------------------------------------------------- 1 | 38 | 39 | 73 | 74 | -------------------------------------------------------------------------------- /resources/js/components/Comments.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 42 | 43 | -------------------------------------------------------------------------------- /resources/js/components/Comments/Comment.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 57 | 58 | -------------------------------------------------------------------------------- /resources/js/components/Comments/CommentForm.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 57 | 58 | -------------------------------------------------------------------------------- /resources/js/components/Comments/CommentModal.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 63 | 64 | -------------------------------------------------------------------------------- /resources/js/components/CoverUploader.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 47 | 48 | -------------------------------------------------------------------------------- /resources/js/components/Pagination.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 53 | 54 | -------------------------------------------------------------------------------- /resources/js/components/Post.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 39 | 40 | -------------------------------------------------------------------------------- /resources/js/components/PostSearch.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 69 | 70 | -------------------------------------------------------------------------------- /resources/js/components/Tag.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 41 | 42 | -------------------------------------------------------------------------------- /resources/js/components/admin/Posts.vue: -------------------------------------------------------------------------------- 1 | 46 | 47 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /resources/js/lib/datatable/datatable-bs4.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | DataTables Bootstrap 4 integration 3 | ©2011-2017 SpryMedia Ltd - datatables.net/license 4 | */ 5 | (function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(a){return b(a,window,document)}):"object"===typeof exports?module.exports=function(a,d){a||(a=window);if(!d||!d.fn.dataTable)d=require("datatables.net")(a,d).$;return b(d,a,a.document)}:b(jQuery,window,document)})(function(b,a,d,m){var f=b.fn.dataTable;b.extend(!0,f.defaults,{dom:"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>", 6 | renderer:"bootstrap"});b.extend(f.ext.classes,{sWrapper:"dataTables_wrapper dt-bootstrap4",sFilterInput:"form-control form-control-sm",sLengthSelect:"custom-select custom-select-sm form-control form-control-sm",sProcessing:"dataTables_processing card",sPageButton:"paginate_button page-item"});f.ext.renderer.pageButton.bootstrap=function(a,h,r,s,j,n){var o=new f.Api(a),t=a.oClasses,k=a.oLanguage.oPaginate,u=a.oLanguage.oAria.paginate||{},e,g,p=0,q=function(d,f){var l,h,i,c,m=function(a){a.preventDefault(); 7 | !b(a.currentTarget).hasClass("disabled")&&o.page()!=a.data.action&&o.page(a.data.action).draw("page")};l=0;for(h=f.length;l", 8 | {"class":t.sPageButton+" "+g,id:0===r&&"string"===typeof c?a.sTableId+"_"+c:null}).append(b("",{href:"#","aria-controls":a.sTableId,"aria-label":u[c],"data-dt-idx":p,tabindex:a.iTabIndex,"class":"page-link"}).html(e)).appendTo(d),a.oApi._fnBindAction(i,{action:c},m),p++)}},i;try{i=b(h).find(d.activeElement).data("dt-idx")}catch(v){}q(b(h).empty().html('