diff --git a/Library/.editorconfig b/Library/.editorconfig index 6537ca4..26ef3ca 100644 --- a/Library/.editorconfig +++ b/Library/.editorconfig @@ -8,6 +8,9 @@ indent_style = space indent_size = 4 trim_trailing_whitespace = true +[*.scss] +indent_size = 2 + [*.md] trim_trailing_whitespace = false diff --git a/Library/.idea/Library.iml b/Library/.idea/Library.iml index 91de2b0..861ac01 100644 --- a/Library/.idea/Library.iml +++ b/Library/.idea/Library.iml @@ -4,7 +4,11 @@ + + + + @@ -25,6 +29,7 @@ + diff --git a/Library/.idea/php.xml b/Library/.idea/php.xml index 07f5143..b53c0f4 100644 --- a/Library/.idea/php.xml +++ b/Library/.idea/php.xml @@ -88,6 +88,11 @@ + + + + + diff --git a/Library/app/Http/Controllers/Auth/RegisterController.php b/Library/app/Http/Controllers/Auth/RegisterController.php index 6fdcba0..572c58e 100644 --- a/Library/app/Http/Controllers/Auth/RegisterController.php +++ b/Library/app/Http/Controllers/Auth/RegisterController.php @@ -3,7 +3,8 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; -use App\User; +use App\Models\User; +use \Cviebrock\EloquentSluggable\Services\SlugService; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; @@ -28,7 +29,7 @@ class RegisterController extends Controller * * @var string */ - protected $redirectTo = '/home'; + protected $redirectTo = '/'; /** * Create a new controller instance. @@ -49,6 +50,8 @@ class RegisterController extends Controller protected function validator(array $data) { return Validator::make($data, [ + 'avatar' => ['required', 'max:1500'], + 'avatar_rating' => ['required', 'numeric', 'min:0', 'max:10' ], 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => ['required', 'string', 'min:8', 'confirmed'], @@ -63,10 +66,25 @@ class RegisterController extends Controller */ protected function create(array $data) { - return User::create([ + $user = User::create([ + 'avatar' => NULL, + 'avatar_rating' => $data['avatar_rating'], 'name' => $data['name'], 'email' => $data['email'], - 'password' => Hash::make($data['password']), + 'password' => bcrypt($data['password']), ]); + if($data['avatar_rating'] === '10') { + $user->update([ + 'user_verified_at' => now(), + ]); + } + if (isset($data['avatar'])) { + $upload_path = 'public/users/user_'.$user->id.'/avatars'; + $avatar_path = $data['avatar']->store($upload_path); + $user->update([ + 'avatar' => $avatar_path, + ]); + } + return $user; } } diff --git a/Library/app/Http/Controllers/BookController.php b/Library/app/Http/Controllers/BookController.php new file mode 100644 index 0000000..ad9cbd8 --- /dev/null +++ b/Library/app/Http/Controllers/BookController.php @@ -0,0 +1,91 @@ +middleware('BookPermission', ['only' => ['edit', 'update', 'destroy']]); + $this->middleware('auth', ['only' => ['create']]); + } + + /** + * Show the form for creating a new resource. + */ + public function create(User $user) + { + return view('book.create', [ + 'user' => $user + ]); + } + + /** + * Store a newly created resource in storage. + */ + public function store(BookRequest $request) + { + $upload_path = 'public/users/user_' . Auth::id() . '/books'; + $photo_path = $request->file('photo')->store($upload_path); + $book = Book::create([ + 'user_id' => Auth::id(), + 'photo' => $photo_path, + 'name' => $request->name, + 'description' => $request->description + ]); + + return redirect()->route('book.show', $book); + } + + /** + * Display the specified resource. + */ + public function show(Book $book) + { + return view('book.show', [ + 'book' => $book->load('comments', 'comments.user', 'user') + ]); + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(Book $book) + { + return view('book.edit', [ + 'book' => $book, + ]); + } + + /** + * Update the specified resource in storage. + */ + public function update(BookRequest $request, Book $book) + { + if ($request->file('photo')) { + $upload_path = 'public/users/user_' . Auth::id() . '/books/'; + $photo_path = $request->file('photo')->store($upload_path); + $book->photo = $photo_path; + } + $book->name = $request->name; + $book->description = $request->description; + $book->save(); + + return redirect()->route('book.show', ['book' => $book]); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(Book $book) + { + $book->delete(); + return redirect()->route('user.show', ['book' => $book->user()]); + + } +} diff --git a/Library/app/Http/Controllers/HomeController.php b/Library/app/Http/Controllers/HomeController.php index 7cbc2c3..11c4de5 100644 --- a/Library/app/Http/Controllers/HomeController.php +++ b/Library/app/Http/Controllers/HomeController.php @@ -3,19 +3,11 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\Models\Book; +use App\Models\User; class HomeController extends Controller { - /** - * Create a new controller instance. - * - * @return void - */ - public function __construct() - { - $this->middleware('auth'); - } - /** * Show the application dashboard. * @@ -23,6 +15,9 @@ class HomeController extends Controller */ public function index() { - return view('home'); + return view('home', [ + 'books' => Book::orderBy('created_at','desc')->take(5)->get(), + 'users' => User::orderBy('created_at','desc')->take(5)->get(), + ]); } } diff --git a/Library/app/Http/Controllers/UserController.php b/Library/app/Http/Controllers/UserController.php new file mode 100644 index 0000000..c189e97 --- /dev/null +++ b/Library/app/Http/Controllers/UserController.php @@ -0,0 +1,24 @@ +middleware('UserPermission', ['only' => ['edit', 'update', 'destroy']]); + } + + /** + * Display the specified resource. + */ + public function show(User $user) + { + return view('user.show', [ + 'user' => $user->load('books'), + ]); + } +} diff --git a/Library/app/Http/Kernel.php b/Library/app/Http/Kernel.php index 2741c0a..ea04643 100644 --- a/Library/app/Http/Kernel.php +++ b/Library/app/Http/Kernel.php @@ -54,6 +54,7 @@ class Kernel extends HttpKernel 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'BookPermission' => \App\Http\Middleware\BookPermission::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, diff --git a/Library/app/Http/Middleware/BookPermission.php b/Library/app/Http/Middleware/BookPermission.php new file mode 100644 index 0000000..40a861c --- /dev/null +++ b/Library/app/Http/Middleware/BookPermission.php @@ -0,0 +1,21 @@ +book->user_id != Auth::id()) { + abort(403, 'Access denied'); + } + return $next($request); + } +} diff --git a/Library/app/Http/Request/BookRequest.php b/Library/app/Http/Request/BookRequest.php new file mode 100644 index 0000000..2cafbbb --- /dev/null +++ b/Library/app/Http/Request/BookRequest.php @@ -0,0 +1,33 @@ + 'max:1500|required', + 'name' => 'string|max:100', + 'description' => 'required|string|max:255', + ]; + } + +} diff --git a/Library/app/Models/Book.php b/Library/app/Models/Book.php new file mode 100644 index 0000000..4005562 --- /dev/null +++ b/Library/app/Models/Book.php @@ -0,0 +1,45 @@ + [ + 'source' => 'name' + ] + ]; + } + + public function user() + { + return $this->belongsTo(User::class); + } + + public function comments() + { + return $this->hasMany(Comment::class); + } +} diff --git a/Library/app/Models/Comment.php b/Library/app/Models/Comment.php new file mode 100644 index 0000000..71d16a3 --- /dev/null +++ b/Library/app/Models/Comment.php @@ -0,0 +1,26 @@ +belongsTo(Book::class); + } + + public function user() + { + return $this->belongsTo(User::class); + } + +} diff --git a/Library/app/Models/User.php b/Library/app/Models/User.php new file mode 100644 index 0000000..fb5ce18 --- /dev/null +++ b/Library/app/Models/User.php @@ -0,0 +1,74 @@ + 'datetime', + ]; + + public function books() + { + return $this->hasMany(Book::class); + } + + public function comments() + { + return $this->hasMany(Comment::class); + } + + public function getRouteKeyName() + { + return 'slug'; + } + + public function sluggable() + { + return [ + 'slug' => [ + 'source' => 'name' + ] + ]; + } + + public function UserAvatar(){ + if(is_null($this->avatar)){ + $url = asset('images/default-avatar.jpg'); + } + else { + $url = url(Storage::url($this->avatar)); + } + return $url; + } +} diff --git a/Library/app/User.php b/Library/app/User.php deleted file mode 100644 index e79dab7..0000000 --- a/Library/app/User.php +++ /dev/null @@ -1,39 +0,0 @@ - 'datetime', - ]; -} diff --git a/Library/composer.json b/Library/composer.json index bfa54bd..37df675 100644 --- a/Library/composer.json +++ b/Library/composer.json @@ -9,12 +9,15 @@ "license": "MIT", "require": { "php": "^7.2", + "cviebrock/eloquent-sluggable": "^6.0", + "davejamesmiller/laravel-breadcrumbs": "^5.3", "fideloper/proxy": "^4.0", "laravel/framework": "^6.2", "laravel/tinker": "^1.0", "laravel/ui": "^1.1" }, "require-dev": { + "barryvdh/laravel-debugbar": "^3.2", "facade/ignition": "^1.4", "fzaninotto/faker": "^1.4", "mockery/mockery": "^1.0", diff --git a/Library/composer.lock b/Library/composer.lock index 8abc3f6..dec9d3d 100644 --- a/Library/composer.lock +++ b/Library/composer.lock @@ -4,8 +4,195 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1b9e73ad57a9bbfb35d3c7cc0d815d97", + "content-hash": "e8b5db1221abaa3c21d7a4760eb7bbd0", "packages": [ + { + "name": "cocur/slugify", + "version": "v3.2", + "source": { + "type": "git", + "url": "https://github.com/cocur/slugify.git", + "reference": "d41701efe58ba2df9cae029c3d21e1518cc6780e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cocur/slugify/zipball/d41701efe58ba2df9cae029c3d21e1518cc6780e", + "reference": "d41701efe58ba2df9cae029c3d21e1518cc6780e", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=5.5.9" + }, + "require-dev": { + "laravel/framework": "~5.1", + "latte/latte": "~2.2", + "league/container": "^2.2.0", + "mikey179/vfsstream": "~1.6", + "mockery/mockery": "~0.9", + "nette/di": "~2.2", + "phpunit/phpunit": "~4.8.36|~5.2", + "pimple/pimple": "~1.1", + "plumphp/plum": "~0.1", + "silex/silex": "~1.3", + "symfony/config": "~2.4|~3.0|~4.0", + "symfony/dependency-injection": "~2.4|~3.0|~4.0", + "symfony/http-kernel": "~2.4|~3.0|~4.0", + "twig/twig": "~1.26|~2.0", + "zendframework/zend-modulemanager": "~2.2", + "zendframework/zend-servicemanager": "~2.2", + "zendframework/zend-view": "~2.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Cocur\\Slugify\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ivo Bathke", + "email": "ivo.bathke@gmail.com" + }, + { + "name": "Florian Eckerstorfer", + "email": "florian@eckerstorfer.co", + "homepage": "https://florian.ec" + } + ], + "description": "Converts a string into a slug.", + "keywords": [ + "slug", + "slugify" + ], + "time": "2019-01-31T20:38:55+00:00" + }, + { + "name": "cviebrock/eloquent-sluggable", + "version": "6.0.2", + "source": { + "type": "git", + "url": "https://github.com/cviebrock/eloquent-sluggable.git", + "reference": "20f39ae0eeb54c73756834570be7f514fa350cbb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cviebrock/eloquent-sluggable/zipball/20f39ae0eeb54c73756834570be7f514fa350cbb", + "reference": "20f39ae0eeb54c73756834570be7f514fa350cbb", + "shasum": "" + }, + "require": { + "cocur/slugify": "^3.2", + "illuminate/config": "^6.0", + "illuminate/database": "^6.0", + "illuminate/support": "^6.0", + "php": "^7.2" + }, + "require-dev": { + "limedeck/phpunit-detailed-printer": "^5.0", + "mockery/mockery": "^1.2.3", + "orchestra/database": "4.*", + "orchestra/testbench": "4.*", + "phpunit/phpunit": "^8.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Cviebrock\\EloquentSluggable\\ServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Cviebrock\\EloquentSluggable\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Colin Viebrock", + "email": "colin@viebrock.ca" + } + ], + "description": "Easy creation of slugs for your Eloquent models in Laravel", + "homepage": "https://github.com/cviebrock/eloquent-sluggable", + "keywords": [ + "eloquent", + "eloquent-sluggable", + "laravel", + "lumen", + "slug", + "sluggable" + ], + "time": "2019-10-10T04:32:04+00:00" + }, + { + "name": "davejamesmiller/laravel-breadcrumbs", + "version": "5.3.1", + "source": { + "type": "git", + "url": "https://github.com/davejamesmiller/laravel-breadcrumbs.git", + "reference": "40a73bc9b32fbbee18938dc92228dea161365245" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/davejamesmiller/laravel-breadcrumbs/zipball/40a73bc9b32fbbee18938dc92228dea161365245", + "reference": "40a73bc9b32fbbee18938dc92228dea161365245", + "shasum": "" + }, + "require": { + "facade/ignition-contracts": "^1.0", + "illuminate/support": "^5.6|^6.0", + "illuminate/view": "^5.6|^6.0", + "php": ">=7.1.3" + }, + "require-dev": { + "orchestra/testbench": "^3.6", + "php-coveralls/php-coveralls": "^1.0", + "phpunit/phpunit": "^7.0|^8.0", + "spatie/phpunit-snapshot-assertions": "^2.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "DaveJamesMiller\\Breadcrumbs\\BreadcrumbsServiceProvider" + ], + "aliases": { + "Breadcrumbs": "DaveJamesMiller\\Breadcrumbs\\Facades\\Breadcrumbs" + } + } + }, + "autoload": { + "psr-4": { + "DaveJamesMiller\\Breadcrumbs\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dave James Miller", + "email": "dave@davejamesmiller.com" + } + ], + "description": "A simple Laravel-style way to create breadcrumbs.", + "homepage": "https://github.com/davejamesmiller/laravel-breadcrumbs", + "keywords": [ + "laravel" + ], + "time": "2019-10-20T18:25:39+00:00" + }, { "name": "dnoegel/php-xdg-base-dir", "version": "0.1", @@ -326,6 +513,50 @@ ], "time": "2019-03-17T18:48:37+00:00" }, + { + "name": "facade/ignition-contracts", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/facade/ignition-contracts.git", + "reference": "f445db0fb86f48e205787b2592840dd9c80ded28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/f445db0fb86f48e205787b2592840dd9c80ded28", + "reference": "f445db0fb86f48e205787b2592840dd9c80ded28", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Facade\\IgnitionContracts\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://flareapp.io", + "role": "Developer" + } + ], + "description": "Solution contracts for Ignition", + "homepage": "https://github.com/facade/ignition-contracts", + "keywords": [ + "contracts", + "flare", + "ignition" + ], + "time": "2019-08-30T14:06:08+00:00" + }, { "name": "fideloper/proxy", "version": "4.2.1", @@ -2954,6 +3185,74 @@ } ], "packages-dev": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.2.8", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "18208d64897ab732f6c04a19b319fe8f1d57a9c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/18208d64897ab732f6c04a19b319fe8f1d57a9c0", + "reference": "18208d64897ab732f6c04a19b319fe8f1d57a9c0", + "shasum": "" + }, + "require": { + "illuminate/routing": "^5.5|^6", + "illuminate/session": "^5.5|^6", + "illuminate/support": "^5.5|^6", + "maximebf/debugbar": "~1.15.0", + "php": ">=7.0", + "symfony/debug": "^3|^4", + "symfony/finder": "^3|^4" + }, + "require-dev": { + "laravel/framework": "5.5.x" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ], + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facade" + } + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "time": "2019-08-29T07:01:03+00:00" + }, { "name": "doctrine/instantiator", "version": "1.3.0", @@ -3135,50 +3434,6 @@ ], "time": "2019-11-14T10:51:35+00:00" }, - { - "name": "facade/ignition-contracts", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/facade/ignition-contracts.git", - "reference": "f445db0fb86f48e205787b2592840dd9c80ded28" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/f445db0fb86f48e205787b2592840dd9c80ded28", - "reference": "f445db0fb86f48e205787b2592840dd9c80ded28", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "Facade\\IgnitionContracts\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Freek Van der Herten", - "email": "freek@spatie.be", - "homepage": "https://flareapp.io", - "role": "Developer" - } - ], - "description": "Solution contracts for Ignition", - "homepage": "https://github.com/facade/ignition-contracts", - "keywords": [ - "contracts", - "flare", - "ignition" - ], - "time": "2019-08-30T14:06:08+00:00" - }, { "name": "filp/whoops", "version": "2.5.0", @@ -3336,6 +3591,67 @@ ], "time": "2016-01-20T08:20:44+00:00" }, + { + "name": "maximebf/debugbar", + "version": "v1.15.1", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/6c4277f6117e4864966c9cb58fb835cee8c74a1e", + "reference": "6c4277f6117e4864966c9cb58fb835cee8c74a1e", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "psr/log": "^1.0", + "symfony/var-dumper": "^2.6|^3|^4" + }, + "require-dev": { + "phpunit/phpunit": "^5" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug", + "debugbar" + ], + "time": "2019-09-24T14:55:42+00:00" + }, { "name": "mockery/mockery", "version": "1.2.4", diff --git a/Library/config/auth.php b/Library/config/auth.php index aaf982b..ba1a4d8 100644 --- a/Library/config/auth.php +++ b/Library/config/auth.php @@ -68,7 +68,7 @@ return [ 'providers' => [ 'users' => [ 'driver' => 'eloquent', - 'model' => App\User::class, + 'model' => App\Models\User::class, ], // 'users' => [ diff --git a/Library/database/migrations/2014_10_12_000000_create_users_table.php b/Library/database/migrations/2014_10_12_000000_create_users_table.php index a91e1d3..1edd959 100644 --- a/Library/database/migrations/2014_10_12_000000_create_users_table.php +++ b/Library/database/migrations/2014_10_12_000000_create_users_table.php @@ -15,7 +15,11 @@ class CreateUsersTable extends Migration { Schema::create('users', function (Blueprint $table) { $table->bigIncrements('id'); + $table->string('avatar')->nullable(); + $table->integer('avatar_rating')->nullable(); + $table->timestamp('user_verified_at')->nullable(); $table->string('name'); + $table->string('slug')->unique(); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); diff --git a/Library/database/migrations/2019_12_10_140611_create_books_table.php b/Library/database/migrations/2019_12_10_140611_create_books_table.php new file mode 100644 index 0000000..1f168ad --- /dev/null +++ b/Library/database/migrations/2019_12_10_140611_create_books_table.php @@ -0,0 +1,37 @@ +bigIncrements('id'); + $table->bigInteger('user_id')->unsigned(); + $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $table->string('photo'); + $table->string('name'); + $table->string('slug')->unique(); + $table->string('description'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('books'); + } +} diff --git a/Library/database/migrations/2019_12_10_140659_create_comments_table.php b/Library/database/migrations/2019_12_10_140659_create_comments_table.php new file mode 100644 index 0000000..3e8afb0 --- /dev/null +++ b/Library/database/migrations/2019_12_10_140659_create_comments_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->bigInteger('book_id')->unsigned(); + $table->foreign('book_id')->references('id')->on('books')->onDelete('cascade'); + $table->integer('user_id')->unsigned(); + $table->string('comment'); + $table->dateTime('edited_at')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('comments'); + } +} diff --git a/Library/resources/images/default-avatar.jpg b/Library/resources/images/default-avatar.jpg index 9c47486..63c8cb6 100644 Binary files a/Library/resources/images/default-avatar.jpg and b/Library/resources/images/default-avatar.jpg differ diff --git a/Library/resources/js/facedatection.js b/Library/resources/js/facedatection.js index 31a4f91..53bbae8 100644 --- a/Library/resources/js/facedatection.js +++ b/Library/resources/js/facedatection.js @@ -1,6 +1,7 @@ const utils = new Utils('errorMessage'), imageInput = document.getElementById('imageInput'), fileInput = document.getElementById('fileInput'), + avatarRatingInput = document.getElementById('avatarRating'), imageResult = document.getElementById('imageResult'); fileInput.addEventListener('change', (e) => { @@ -118,6 +119,7 @@ function isMatching(facesSize, imageWidth, imageHeight, facePoint1, facePoint2, } result(imageRating, errorMassages, errorMessageId, massageAlertPrimaryId); + avatarRatingInput.setAttribute('value', imageRating); } function result(imageRating, errorMassages, errorMessageId, massageAlertPrimaryId) { diff --git a/Library/resources/sass/app.scss b/Library/resources/sass/app.scss index 51df9f8..842b34c 100644 --- a/Library/resources/sass/app.scss +++ b/Library/resources/sass/app.scss @@ -8,4 +8,8 @@ @import '~bootstrap/scss/bootstrap'; // Sections +@import 'sections/book.scss'; +@import 'sections/books.scss'; @import 'sections/register.scss'; +@import 'sections/user.scss'; +@import 'sections/users.scss'; diff --git a/Library/resources/sass/sections/book.scss b/Library/resources/sass/sections/book.scss new file mode 100644 index 0000000..295805e --- /dev/null +++ b/Library/resources/sass/sections/book.scss @@ -0,0 +1,5 @@ +.book{ + img{ + width: 100%; + } +} diff --git a/Library/resources/sass/sections/books.scss b/Library/resources/sass/sections/books.scss new file mode 100644 index 0000000..86555b2 --- /dev/null +++ b/Library/resources/sass/sections/books.scss @@ -0,0 +1,10 @@ +.books{ + img{ + width: 100%; + } + h2 { + font-size: 20px; + margin: 20px 0 0 0; + color: #000000 + } +} diff --git a/Library/resources/sass/sections/user.scss b/Library/resources/sass/sections/user.scss new file mode 100644 index 0000000..0dc4e38 --- /dev/null +++ b/Library/resources/sass/sections/user.scss @@ -0,0 +1,10 @@ +.profile { + img { + width: 100%; + } + + h1 { + font-size: 20px; + margin: 20px 0 0 0; + } +} diff --git a/Library/resources/sass/sections/users.scss b/Library/resources/sass/sections/users.scss new file mode 100644 index 0000000..d6bb425 --- /dev/null +++ b/Library/resources/sass/sections/users.scss @@ -0,0 +1,27 @@ +.users { + ul { + list-style: none; + margin: 0px; + padding: 0px; + + li { + a { + display: flex; + align-items: center; + img { + width: 60px; + height: 60px; + border-radius: 100%; + margin-right: 20px; + object-fit: cover; + } + + p { + width: calc(100% - 80px); + margin-bottom: 0px; + font-size: 16px; + } + } + } + } +} diff --git a/Library/resources/views/auth/register.blade.php b/Library/resources/views/auth/register.blade.php index 43e4ad0..901da49 100644 --- a/Library/resources/views/auth/register.blade.php +++ b/Library/resources/views/auth/register.blade.php @@ -13,7 +13,7 @@
{{ __('Register') }}
-
+ @csrf
@@ -33,7 +33,7 @@ class="col-md-4 col-form-label text-md-right">Avatar
- +
diff --git a/Library/resources/views/book/create.blade.php b/Library/resources/views/book/create.blade.php new file mode 100644 index 0000000..35e0353 --- /dev/null +++ b/Library/resources/views/book/create.blade.php @@ -0,0 +1,68 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Register') }}
+
+ + {{csrf_field()}} + {{method_field('POST')}} + +
+
+ +
+ + @if ($errors->has('photo')) + + {{ $errors->first('photo') }} + + @endif +
+
+ +
+ +
+ + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif +
+
+ + +
+ +
+ + @if ($errors->has('description')) + + {{ $errors->first('description') }} + + @endif +
+
+ +
+
+ +
+
+
+ +
+
+
+
+
+@endsection diff --git a/Library/resources/views/book/show.blade.php b/Library/resources/views/book/show.blade.php new file mode 100644 index 0000000..2d8591d --- /dev/null +++ b/Library/resources/views/book/show.blade.php @@ -0,0 +1,39 @@ +@extends('layouts.app') + +@section('content') + +
+
+
+
+
+
Book
+
+ +

{{$book->name}}

+
+
+
+ +
+
+
+@endsection diff --git a/Library/resources/views/home.blade.php b/Library/resources/views/home.blade.php index 05dfca9..4c60cf7 100644 --- a/Library/resources/views/home.blade.php +++ b/Library/resources/views/home.blade.php @@ -1,23 +1,42 @@ @extends('layouts.app') @section('content') -
-
-
-
-
Dashboard
- -
- @if (session('status')) - @endsection diff --git a/Library/resources/views/layouts/app.blade.php b/Library/resources/views/layouts/app.blade.php index 282cb4c..526a3e7 100644 --- a/Library/resources/views/layouts/app.blade.php +++ b/Library/resources/views/layouts/app.blade.php @@ -46,11 +46,13 @@ @endif @else +