Zintegorwano detektor twarzy z backendem. Utworzono modele i migracje dla użytkowników, książek oraz komentarzy. Przygotowano w pełni funkcjonalne widoki dla dodawania książek, przeglądania userów i przeglądania książek. Dodano podstawowe zabezpieczenia i walidacje. Przygotowano modele dla edycji i usuwania książek.
This commit is contained in:
parent
7fd7191f87
commit
d3f517d508
@ -8,6 +8,9 @@ indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.scss]
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
|
@ -4,7 +4,11 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/app" isTestSource="false" packagePrefix="App\" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="Tests\" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/barryvdh/laravel-debugbar" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/cocur/slugify" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/cviebrock/eloquent-sluggable" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/davejamesmiller/laravel-breadcrumbs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/dnoegel/php-xdg-base-dir" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/inflector" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/doctrine/instantiator" />
|
||||
@ -25,6 +29,7 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/tinker" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/ui" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/league/flysystem" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/maximebf/debugbar" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/mockery/mockery" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/monolog/monolog" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/myclabs/deep-copy" />
|
||||
|
@ -88,6 +88,11 @@
|
||||
<path value="$PROJECT_DIR$/vendor/facade/ignition-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/league/flysystem" />
|
||||
<path value="$PROJECT_DIR$/vendor/nesbot/carbon" />
|
||||
<path value="$PROJECT_DIR$/vendor/cocur/slugify" />
|
||||
<path value="$PROJECT_DIR$/vendor/cviebrock/eloquent-sluggable" />
|
||||
<path value="$PROJECT_DIR$/vendor/davejamesmiller/laravel-breadcrumbs" />
|
||||
<path value="$PROJECT_DIR$/vendor/maximebf/debugbar" />
|
||||
<path value="$PROJECT_DIR$/vendor/barryvdh/laravel-debugbar" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="7.2" />
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
91
Library/app/Http/Controllers/BookController.php
Normal file
91
Library/app/Http/Controllers/BookController.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\BookRequest;
|
||||
use App\Models\Book;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class BookController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->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()]);
|
||||
|
||||
}
|
||||
}
|
@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
24
Library/app/Http/Controllers/UserController.php
Normal file
24
Library/app/Http/Controllers/UserController.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('UserPermission', ['only' => ['edit', 'update', 'destroy']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(User $user)
|
||||
{
|
||||
return view('user.show', [
|
||||
'user' => $user->load('books'),
|
||||
]);
|
||||
}
|
||||
}
|
@ -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,
|
||||
|
21
Library/app/Http/Middleware/BookPermission.php
Normal file
21
Library/app/Http/Middleware/BookPermission.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class BookPermission
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!Auth::check() || $request->book->user_id != Auth::id()) {
|
||||
abort(403, 'Access denied');
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
33
Library/app/Http/Request/BookRequest.php
Normal file
33
Library/app/Http/Request/BookRequest.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class BookRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'photo' => 'max:1500|required',
|
||||
'name' => 'string|max:100',
|
||||
'description' => 'required|string|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
45
Library/app/Models/Book.php
Normal file
45
Library/app/Models/Book.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Book extends Model
|
||||
{
|
||||
use Sluggable;
|
||||
|
||||
public function getRouteKeyName()
|
||||
{
|
||||
return 'slug';
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id', 'photo', 'name', 'description',
|
||||
];
|
||||
|
||||
/**
|
||||
* Return the sluggable configuration array for this model.
|
||||
*/
|
||||
public function sluggable()
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(Comment::class);
|
||||
}
|
||||
}
|
26
Library/app/Models/Comment.php
Normal file
26
Library/app/Models/Comment.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Comment extends Model
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'book_id', 'user_id', 'comment', 'edited_at',
|
||||
];
|
||||
|
||||
public function book()
|
||||
{
|
||||
return $this->belongsTo(Book::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
}
|
74
Library/app/Models/User.php
Normal file
74
Library/app/Models/User.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Notifiable, Sluggable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'avatar', 'avatar_rating', 'user_verified_at', 'name', 'email', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => '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;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
}
|
@ -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",
|
||||
|
406
Library/composer.lock
generated
406
Library/composer.lock
generated
@ -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",
|
||||
|
@ -68,7 +68,7 @@ return [
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\User::class,
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
|
@ -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');
|
||||
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBooksTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('books', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCommentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('comments', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 19 KiB |
2
Library/resources/js/facedatection.js
vendored
2
Library/resources/js/facedatection.js
vendored
@ -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) {
|
||||
|
4
Library/resources/sass/app.scss
vendored
4
Library/resources/sass/app.scss
vendored
@ -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';
|
||||
|
5
Library/resources/sass/sections/book.scss
vendored
Normal file
5
Library/resources/sass/sections/book.scss
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.book{
|
||||
img{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
10
Library/resources/sass/sections/books.scss
vendored
Normal file
10
Library/resources/sass/sections/books.scss
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
.books{
|
||||
img{
|
||||
width: 100%;
|
||||
}
|
||||
h2 {
|
||||
font-size: 20px;
|
||||
margin: 20px 0 0 0;
|
||||
color: #000000
|
||||
}
|
||||
}
|
10
Library/resources/sass/sections/user.scss
vendored
Normal file
10
Library/resources/sass/sections/user.scss
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
.profile {
|
||||
img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 20px;
|
||||
margin: 20px 0 0 0;
|
||||
}
|
||||
}
|
27
Library/resources/sass/sections/users.scss
vendored
Normal file
27
Library/resources/sass/sections/users.scss
vendored
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
<div class="card">
|
||||
<div class="card-header">{{ __('Register') }}</div>
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ route('register') }}">
|
||||
<form method="POST" action="{{ route('register') }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="card-opencv">
|
||||
<div class="row">
|
||||
@ -33,7 +33,7 @@
|
||||
class="col-md-4 col-form-label text-md-right">Avatar</label>
|
||||
<div class="col-md-6">
|
||||
<input type="file" name="avatar" id="fileInput" class="@error('avatar') is-invalid @enderror">
|
||||
<input type="hidden" name="avatar_rating" id="avatarRating">
|
||||
<input type="hidden" name="avatar_rating" id="avatarRating" value="0">
|
||||
<div class="invalid-feedback" id="imageInvalidFeedback" role="alert"></div>
|
||||
<div class="massage-alert-primary" id="massageAlertPrimary" role="alert"></div>
|
||||
</div>
|
||||
|
68
Library/resources/views/book/create.blade.php
Normal file
68
Library/resources/views/book/create.blade.php
Normal file
@ -0,0 +1,68 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">{{ __('Register') }}</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('book.store') }}" method="POST" enctype="multipart/form-data">
|
||||
{{csrf_field()}}
|
||||
{{method_field('POST')}}
|
||||
|
||||
<div class="col-12">
|
||||
<div class="row form-group{{ $errors->has('photo') ? ' has-error' : '' }}">
|
||||
<label for="photo"
|
||||
class="col-md-4 col-form-label text-md-right">Photo</label>
|
||||
<div class="col-md-6">
|
||||
<input type="file" name="photo" value="">
|
||||
@if ($errors->has('photo'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('photo') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row form-group{{ $errors->has('name') ? ' has-error' : '' }}">
|
||||
<label for="name"
|
||||
class="col-md-4 col-form-label text-md-right">Name</label>
|
||||
<div class="col-md-6">
|
||||
<input type="text" class="form-control" name="name" value="{{ old('name') }}">
|
||||
@if ($errors->has('name'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('name') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row form-group{{ $errors->has('description') ? ' has-error' : '' }}">
|
||||
<label for="description"
|
||||
class="col-md-4 col-form-label text-md-right">Description</label>
|
||||
<div class="col-md-6">
|
||||
<textarea class="form-control" name="description" value="" cols="10"
|
||||
rows="5">{{ old('description') }}</textarea>
|
||||
@if ($errors->has('description'))
|
||||
<span class="help-block">
|
||||
<strong>{{ $errors->first('description') }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mb-0">
|
||||
<div class="col-md-6 offset-md-4">
|
||||
<button type="submit" class="btn btn-primary pull-right">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
39
Library/resources/views/book/show.blade.php
Normal file
39
Library/resources/views/book/show.blade.php
Normal file
@ -0,0 +1,39 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<section id="breadcrumbs">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{{ Breadcrumbs::render('book', $book) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="book">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<div class="card book">
|
||||
<div class="card-header">Book</div>
|
||||
<div class="card-body">
|
||||
<img src="{{ url(Storage::url($book->photo)) }}" alt="">
|
||||
<h1>{{$book->name}}</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card profile">
|
||||
<div class="card-header">User</div>
|
||||
<div class="card-body">
|
||||
<a href="{{route('user.show', $book->user)}}">
|
||||
<img src="{{$book->user->userAvatar()}}" alt="">
|
||||
<h1>{{$book->user->name}}</h1>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
@ -1,23 +1,42 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">Dashboard</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success" role="alert">
|
||||
{{ session('status') }}
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card books">
|
||||
<div class="card-header">New books</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
@foreach($books as $book)
|
||||
<div class="col-md-4">
|
||||
<a href="{{ route('book.show', $book) }}">
|
||||
<img src="{{ url(Storage::url($book->photo)) }}" alt="">
|
||||
<h2>{{ $book->name }}</h2>
|
||||
</a>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
You are logged in!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card users">
|
||||
<div class="card-header">New users</div>
|
||||
<div class="card-body">
|
||||
<ul>
|
||||
@foreach($users as $user)
|
||||
<li>
|
||||
<a href="{{route('user.show', $user)}}">
|
||||
<img src="{{$user->userAvatar()}}" alt="">
|
||||
<p>{{$user->name}}</p>
|
||||
</a>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
@ -46,11 +46,13 @@
|
||||
</li>
|
||||
@endif
|
||||
@else
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('book.create') }}">Add book</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
|
||||
{{ Auth::user()->name }} <span class="caret"></span>
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
|
||||
<a class="dropdown-item" href="{{ route('logout') }}"
|
||||
onclick="event.preventDefault();
|
||||
|
33
Library/resources/views/user/layout.blade.php
Normal file
33
Library/resources/views/user/layout.blade.php
Normal file
@ -0,0 +1,33 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
|
||||
<section id="breadcrumbs">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{{ Breadcrumbs::render('user', $user) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="user">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="card profile">
|
||||
<div class="card-header">User</div>
|
||||
<div class="card-body">
|
||||
<img src="{{$user->userAvatar()}}" alt="">
|
||||
<h1>{{$user->name}}</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
@yield('user-content')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
20
Library/resources/views/user/show.blade.php
Normal file
20
Library/resources/views/user/show.blade.php
Normal file
@ -0,0 +1,20 @@
|
||||
@extends('user.layout')
|
||||
|
||||
@section('user-content')
|
||||
<div class="card comments">
|
||||
<div class="card-header">Books</div>
|
||||
<div class="card-body books">
|
||||
<div class="row">
|
||||
@foreach($user->books as $book)
|
||||
<div class="col-md-4">
|
||||
<a href="{{ route('book.show', $book) }}">
|
||||
<img src="{{ url(Storage::url($book->photo)) }}" alt="">
|
||||
<h2>{{ $book->name }}</h2>
|
||||
</a>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
18
Library/routes/breadcrumbs.php
Normal file
18
Library/routes/breadcrumbs.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
// Home
|
||||
Breadcrumbs::for('home', function ($trail) {
|
||||
$trail->push('Home', route('home'));
|
||||
});
|
||||
|
||||
// Home > [User]
|
||||
Breadcrumbs::for('user', function ($trail, $user) {
|
||||
$trail->parent('home');
|
||||
$trail->push($user->name, route('user.show', $user));
|
||||
});
|
||||
|
||||
// Home > [User] > [Book]
|
||||
Breadcrumbs::for('book', function ($trail, $book) {
|
||||
$trail->parent('user', $book->user);
|
||||
$trail->push($book->name, route('book.show', $book));
|
||||
});
|
@ -11,10 +11,22 @@
|
||||
|
|
||||
*/
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
Auth::routes();
|
||||
|
||||
Route::get('/home', 'HomeController@index')->name('home');
|
||||
Route::get('/', 'HomeController@index')->name('home');
|
||||
|
||||
Route::group(['prefix' => 'user', 'as' => 'user.'], function () {
|
||||
Route::get('/{user}', 'UserController@show')->name('show');
|
||||
Route::patch('/{user}', 'UserController@update')->name('update');
|
||||
Route::delete('/{user}', 'UserController@destroy')->name('destroy');
|
||||
Route::get('/{user}/edit', 'UserController@edit')->name('edit');
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'book', 'as' => 'book.'], function () {
|
||||
Route::post('/', 'BookController@store')->name('store');
|
||||
Route::get('/create', 'BookController@create')->name('create');
|
||||
Route::get('/{book}', 'BookController@show')->name('show');
|
||||
Route::patch('/{book}', 'BookController@update')->name('update');
|
||||
Route::delete('/{book}', 'BookController@destroy')->name('destroy');
|
||||
Route::get('/{book}/edit', 'BookController@edit')->name('edit');
|
||||
});
|
||||
|
2
Library/storage/debugbar/.gitignore
vendored
Normal file
2
Library/storage/debugbar/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
Loading…
Reference in New Issue
Block a user