From 54b1af2c068bf1193eb8a8f034f1986e382d1cad Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Mon, 15 Apr 2019 15:57:13 -0300 Subject: [PATCH 01/25] =?UTF-8?q?Conexi=C3=B3n=20SQL,=20Creaci=C3=B3n=20DB?= =?UTF-8?q?=20+=20Tabla=20seed=20con=20usuario=20por=20defecto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Providers/AppServiceProvider.php | 3 ++- database/seeds/DatabaseSeeder.php | 2 +- database/seeds/UsersTableSeeder.php | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 database/seeds/UsersTableSeeder.php diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index ee8ca5bc..9242dee7 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; +use Illuminate\Support\Facades\Schema; class AppServiceProvider extends ServiceProvider { @@ -23,6 +24,6 @@ public function register() */ public function boot() { - // + Schema::defaultStringLength(191); } } diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 91cb6d1c..dcfdf4c1 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -11,6 +11,6 @@ class DatabaseSeeder extends Seeder */ public function run() { - // $this->call(UsersTableSeeder::class); + $this->call(UsersTableSeeder::class); } } diff --git a/database/seeds/UsersTableSeeder.php b/database/seeds/UsersTableSeeder.php new file mode 100644 index 00000000..eb39a8e0 --- /dev/null +++ b/database/seeds/UsersTableSeeder.php @@ -0,0 +1,20 @@ +insert([ + 'name' => 'fritz', + 'email' => 'fritz@gmail.com', + 'password' => bcrypt('12345678'), + ]); + } +} From 9d2569a8949d2117967a6b5136375944c14e747b Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Mon, 15 Apr 2019 16:13:04 -0300 Subject: [PATCH 02/25] =?UTF-8?q?Creaci=C3=B3n=20autenticaci=C3=B3n=20Lara?= =?UTF-8?q?vel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Book.php | 10 +++ app/Http/Controllers/BookController.php | 85 +++++++++++++++++++ app/Http/Controllers/HomeController.php | 28 ++++++ database/factories/BookFactory.php | 9 ++ .../2019_04_15_185930_create_books_table.php | 31 +++++++ resources/views/auth/login.blade.php | 73 ++++++++++++++++ .../views/auth/passwords/email.blade.php | 47 ++++++++++ .../views/auth/passwords/reset.blade.php | 65 ++++++++++++++ resources/views/auth/register.blade.php | 77 +++++++++++++++++ resources/views/auth/verify.blade.php | 24 ++++++ resources/views/home.blade.php | 23 +++++ resources/views/layouts/app.blade.php | 80 +++++++++++++++++ routes/web.php | 4 + 13 files changed, 556 insertions(+) create mode 100644 app/Book.php create mode 100644 app/Http/Controllers/BookController.php create mode 100644 app/Http/Controllers/HomeController.php create mode 100644 database/factories/BookFactory.php create mode 100644 database/migrations/2019_04_15_185930_create_books_table.php create mode 100644 resources/views/auth/login.blade.php create mode 100644 resources/views/auth/passwords/email.blade.php create mode 100644 resources/views/auth/passwords/reset.blade.php create mode 100644 resources/views/auth/register.blade.php create mode 100644 resources/views/auth/verify.blade.php create mode 100644 resources/views/home.blade.php create mode 100644 resources/views/layouts/app.blade.php diff --git a/app/Book.php b/app/Book.php new file mode 100644 index 00000000..c82a08c7 --- /dev/null +++ b/app/Book.php @@ -0,0 +1,10 @@ +middleware('auth'); + } + + /** + * Show the application dashboard. + * + * @return \Illuminate\Contracts\Support\Renderable + */ + public function index() + { + return view('home'); + } +} diff --git a/database/factories/BookFactory.php b/database/factories/BookFactory.php new file mode 100644 index 00000000..457d93e0 --- /dev/null +++ b/database/factories/BookFactory.php @@ -0,0 +1,9 @@ +define(App\Book::class, function (Faker $faker) { + return [ + // + ]; +}); diff --git a/database/migrations/2019_04_15_185930_create_books_table.php b/database/migrations/2019_04_15_185930_create_books_table.php new file mode 100644 index 00000000..fb0d615d --- /dev/null +++ b/database/migrations/2019_04_15_185930_create_books_table.php @@ -0,0 +1,31 @@ +bigIncrements('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('books'); + } +} diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php new file mode 100644 index 00000000..9edb920e --- /dev/null +++ b/resources/views/auth/login.blade.php @@ -0,0 +1,73 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Login') }}
+ +
+
+ @csrf + +
+ + +
+ + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif +
+
+ +
+
+
+ + + +
+
+
+ +
+
+ + + @if (Route::has('password.request')) + + {{ __('Forgot Your Password?') }} + + @endif +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/auth/passwords/email.blade.php b/resources/views/auth/passwords/email.blade.php new file mode 100644 index 00000000..ccbee595 --- /dev/null +++ b/resources/views/auth/passwords/email.blade.php @@ -0,0 +1,47 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Reset Password') }}
+ +
+ @if (session('status')) + + @endif + +
+ @csrf + +
+ + +
+ + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif +
+
+ +
+
+ +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/auth/passwords/reset.blade.php b/resources/views/auth/passwords/reset.blade.php new file mode 100644 index 00000000..bf27f4c8 --- /dev/null +++ b/resources/views/auth/passwords/reset.blade.php @@ -0,0 +1,65 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Reset Password') }}
+ +
+
+ @csrf + + + +
+ + +
+ + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif +
+
+ +
+ + +
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php new file mode 100644 index 00000000..ad95f2cf --- /dev/null +++ b/resources/views/auth/register.blade.php @@ -0,0 +1,77 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Register') }}
+ +
+
+ @csrf + +
+ + +
+ + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif +
+
+ +
+ + +
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/auth/verify.blade.php b/resources/views/auth/verify.blade.php new file mode 100644 index 00000000..c742cb4b --- /dev/null +++ b/resources/views/auth/verify.blade.php @@ -0,0 +1,24 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Verify Your Email Address') }}
+ +
+ @if (session('resent')) + + @endif + + {{ __('Before proceeding, please check your email for a verification link.') }} + {{ __('If you did not receive the email') }}, {{ __('click here to request another') }}. +
+
+
+
+
+@endsection diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php new file mode 100644 index 00000000..05dfca92 --- /dev/null +++ b/resources/views/home.blade.php @@ -0,0 +1,23 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Dashboard
+ +
+ @if (session('status')) + + @endif + + You are logged in! +
+
+
+
+
+@endsection diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php new file mode 100644 index 00000000..ee7767c4 --- /dev/null +++ b/resources/views/layouts/app.blade.php @@ -0,0 +1,80 @@ + + + + + + + + + + {{ config('app.name', 'Laravel') }} + + + + + + + + + + + + +
+ + +
+ @yield('content') +
+
+ + diff --git a/routes/web.php b/routes/web.php index 810aa349..12fc04c0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -14,3 +14,7 @@ Route::get('/', function () { return view('welcome'); }); + +Auth::routes(); + +Route::get('/home', 'HomeController@index')->name('home'); From 115a9a6df18709453d8cffb664fb9216c58d4e1d Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Mon, 15 Apr 2019 17:33:39 -0300 Subject: [PATCH 03/25] =?UTF-8?q?Creaci=C3=B3n=20de=20la=20tabla=20para=20?= =?UTF-8?q?la=20entidad,=20vista=20para=20registrar=20la=20entidad.=20Mens?= =?UTF-8?q?aje=20de=20=C3=A9xito=20al=20guardar=20entidad.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/BookController.php | 21 +++++- .../2019_04_15_185930_create_books_table.php | 5 ++ resources/views/book/create.blade.php | 75 +++++++++++++++++++ routes/web.php | 2 + 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 resources/views/book/create.blade.php diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 7a08d8d1..413b0830 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -4,9 +4,17 @@ use App\Book; use Illuminate\Http\Request; +use Auth; class BookController extends Controller { + + public function __construct() + { + + $this->middleware('auth'); + } + /** * Display a listing of the resource. * @@ -24,7 +32,7 @@ public function index() */ public function create() { - // + return view('book.create'); } /** @@ -35,7 +43,16 @@ public function create() */ public function store(Request $request) { - // + $book = New Book(); + + $book->name=$request->name; + $book->author=$request->author; + $book->isbn=$request->ISBN; + $book->user_id = Auth::user()->id; + + if ($book->save()) { + return redirect()->route('book.create')->with('status', 'Éxito'); + } } /** diff --git a/database/migrations/2019_04_15_185930_create_books_table.php b/database/migrations/2019_04_15_185930_create_books_table.php index fb0d615d..7b650661 100644 --- a/database/migrations/2019_04_15_185930_create_books_table.php +++ b/database/migrations/2019_04_15_185930_create_books_table.php @@ -15,7 +15,12 @@ public function up() { Schema::create('books', function (Blueprint $table) { $table->bigIncrements('id'); + $table->string('name'); + $table->string('author'); + $table->string('isbn'); + $table->bigInteger('user_id'); $table->timestamps(); + }); } diff --git a/resources/views/book/create.blade.php b/resources/views/book/create.blade.php new file mode 100644 index 00000000..7f83d112 --- /dev/null +++ b/resources/views/book/create.blade.php @@ -0,0 +1,75 @@ +@extends('layouts.app') + +@section('content') +
+
+
+ @if (session('status')) + + @endif + +
+
{{ __('Agregar Libro') }}
+ +
+
+ @csrf + +
+ + +
+ + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('author')) + + {{ $errors->first('author') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('ISBN')) + + {{ $errors->first('ISBN') }} + + @endif +
+
+ +
+
+ +
+
+
+
+
+
+
+
+@endsection diff --git a/routes/web.php b/routes/web.php index 12fc04c0..8dd8ab56 100644 --- a/routes/web.php +++ b/routes/web.php @@ -18,3 +18,5 @@ Auth::routes(); Route::get('/home', 'HomeController@index')->name('home'); + +Route::resource('/book', 'BookController'); From 9a44f4ae79cb33d14a902de968f63788e6e6acf4 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Mon, 15 Apr 2019 18:25:17 -0300 Subject: [PATCH 04/25] Listar libros, index libros --- app/Http/Controllers/BookController.php | 27 +++++++++++++-- resources/views/book/index.blade.php | 44 +++++++++++++++++++++++++ resources/views/book/list.blade.php | 44 +++++++++++++++++++++++++ routes/web.php | 1 + 4 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 resources/views/book/index.blade.php create mode 100644 resources/views/book/list.blade.php diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 413b0830..07069f5f 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -22,7 +22,22 @@ public function __construct() */ public function index() { - // + $books = Book::all(); + + $data['books'] = $books; + + return view('book.index', $data); + } + + public function list($id) + { + + $books = Book::where('user_id', $id)->get(); + + $data['books'] = $books; + + return view('book.index', $data); + } /** @@ -86,7 +101,15 @@ public function edit(Book $book) */ public function update(Request $request, Book $book) { - // + $book = Book::find($book); + + $book->name=$request->name; + $book->author=$request->author; + $book->isbn=$request->ISBN; + + if ($book->save()) { + return redirect()->route('book.update')->with('status', 'Éxito'); + } } /** diff --git a/resources/views/book/index.blade.php b/resources/views/book/index.blade.php new file mode 100644 index 00000000..2b53c48c --- /dev/null +++ b/resources/views/book/index.blade.php @@ -0,0 +1,44 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Lista de Libros
+ +
+ @if (session('status')) + + @endif + + + + + + + + + + + @foreach($books as $book) + + + + + + + + + @endforeach + + +
IDNombreAutorISBNUsuario IDFecha de creación
{{ $book->id }}{{ $book->name }}{{ $book->author }}{{ $book->isbn }}{{ $book->user_id }}{{ $book->created_at}}
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/book/list.blade.php b/resources/views/book/list.blade.php new file mode 100644 index 00000000..1da44482 --- /dev/null +++ b/resources/views/book/list.blade.php @@ -0,0 +1,44 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Dashboard
+ +
+ @if (session('status')) + + @endif + + + + + + + + + + + @foreach($books as $book) + + + + + + + + + @endforeach + + +
IDNombreAutorISBNUsuario IDFecha de creación
{{ $book->id }}{{ $book->name }}{{ $book->author }}{{ $book->isbn }}{{ $book->user_id }}{{ $book->created_at}}
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 8dd8ab56..4c33bcaf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -20,3 +20,4 @@ Route::get('/home', 'HomeController@index')->name('home'); Route::resource('/book', 'BookController'); +Route::get('/book/list/{id}', 'BookController@list'); From 1eedec87cdedea817be31b4f20255edffb0856d6 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Thu, 18 Apr 2019 20:29:51 -0300 Subject: [PATCH 05/25] - add model Lista, view Lista, ListController. - add Middleware CheckBookPrivacy. - add Relationships --- app/Http/Controllers/BookController.php | 12 +- app/Http/Controllers/ListaController.php | 112 +++++++++++++ app/Http/Kernel.php | 1 + app/Http/Middleware/CheckBookPrivacy.php | 31 ++++ app/Lista.php | 16 ++ database/factories/ListaFactory.php | 9 ++ .../2019_04_15_185930_create_books_table.php | 2 +- .../2019_04_17_163337_create_listas_table.php | 34 ++++ resources/views/book/create.blade.php | 4 +- resources/views/layouts/app.blade.php | 64 ++++---- resources/views/lista/create.blade.php | 53 +++++++ resources/views/lista/index.blade.php | 42 +++++ resources/views/template.blade.php | 22 +++ resources/views/welcome.blade.php | 147 ++++++------------ routes/web.php | 10 +- 15 files changed, 414 insertions(+), 145 deletions(-) create mode 100644 app/Http/Controllers/ListaController.php create mode 100644 app/Http/Middleware/CheckBookPrivacy.php create mode 100644 app/Lista.php create mode 100644 database/factories/ListaFactory.php create mode 100644 database/migrations/2019_04_17_163337_create_listas_table.php create mode 100644 resources/views/lista/create.blade.php create mode 100644 resources/views/lista/index.blade.php create mode 100644 resources/views/template.blade.php diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 07069f5f..20c0502f 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -29,17 +29,7 @@ public function index() return view('book.index', $data); } - public function list($id) - { - - $books = Book::where('user_id', $id)->get(); - - $data['books'] = $books; - - return view('book.index', $data); - - } - + /** * Show the form for creating a new resource. * diff --git a/app/Http/Controllers/ListaController.php b/app/Http/Controllers/ListaController.php new file mode 100644 index 00000000..02b20a7b --- /dev/null +++ b/app/Http/Controllers/ListaController.php @@ -0,0 +1,112 @@ +middleware('auth'); + + $this->middleware('book.privacy')->only('show'); + } + + /** + * Display a listing of the resource. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + + $lista = Lista::all(); + + return $lista; + + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + return view('lista.create'); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $lista = New Lista(); + + $lista->name=$request->name; + //$lista->description=$request->description; + $lista->user_id = Auth::user()->id; + + if ($lista->save()) { + return redirect()->route('lista.create')->with('status', 'Éxito'); + } + } + + /** + * Display the specified resource. + * + * @param \App\lista $lista + * @return \Illuminate\Http\Response + */ + public function show($lista) + { + $lista = Lista::find($lista); + $name = $lista->name; + $books = $lista->book; + + $data['name'] = $name; + $data['books'] = $books; + + return view('lista.index', $data); + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\lista $lista + * @return \Illuminate\Http\Response + */ + public function edit(lista $lista) + { + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\lista $lista + * @return \Illuminate\Http\Response + */ + public function update(Request $request, lista $lista) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param \App\lista $lista + * @return \Illuminate\Http\Response + */ + public function destroy(lista $lista) + { + // + } +} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index a3d8c48d..bc715f02 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -60,6 +60,7 @@ class Kernel extends HttpKernel 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + 'book.privacy' => \App\Http\Middleware\CheckBookPrivacy::class ]; /** diff --git a/app/Http/Middleware/CheckBookPrivacy.php b/app/Http/Middleware/CheckBookPrivacy.php new file mode 100644 index 00000000..2862d849 --- /dev/null +++ b/app/Http/Middleware/CheckBookPrivacy.php @@ -0,0 +1,31 @@ +route()->parameter('list'); + $lista = Lista::find($id); + + if($lista->public_list==0){ + + return redirect()->route('home'); + } + + + return $next($request); + } +} diff --git a/app/Lista.php b/app/Lista.php new file mode 100644 index 00000000..1c6aafce --- /dev/null +++ b/app/Lista.php @@ -0,0 +1,16 @@ +hasMany('App\Book', 'list_id'); + } +} diff --git a/database/factories/ListaFactory.php b/database/factories/ListaFactory.php new file mode 100644 index 00000000..cb6e17c1 --- /dev/null +++ b/database/factories/ListaFactory.php @@ -0,0 +1,9 @@ +define(App\lista::class, function (Faker $faker) { + return [ + // + ]; +}); diff --git a/database/migrations/2019_04_15_185930_create_books_table.php b/database/migrations/2019_04_15_185930_create_books_table.php index 7b650661..2d4d24d5 100644 --- a/database/migrations/2019_04_15_185930_create_books_table.php +++ b/database/migrations/2019_04_15_185930_create_books_table.php @@ -18,7 +18,7 @@ public function up() $table->string('name'); $table->string('author'); $table->string('isbn'); - $table->bigInteger('user_id'); + $table->bigInteger('list_id'); $table->timestamps(); }); diff --git a/database/migrations/2019_04_17_163337_create_listas_table.php b/database/migrations/2019_04_17_163337_create_listas_table.php new file mode 100644 index 00000000..8188fa5b --- /dev/null +++ b/database/migrations/2019_04_17_163337_create_listas_table.php @@ -0,0 +1,34 @@ +bigIncrements('id'); + $table->string('name'); + $table->bigInteger('user_id'); + $table->bigInteger('public_list')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('listas'); + } +} diff --git a/resources/views/book/create.blade.php b/resources/views/book/create.blade.php index 7f83d112..daacc010 100644 --- a/resources/views/book/create.blade.php +++ b/resources/views/book/create.blade.php @@ -35,7 +35,7 @@
- + @if ($errors->has('author')) @@ -49,7 +49,7 @@
- + @if ($errors->has('ISBN')) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index ee7767c4..6b12dd16 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -7,7 +7,7 @@ - {{ config('app.name', 'Laravel') }} + @yield('title') @@ -40,41 +40,41 @@ -
+ +
+ + @endguest + - + + -
- @yield('content') -
- +
+ @yield('content') +
+ diff --git a/resources/views/lista/create.blade.php b/resources/views/lista/create.blade.php new file mode 100644 index 00000000..d1be83aa --- /dev/null +++ b/resources/views/lista/create.blade.php @@ -0,0 +1,53 @@ +@extends('layouts.app') + +@section('content') +
+
+
+ @if (session('status')) + + @endif + +
+
{{ __('Agregar Lista') }}
+ +
+
+ @csrf + +
+ + +
+ + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif +
+
+ + + + + + + +
+
+ +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/lista/index.blade.php b/resources/views/lista/index.blade.php new file mode 100644 index 00000000..c31a3e3d --- /dev/null +++ b/resources/views/lista/index.blade.php @@ -0,0 +1,42 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Lista: {{$name}}
+ +
+ @if (session('status')) + + @endif + + + + + + + + + + @foreach($books as $book) + + + + + + + + @endforeach + + +
ID LibroNombreAutorISBN¿Es pública?
{{ $book->id }}{{ $book->name }}{{ $book->author }}{{ $book->isbn }}{{ ($book->public_list ==0) ? 'No' : 'Sí' }}
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/template.blade.php b/resources/views/template.blade.php new file mode 100644 index 00000000..cc650f7f --- /dev/null +++ b/resources/views/template.blade.php @@ -0,0 +1,22 @@ + + + + + + + + + + + Hello, world! + + +

Hello, world!

+ + + + + + + + \ No newline at end of file diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 044b874c..edf01639 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -1,99 +1,50 @@ - - - - - - Laravel - - - - - - - - -
- @if (Route::has('login')) - - @endif - -
-
- Laravel -
- - -
-
- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 4c33bcaf..f3204393 100644 --- a/routes/web.php +++ b/routes/web.php @@ -12,7 +12,7 @@ */ Route::get('/', function () { - return view('welcome'); + return view('layouts/app'); }); Auth::routes(); @@ -21,3 +21,11 @@ Route::resource('/book', 'BookController'); Route::get('/book/list/{id}', 'BookController@list'); + +Route::resource('/list', 'ListaController'); + + + +Route::get('/template', function () { + return view('template'); +}); \ No newline at end of file From 2898b12418d9b6be60b7f1c7252d0b5570741566 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 23 Apr 2019 14:26:28 -0300 Subject: [PATCH 06/25] Fix list.create --- app/Http/Controllers/ListaController.php | 2 +- routes/web.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ListaController.php b/app/Http/Controllers/ListaController.php index 02b20a7b..b9e58ba6 100644 --- a/app/Http/Controllers/ListaController.php +++ b/app/Http/Controllers/ListaController.php @@ -55,7 +55,7 @@ public function store(Request $request) $lista->user_id = Auth::user()->id; if ($lista->save()) { - return redirect()->route('lista.create')->with('status', 'Éxito'); + return redirect()->route('list.create')->with('status', 'Éxito'); } } diff --git a/routes/web.php b/routes/web.php index f3204393..4d1fc210 100644 --- a/routes/web.php +++ b/routes/web.php @@ -26,6 +26,7 @@ + Route::get('/template', function () { return view('template'); }); \ No newline at end of file From 9d594936d474114b753a152b1aeb3b2a150872d6 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 23 Apr 2019 23:16:04 -0300 Subject: [PATCH 07/25] add bookRequest, update checkBookPrivacy, add book.update, edit book.store, edit views, update routes, add list.updates, add list.showAll, fix migrations (books). --- app/Http/Controllers/BookController.php | 19 +++++- app/Http/Controllers/ListaController.php | 46 ++++++++++++-- app/Http/Middleware/CheckBookPrivacy.php | 3 +- app/Http/Requests/BookRequest.php | 31 ++++++++++ app/User.php | 5 ++ .../2019_04_15_185930_create_books_table.php | 1 + resources/views/book/create.blade.php | 26 ++++++-- resources/views/lista/edit.blade.php | 61 +++++++++++++++++++ resources/views/lista/index.blade.php | 4 +- resources/views/lista/publicLists.blade.php | 32 ++++++++++ routes/web.php | 3 +- 11 files changed, 214 insertions(+), 17 deletions(-) create mode 100644 app/Http/Requests/BookRequest.php create mode 100644 resources/views/lista/edit.blade.php create mode 100644 resources/views/lista/publicLists.blade.php diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 20c0502f..07001346 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -3,8 +3,10 @@ namespace App\Http\Controllers; use App\Book; +use App\Lista; use Illuminate\Http\Request; use Auth; +use App\Http\Requests\BookRequest; class BookController extends Controller { @@ -37,7 +39,17 @@ public function index() */ public function create() { - return view('book.create'); + + $lists = Auth::user()->list()->get(); + + if($lists) { + $data['lists'] = $lists; + } else { + $data['lists'] = []; + } + + + return view('book.create', $data); } /** @@ -46,14 +58,15 @@ public function create() * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ - public function store(Request $request) + public function store(BookRequest $request) { $book = New Book(); $book->name=$request->name; $book->author=$request->author; - $book->isbn=$request->ISBN; + $book->isbn=$request->isbn; $book->user_id = Auth::user()->id; + $book->list_id=$request->list_id; if ($book->save()) { return redirect()->route('book.create')->with('status', 'Éxito'); diff --git a/app/Http/Controllers/ListaController.php b/app/Http/Controllers/ListaController.php index b9e58ba6..92d83830 100644 --- a/app/Http/Controllers/ListaController.php +++ b/app/Http/Controllers/ListaController.php @@ -5,6 +5,7 @@ use App\Lista; use Illuminate\Http\Request; use Auth; +use App\User; class ListaController extends Controller { @@ -28,6 +29,17 @@ public function index() return $lista; + } + + public function publicLists($userid) + { + + $lists = User::find($userid)->list()->where('public_list', 1)->get(); + + $data['lists'] = $lists; + + return view('lista.publicLists', $data); + } /** @@ -50,8 +62,7 @@ public function store(Request $request) { $lista = New Lista(); - $lista->name=$request->name; - //$lista->description=$request->description; + $lista->name = $request->name; $lista->user_id = Auth::user()->id; if ($lista->save()) { @@ -70,21 +81,37 @@ public function show($lista) $lista = Lista::find($lista); $name = $lista->name; $books = $lista->book; + $public_list = $lista->public_list; $data['name'] = $name; $data['books'] = $books; + $data['is_public'] = $public_list; return view('lista.index', $data); } + public function showAll() + { + $lista = Lista::all(); + + return show($lista); + } + /** * Show the form for editing the specified resource. * * @param \App\lista $lista * @return \Illuminate\Http\Response */ - public function edit(lista $lista) + public function edit($lista) { + + $list = Lista::find($lista)->first(); + + $data['list'] = $list; + + return view('lista.edit', $data); + } /** @@ -94,9 +121,18 @@ public function edit(lista $lista) * @param \App\lista $lista * @return \Illuminate\Http\Response */ - public function update(Request $request, lista $lista) + public function update(Request $request, $lista) { - // + $list = Lista::find($lista); + + $list->name = $request->name; + $list->public_list = $request->public_list; + $list->user_id = Auth::user()->id; + + if ($list->save()) { + return redirect()->route('list.edit', ['id' => $list->id])->with('status', 'Éxito'); + } + } /** diff --git a/app/Http/Middleware/CheckBookPrivacy.php b/app/Http/Middleware/CheckBookPrivacy.php index 2862d849..14a215ec 100644 --- a/app/Http/Middleware/CheckBookPrivacy.php +++ b/app/Http/Middleware/CheckBookPrivacy.php @@ -4,6 +4,7 @@ use Closure; use App\Lista; +use Auth; class CheckBookPrivacy @@ -20,7 +21,7 @@ public function handle($request, Closure $next) $id = $request->route()->parameter('list'); $lista = Lista::find($id); - if($lista->public_list==0){ + if(Auth::user()->id !== $lista->user_id && $lista->public_list==0){ return redirect()->route('home'); } diff --git a/app/Http/Requests/BookRequest.php b/app/Http/Requests/BookRequest.php new file mode 100644 index 00000000..4c9381ab --- /dev/null +++ b/app/Http/Requests/BookRequest.php @@ -0,0 +1,31 @@ + 'required|min:3|max:255', + 'list_id' => 'required|numeric' + ]; + } +} diff --git a/app/User.php b/app/User.php index faa03c3b..23d3a23a 100644 --- a/app/User.php +++ b/app/User.php @@ -36,4 +36,9 @@ class User extends Authenticatable protected $casts = [ 'email_verified_at' => 'datetime', ]; + + public function list() + { + return $this->hasMany('App\Lista', 'user_id'); + } } diff --git a/database/migrations/2019_04_15_185930_create_books_table.php b/database/migrations/2019_04_15_185930_create_books_table.php index 2d4d24d5..b2938807 100644 --- a/database/migrations/2019_04_15_185930_create_books_table.php +++ b/database/migrations/2019_04_15_185930_create_books_table.php @@ -18,6 +18,7 @@ public function up() $table->string('name'); $table->string('author'); $table->string('isbn'); + $table->bigInteger('user_id'); $table->bigInteger('list_id'); $table->timestamps(); diff --git a/resources/views/book/create.blade.php b/resources/views/book/create.blade.php index daacc010..0eeefef5 100644 --- a/resources/views/book/create.blade.php +++ b/resources/views/book/create.blade.php @@ -46,14 +46,32 @@
- +
- + - @if ($errors->has('ISBN')) + @if ($errors->has('isbn')) - {{ $errors->first('ISBN') }} + {{ $errors->first('isbn') }} + + @endif +
+
+ +
+ +
+ + + @if ($errors->has('list_id')) + + {{ $errors->first('list_id') }} @endif
diff --git a/resources/views/lista/edit.blade.php b/resources/views/lista/edit.blade.php new file mode 100644 index 00000000..b621ffa0 --- /dev/null +++ b/resources/views/lista/edit.blade.php @@ -0,0 +1,61 @@ +@extends('layouts.app') + +@section('content') +
+
+
+ @if (session('status')) + + @endif + +
+
{{ __('Editar Lista') }}
+ +
+
+ @csrf + @method('PUT') + +
+ + +
+ + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif +
+ +
+
+ +
+ + + @if ($errors->has('public_list')) + + {{ $errors->first('public_list') }} + + @endif +
+
+ +
+
+ +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/lista/index.blade.php b/resources/views/lista/index.blade.php index c31a3e3d..e8e42140 100644 --- a/resources/views/lista/index.blade.php +++ b/resources/views/lista/index.blade.php @@ -5,7 +5,7 @@
-
Lista: {{$name}}
+
Lista: {{$name}} - {{($is_public ==0) ? 'Lista no Pública' : 'Lista Pública' }}
@if (session('status')) @@ -20,7 +20,6 @@ Nombre Autor ISBN - ¿Es pública? @foreach($books as $book) @@ -28,7 +27,6 @@ {{ $book->name }} {{ $book->author }} {{ $book->isbn }} - {{ ($book->public_list ==0) ? 'No' : 'Sí' }} @endforeach diff --git a/resources/views/lista/publicLists.blade.php b/resources/views/lista/publicLists.blade.php new file mode 100644 index 00000000..22c70df9 --- /dev/null +++ b/resources/views/lista/publicLists.blade.php @@ -0,0 +1,32 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Listas
+ +
+ + + + + + + @foreach($lists as $list) + + + + + + @endforeach + + +
ID ListaNombre
{{ $list->id }}{{ $list->name }}Ver
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 4d1fc210..ca83fbf9 100644 --- a/routes/web.php +++ b/routes/web.php @@ -20,8 +20,9 @@ Route::get('/home', 'HomeController@index')->name('home'); Route::resource('/book', 'BookController'); -Route::get('/book/list/{id}', 'BookController@list'); + +Route::get('user/{userid}/list', 'ListaController@publicLists'); Route::resource('/list', 'ListaController'); From 36512745ff99b3d202d0edbd55297c1a5c6801db Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Sat, 27 Apr 2019 12:00:01 -0300 Subject: [PATCH 08/25] - Edit and update book (controller and views) - Index and indexAll for Lists - Update BookRequest - Update routes - ProfileController created --- app/Http/Controllers/BookController.php | 20 +++-- app/Http/Controllers/ListaController.php | 20 ++++- app/Http/Controllers/ProfileController.php | 84 +++++++++++++++++++ app/Http/Requests/BookRequest.php | 2 + resources/views/book/edit.blade.php | 96 ++++++++++++++++++++++ resources/views/lista/indexAll.blade.php | 32 ++++++++ resources/views/lista/show.blade.php | 40 +++++++++ routes/web.php | 2 + 8 files changed, 287 insertions(+), 9 deletions(-) create mode 100644 app/Http/Controllers/ProfileController.php create mode 100644 resources/views/book/edit.blade.php create mode 100644 resources/views/lista/indexAll.blade.php create mode 100644 resources/views/lista/show.blade.php diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 07001346..c0ba7d67 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -90,9 +90,17 @@ public function show(Book $book) * @param \App\Book $book * @return \Illuminate\Http\Response */ - public function edit(Book $book) + public function edit($libro) { - // + $book = Book::find($libro); + + $lists = Auth::user()->list()->get(); + + $data['lists'] = $lists; + $data['book'] = $book; + + return view('book.edit', $data); + //return $lists; } /** @@ -104,14 +112,16 @@ public function edit(Book $book) */ public function update(Request $request, Book $book) { - $book = Book::find($book); + $book = Book::find($book)->first(); $book->name=$request->name; $book->author=$request->author; - $book->isbn=$request->ISBN; + $book->isbn=$request->isbn; + $book->list_id=$request->list_id; if ($book->save()) { - return redirect()->route('book.update')->with('status', 'Éxito'); + // return redirect()->route('book.update')->with('status', 'Éxito'); + return redirect()->route('book.edit', ['id' => $book->id])->with('status', 'Éxito'); } } diff --git a/app/Http/Controllers/ListaController.php b/app/Http/Controllers/ListaController.php index 92d83830..72c96a42 100644 --- a/app/Http/Controllers/ListaController.php +++ b/app/Http/Controllers/ListaController.php @@ -14,7 +14,8 @@ public function __construct() $this->middleware('auth'); - $this->middleware('book.privacy')->only('show'); + //$this->middleware('book.privacy')->only('show'); + $this->middleware('book.privacy', ['only' => ['show', 'edit','index']]); } /** @@ -24,10 +25,21 @@ public function __construct() */ public function index() { + $listas = Lista::all(); - $lista = Lista::all(); + $data['listas'] = $listas; + + return view('lista.show', $data); + } - return $lista; + public function indexAll($userid) + { + + $lists = User::find($userid)->list()->get(); + + $data['lists'] = $lists; + + return view('lista.indexAll', $data); } @@ -106,7 +118,7 @@ public function showAll() public function edit($lista) { - $list = Lista::find($lista)->first(); + $list = Lista::find($lista); $data['list'] = $list; diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php new file mode 100644 index 00000000..69cd7e87 --- /dev/null +++ b/app/Http/Controllers/ProfileController.php @@ -0,0 +1,84 @@ + 'required|min:3|max:255', + 'author' => 'required|min:3|max:255', + 'isbn' => 'required|min:10|max:13', 'list_id' => 'required|numeric' ]; } diff --git a/resources/views/book/edit.blade.php b/resources/views/book/edit.blade.php new file mode 100644 index 00000000..53ce1abe --- /dev/null +++ b/resources/views/book/edit.blade.php @@ -0,0 +1,96 @@ +@extends('layouts.app') + +@section('content') +
+
+
+ @if (session('status')) + + @endif + +
+
{{ __('Editar Libro') }}
+ +
+
+ @csrf + @method('PUT') + +
+ + +
+ + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('author')) + + {{ $errors->first('author') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('isbn')) + + {{ $errors->first('isbn') }} + + @endif +
+
+ +
+ +
+ + + @if ($errors->has('list_id')) + + {{ $errors->first('list_id') }} + + @endif +
+
+ + + +
+
+ +
+
+
+
+
+
+
+
+@endsection diff --git a/resources/views/lista/indexAll.blade.php b/resources/views/lista/indexAll.blade.php new file mode 100644 index 00000000..22c70df9 --- /dev/null +++ b/resources/views/lista/indexAll.blade.php @@ -0,0 +1,32 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Listas
+ +
+ + + + + + + @foreach($lists as $list) + + + + + + @endforeach + + +
ID ListaNombre
{{ $list->id }}{{ $list->name }}Ver
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/lista/show.blade.php b/resources/views/lista/show.blade.php new file mode 100644 index 00000000..4f1b363c --- /dev/null +++ b/resources/views/lista/show.blade.php @@ -0,0 +1,40 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Lista de listas
+ +
+ @if (session('status')) + + @endif + + + + + + + + + @foreach($listas as $lista) + + + + + + + @endforeach + + +
ID ListaNombreUsuarioCreada en
{{ $lista->id }}{{ $lista->name }}{{ $lista->user_id }}{{ $lista->created_at }}
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index ca83fbf9..b4a54ad3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -25,6 +25,8 @@ Route::get('user/{userid}/list', 'ListaController@publicLists'); Route::resource('/list', 'ListaController'); +Route::get('user/{userid}/list', 'ListaController@indexAll'); + From 3151faddabc5f99bee851087c55f95b35f75be25 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Sat, 27 Apr 2019 17:32:24 -0300 Subject: [PATCH 09/25] - ProfileController - Update UsersTable - Update UserTableSeeder - Update routes (profile) - Edit profile (method and view) - Index profile (method and view) --- app/Http/Controllers/ListaController.php | 2 +- app/Http/Controllers/ProfileController.php | 40 +++++- .../2014_10_12_000000_create_users_table.php | 4 + database/seeds/UsersTableSeeder.php | 6 +- resources/views/profile/create.blade.php | 133 ++++++++++++++++++ resources/views/profile/index.blade.php | 43 ++++++ routes/web.php | 5 + 7 files changed, 226 insertions(+), 7 deletions(-) create mode 100644 resources/views/profile/create.blade.php create mode 100644 resources/views/profile/index.blade.php diff --git a/app/Http/Controllers/ListaController.php b/app/Http/Controllers/ListaController.php index 72c96a42..3af9de45 100644 --- a/app/Http/Controllers/ListaController.php +++ b/app/Http/Controllers/ListaController.php @@ -15,7 +15,7 @@ public function __construct() $this->middleware('auth'); //$this->middleware('book.privacy')->only('show'); - $this->middleware('book.privacy', ['only' => ['show', 'edit','index']]); + $this->middleware('book.privacy', ['only' => ['show', 'edit']]); } /** diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 69cd7e87..34c2ebff 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use Auth; class ProfileController extends Controller { @@ -13,7 +14,15 @@ class ProfileController extends Controller */ public function index() { - // + $userData = Auth::user(); + + if($userData) { + $data['userData'] = $userData; + } else { + $data['userData'] = []; + } + + return view('profile.index', $data); } /** @@ -23,7 +32,15 @@ public function index() */ public function create() { - // + $userData = Auth::user(); + + if($userData) { + $data['userData'] = $userData; + } else { + $data['userData'] = []; + } + + return view('profile.create', $data); } /** @@ -34,7 +51,20 @@ public function create() */ public function store(Request $request) { - // + $user = Auth::user(); + + $user->name=$request->name; + $user->surname=$request->surname; + $user->username=$request->username; + $user->email=$request->email; + //$user->password=bcrypt($request->password); + $user->telephone=$request->telephone; + $user->address=$request->address; + + if ($user->save()) { + // return redirect()->route('book.update')->with('status', 'Éxito'); + return redirect()->route('profile.create')->with('status', 'Éxito'); + } } /** @@ -56,7 +86,7 @@ public function show($id) */ public function edit($id) { - // + } /** @@ -68,7 +98,7 @@ public function edit($id) */ public function update(Request $request, $id) { - // + } /** diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 4a3ba472..d31879ae 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -16,9 +16,13 @@ public function up() Schema::create('users', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); + $table->string('surname')->nullable(); + $table->string('username')->unique()->nullable(); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); + $table->bigInteger('telephone')->nullable(); + $table->string('address')->nullable(); $table->rememberToken(); $table->timestamps(); }); diff --git a/database/seeds/UsersTableSeeder.php b/database/seeds/UsersTableSeeder.php index eb39a8e0..f04ade9e 100644 --- a/database/seeds/UsersTableSeeder.php +++ b/database/seeds/UsersTableSeeder.php @@ -12,9 +12,13 @@ class UsersTableSeeder extends Seeder public function run() { DB::table('users')->insert([ - 'name' => 'fritz', + 'name' => 'jonathan', + 'surname' => 'fritz', + 'username' => 'jonii', 'email' => 'fritz@gmail.com', 'password' => bcrypt('12345678'), + 'telephone' => '123456', + 'address' => 'dirección 123', ]); } } diff --git a/resources/views/profile/create.blade.php b/resources/views/profile/create.blade.php new file mode 100644 index 00000000..e601675d --- /dev/null +++ b/resources/views/profile/create.blade.php @@ -0,0 +1,133 @@ +@extends('layouts.app') + +@section('content') +
+
+
+ @if (session('status')) + + @endif + +
+
{{ __('Completar Perfil') }}
+ +
+
+ @csrf + + +
+ + +
+ + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('surname')) + + {{ $errors->first('surname') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('username')) + + {{ $errors->first('username') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('telephone')) + + {{ $errors->first('telephone') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('address')) + + {{ $errors->first('address') }} + + @endif +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+@endsection diff --git a/resources/views/profile/index.blade.php b/resources/views/profile/index.blade.php new file mode 100644 index 00000000..d463b75b --- /dev/null +++ b/resources/views/profile/index.blade.php @@ -0,0 +1,43 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Mi Perfil
+ +
+ @if (session('status')) + + @endif + + + + + + + + + + + + + + + + + + + + + +
NombreApellidoUsuarioE-mailPasswordTeléfonoDirección
{{ $userData->name }}{{ $userData->surname }}{{ $userData->username }}{{ $userData->email }}{{ $userData->name }}{{ $userData->telephone}}{{ $userData->address}}
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index b4a54ad3..a7a7d992 100644 --- a/routes/web.php +++ b/routes/web.php @@ -27,6 +27,11 @@ Route::get('user/{userid}/list', 'ListaController@indexAll'); +Route::resource('/profile', 'ProfileController'); + +//Route::get('profile/', 'ProfileController@index'); + + From ecb47c2df1a98e42297c7a8256da76b2e3002919 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 00:08:54 -0300 Subject: [PATCH 10/25] - Update Book controller (book.index, add book.destroy). - Update ListController (list.index, update list.show, add list.destroy, remove duplicate indexAll). - Add profile.edit, profile.store, profile.show (ProfileController). - Update books_table with list_id nullable. - Update list.index, list.show (List views). - Update routes. - Update profile.edit, profile.show (Profile views). - Fix list privacy. --- app/Http/Controllers/BookController.php | 8 ++-- app/Http/Controllers/ListaController.php | 43 ++++++++----------- app/Http/Controllers/ProfileController.php | 37 +++++++++++----- .../2019_04_15_185930_create_books_table.php | 2 +- resources/views/book/index.blade.php | 4 +- resources/views/lista/index.blade.php | 28 ++++++++---- resources/views/lista/indexAll.blade.php | 32 -------------- resources/views/lista/show.blade.php | 18 ++++---- .../{create.blade.php => edit.blade.php} | 3 +- resources/views/profile/show.blade.php | 39 +++++++++++++++++ routes/web.php | 13 +++--- 11 files changed, 127 insertions(+), 100 deletions(-) delete mode 100644 resources/views/lista/indexAll.blade.php rename resources/views/profile/{create.blade.php => edit.blade.php} (97%) create mode 100644 resources/views/profile/show.blade.php diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index c0ba7d67..0db21f89 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -24,7 +24,7 @@ public function __construct() */ public function index() { - $books = Book::all(); + $books = Book::where('user_id', Auth::user()->id)->get(); $data['books'] = $books; @@ -131,8 +131,10 @@ public function update(Request $request, Book $book) * @param \App\Book $book * @return \Illuminate\Http\Response */ - public function destroy(Book $book) + public function destroy($book) { - // + Book::where('id', $book)->delete(); + + return redirect()->route('book.index'); } } diff --git a/app/Http/Controllers/ListaController.php b/app/Http/Controllers/ListaController.php index 3af9de45..7a80a189 100644 --- a/app/Http/Controllers/ListaController.php +++ b/app/Http/Controllers/ListaController.php @@ -6,16 +6,17 @@ use Illuminate\Http\Request; use Auth; use App\User; +use App\Book; class ListaController extends Controller { public function __construct() { - $this->middleware('auth'); + $this->middleware('auth')->except('publicLists', 'show'); //$this->middleware('book.privacy')->only('show'); - $this->middleware('book.privacy', ['only' => ['show', 'edit']]); + $this->middleware('book.privacy', ['only' => ['show']]); } /** @@ -25,23 +26,13 @@ public function __construct() */ public function index() { - $listas = Lista::all(); + $lists = Auth::user()->list()->get(); - $data['listas'] = $listas; + $data['listas'] = $lists; - return view('lista.show', $data); + return view('lista.index', $data); } - public function indexAll($userid) - { - - $lists = User::find($userid)->list()->get(); - - $data['lists'] = $lists; - - return view('lista.indexAll', $data); - - } public function publicLists($userid) { @@ -99,14 +90,7 @@ public function show($lista) $data['books'] = $books; $data['is_public'] = $public_list; - return view('lista.index', $data); - } - - public function showAll() - { - $lista = Lista::all(); - - return show($lista); + return view('lista.show', $data); } /** @@ -153,8 +137,17 @@ public function update(Request $request, $lista) * @param \App\lista $lista * @return \Illuminate\Http\Response */ - public function destroy(lista $lista) + public function destroy($lista) { - // + + if (Lista::where('id', $lista)->delete()) { + + $book = Book::where('list_id', $lista)->update(['list_id' => null]); + + } + + return redirect()->route('list.index'); + + } } diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 34c2ebff..25055637 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -4,9 +4,16 @@ use Illuminate\Http\Request; use Auth; +use App\User; class ProfileController extends Controller { + public function __construct() + { + + $this->middleware('auth', ['only' => ['index','create']]); + } + /** * Display a listing of the resource. * @@ -30,9 +37,9 @@ public function index() * * @return \Illuminate\Http\Response */ - public function create() + public function edit() { - $userData = Auth::user(); + $userData = Auth::user(); if($userData) { $data['userData'] = $userData; @@ -40,7 +47,7 @@ public function create() $data['userData'] = []; } - return view('profile.create', $data); + return view('profile.edit', $data); } /** @@ -51,19 +58,21 @@ public function create() */ public function store(Request $request) { + $user = Auth::user(); $user->name=$request->name; $user->surname=$request->surname; $user->username=$request->username; $user->email=$request->email; - //$user->password=bcrypt($request->password); + if($request->filled('password')) { + $user->password= bcrypt($request->password); + } $user->telephone=$request->telephone; $user->address=$request->address; if ($user->save()) { - // return redirect()->route('book.update')->with('status', 'Éxito'); - return redirect()->route('profile.create')->with('status', 'Éxito'); + return redirect()->route('profile.edit')->with('status', 'Éxito'); } } @@ -75,7 +84,16 @@ public function store(Request $request) */ public function show($id) { - // + $user = User::find($id); + + + if($user) { + $data['userData'] = $user; + } else { + $data['userData'] = []; + } + + return view('profile.show', $data); } /** @@ -84,10 +102,7 @@ public function show($id) * @param int $id * @return \Illuminate\Http\Response */ - public function edit($id) - { - - } + /** * Update the specified resource in storage. diff --git a/database/migrations/2019_04_15_185930_create_books_table.php b/database/migrations/2019_04_15_185930_create_books_table.php index b2938807..cd41c3fc 100644 --- a/database/migrations/2019_04_15_185930_create_books_table.php +++ b/database/migrations/2019_04_15_185930_create_books_table.php @@ -19,7 +19,7 @@ public function up() $table->string('author'); $table->string('isbn'); $table->bigInteger('user_id'); - $table->bigInteger('list_id'); + $table->bigInteger('list_id')->nullable(); $table->timestamps(); }); diff --git a/resources/views/book/index.blade.php b/resources/views/book/index.blade.php index 2b53c48c..7159ffe1 100644 --- a/resources/views/book/index.blade.php +++ b/resources/views/book/index.blade.php @@ -20,7 +20,7 @@ Nombre Autor ISBN - Usuario ID + Lista ID Fecha de creación @foreach($books as $book) @@ -29,7 +29,7 @@ {{ $book->name }} {{ $book->author }} {{ $book->isbn }} - {{ $book->user_id }} + {{ $book->list_id }} {{ $book->created_at}} @endforeach diff --git a/resources/views/lista/index.blade.php b/resources/views/lista/index.blade.php index e8e42140..8788a5c6 100644 --- a/resources/views/lista/index.blade.php +++ b/resources/views/lista/index.blade.php @@ -5,7 +5,7 @@
-
Lista: {{$name}} - {{($is_public ==0) ? 'Lista no Pública' : 'Lista Pública' }}
+
Lista de listas
@if (session('status')) @@ -16,17 +16,27 @@ - + - - + + - @foreach($books as $book) + @foreach($listas as $lista) - - - - + + + + + + + + @endforeach diff --git a/resources/views/lista/indexAll.blade.php b/resources/views/lista/indexAll.blade.php deleted file mode 100644 index 22c70df9..00000000 --- a/resources/views/lista/indexAll.blade.php +++ /dev/null @@ -1,32 +0,0 @@ -@extends('layouts.app') - -@section('content') -
-
-
-
-
Listas
- -
-
ID LibroID Lista NombreAutorISBNUsuarioCreada en
{{ $book->id }}{{ $book->name }}{{ $book->author }}{{ $book->isbn }}{{ $lista->id }}{{ $lista->name }}{{ $lista->user_id }}{{ $lista->created_at }} +
+ @csrf + @method('DELETE') + +
+
VerEditar
- - - - - - @foreach($lists as $list) - - - - - - @endforeach - - -
ID ListaNombre
{{ $list->id }}{{ $list->name }}Ver
-
-
-
-
-
-@endsection \ No newline at end of file diff --git a/resources/views/lista/show.blade.php b/resources/views/lista/show.blade.php index 4f1b363c..e8e42140 100644 --- a/resources/views/lista/show.blade.php +++ b/resources/views/lista/show.blade.php @@ -5,7 +5,7 @@
-
Lista de listas
+
Lista: {{$name}} - {{($is_public ==0) ? 'Lista no Pública' : 'Lista Pública' }}
@if (session('status')) @@ -16,17 +16,17 @@ - + - - + + - @foreach($listas as $lista) + @foreach($books as $book) - - - - + + + + @endforeach diff --git a/resources/views/profile/create.blade.php b/resources/views/profile/edit.blade.php similarity index 97% rename from resources/views/profile/create.blade.php rename to resources/views/profile/edit.blade.php index e601675d..0923087d 100644 --- a/resources/views/profile/create.blade.php +++ b/resources/views/profile/edit.blade.php @@ -17,7 +17,6 @@ @csrf -
@@ -78,7 +77,7 @@
- + @if ($errors->has('password')) diff --git a/resources/views/profile/show.blade.php b/resources/views/profile/show.blade.php new file mode 100644 index 00000000..b355e8c8 --- /dev/null +++ b/resources/views/profile/show.blade.php @@ -0,0 +1,39 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Perfil Público del Usuario: {{$userData->name}}
+ + +
+ @if (session('status')) + + @endif + +
ID ListaID Libro NombreUsuarioCreada enAutorISBN
{{ $lista->id }}{{ $lista->name }}{{ $lista->user_id }}{{ $lista->created_at }}{{ $book->id }}{{ $book->name }}{{ $book->author }}{{ $book->isbn }}
+ + + + + + + + + + + + + +
NombreApellidoTeléfonoDirección
{{ $userData->name }}{{ $userData->surname }}{{ $userData->telephone}}{{ $userData->address}}
+
+ +
+
+
+
+@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index a7a7d992..f57acb0d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,17 +22,18 @@ Route::resource('/book', 'BookController'); -Route::get('user/{userid}/list', 'ListaController@publicLists'); +Route::get('user/{userid}/publicList', 'ListaController@publicLists'); Route::resource('/list', 'ListaController'); -Route::get('user/{userid}/list', 'ListaController@indexAll'); - -Route::resource('/profile', 'ProfileController'); - -//Route::get('profile/', 'ProfileController@index'); +Route::prefix('profile')->name('profile.')->group(function () { + Route::get('edit', 'ProfileController@edit')->name('edit'); + Route::get('{id}', 'ProfileController@show')->name('show'); + Route::post('store', 'ProfileController@store')->name('store'); +}); +Route::get('profile/{userid}/show', 'ProfileController@show'); Route::get('/template', function () { From 2544b078cd767c3fda2494c55ba8426c813530ee Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 10:04:04 -0300 Subject: [PATCH 11/25] Procfile for Heroku --- Procfile | 1 + 1 file changed, 1 insertion(+) create mode 100644 Procfile diff --git a/Procfile b/Procfile new file mode 100644 index 00000000..d1eb6ac8 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +"web: vendor/bin/heroku-php-apache2 public/" From 26251459a357c0485f09fd0ff144d7e84645ce1a Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 12:14:59 -0300 Subject: [PATCH 12/25] -Updates views --- resources/views/book/create.blade.php | 2 +- resources/views/book/index.blade.php | 13 ++++++++++++- resources/views/home.blade.php | 2 +- resources/views/lista/index.blade.php | 6 ++---- resources/views/profile/index.blade.php | 4 +--- routes/web.php | 1 + 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/resources/views/book/create.blade.php b/resources/views/book/create.blade.php index 0eeefef5..cd34e7a8 100644 --- a/resources/views/book/create.blade.php +++ b/resources/views/book/create.blade.php @@ -32,7 +32,7 @@
- +
diff --git a/resources/views/book/index.blade.php b/resources/views/book/index.blade.php index 7159ffe1..d9f21787 100644 --- a/resources/views/book/index.blade.php +++ b/resources/views/book/index.blade.php @@ -5,7 +5,7 @@
-
Lista de Libros
+
Mis Libros
@if (session('status')) @@ -31,6 +31,17 @@ {{ $book->isbn }} {{ $book->list_id }} {{ $book->created_at}} + +
+ @csrf + @method('DELETE') + +
+ + + Editar + + @endforeach diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 05dfca92..b661b230 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -14,7 +14,7 @@
@endif - You are logged in! + Has ingresado correctamente!
diff --git a/resources/views/lista/index.blade.php b/resources/views/lista/index.blade.php index 8788a5c6..9810a43b 100644 --- a/resources/views/lista/index.blade.php +++ b/resources/views/lista/index.blade.php @@ -5,7 +5,7 @@
-
Lista de listas
+
Mis listas
@if (session('status')) @@ -18,20 +18,18 @@ ID Lista Nombre - Usuario Creada en @foreach($listas as $lista) {{ $lista->id }} {{ $lista->name }} - {{ $lista->user_id }} {{ $lista->created_at }}
@csrf @method('DELETE') - +
Ver diff --git a/resources/views/profile/index.blade.php b/resources/views/profile/index.blade.php index d463b75b..4ee8678c 100644 --- a/resources/views/profile/index.blade.php +++ b/resources/views/profile/index.blade.php @@ -20,7 +20,6 @@ Apellido Usuario E-mail - Password Teléfono Dirección @@ -29,12 +28,11 @@ {{ $userData->surname }} {{ $userData->username }} {{ $userData->email }} - {{ $userData->name }} {{ $userData->telephone}} {{ $userData->address}} - +
Editar
diff --git a/routes/web.php b/routes/web.php index f57acb0d..1ba80229 100644 --- a/routes/web.php +++ b/routes/web.php @@ -27,6 +27,7 @@ Route::prefix('profile')->name('profile.')->group(function () { + Route::get('/', 'ProfileController@index')->name('index'); Route::get('edit', 'ProfileController@edit')->name('edit'); Route::get('{id}', 'ProfileController@show')->name('show'); Route::post('store', 'ProfileController@store')->name('store'); From 2e1fa1bc20e278f773e1c8c3bfed5bca0edd21f1 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 15:31:53 -0300 Subject: [PATCH 13/25] - General fixes. BookController, ListController, Middleware. - Updates views. --- app/Http/Controllers/BookController.php | 28 +++++---- app/Http/Controllers/ListaController.php | 17 ++++-- app/Http/Middleware/CheckBookPrivacy.php | 6 +- resources/views/book/create.blade.php | 2 +- resources/views/book/edit.blade.php | 4 +- resources/views/book/index.blade.php | 8 ++- resources/views/home.blade.php | 24 +++++--- resources/views/layouts/app.blade.php | 50 +--------------- .../views/layouts/assets/header.blade.php | 59 +++++++++++++++++++ resources/views/lista/index.blade.php | 7 ++- resources/views/profile/index.blade.php | 45 +++++++------- 11 files changed, 148 insertions(+), 102 deletions(-) create mode 100644 resources/views/layouts/assets/header.blade.php diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 0db21f89..f34d6e30 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -92,12 +92,20 @@ public function show(Book $book) */ public function edit($libro) { - $book = Book::find($libro); + + $book = Book::where([ + ['id', $libro], + ['user_id', Auth::user()->id], + ]); + + if($book->count() == 0) { + return redirect()->route('book.index')->with('status', 'Este libro no pertenece'); + } $lists = Auth::user()->list()->get(); $data['lists'] = $lists; - $data['book'] = $book; + $data['book'] = $book->first(); return view('book.edit', $data); //return $lists; @@ -110,18 +118,18 @@ public function edit($libro) * @param \App\Book $book * @return \Illuminate\Http\Response */ - public function update(Request $request, Book $book) + public function update(Request $request, $book) { - $book = Book::find($book)->first(); + $book_ = Book::find($book); - $book->name=$request->name; - $book->author=$request->author; - $book->isbn=$request->isbn; - $book->list_id=$request->list_id; + $book_->name=$request->name; + $book_->author=$request->author; + $book_->isbn=$request->isbn; + $book_->list_id=$request->list_id; - if ($book->save()) { + if ($book_->save()) { // return redirect()->route('book.update')->with('status', 'Éxito'); - return redirect()->route('book.edit', ['id' => $book->id])->with('status', 'Éxito'); + return redirect()->route('book.edit', ['id' => $book_->id])->with('status', 'Éxito'); } } diff --git a/app/Http/Controllers/ListaController.php b/app/Http/Controllers/ListaController.php index 7a80a189..057a3f2f 100644 --- a/app/Http/Controllers/ListaController.php +++ b/app/Http/Controllers/ListaController.php @@ -16,7 +16,7 @@ public function __construct() $this->middleware('auth')->except('publicLists', 'show'); //$this->middleware('book.privacy')->only('show'); - $this->middleware('book.privacy', ['only' => ['show']]); + $this->middleware('book.privacy', ['only' => ['show','edit']]); } /** @@ -37,11 +37,20 @@ public function index() public function publicLists($userid) { - $lists = User::find($userid)->list()->where('public_list', 1)->get(); + try { - $data['lists'] = $lists; + $lists = User::findOrFail($userid)->list()->where('public_list', 1)->get(); - return view('lista.publicLists', $data); + $data['lists'] = $lists; + + return view('lista.publicLists', $data); + + } catch(\Exception $e) { + + return redirect('/home'); + + } + } diff --git a/app/Http/Middleware/CheckBookPrivacy.php b/app/Http/Middleware/CheckBookPrivacy.php index 14a215ec..38799b59 100644 --- a/app/Http/Middleware/CheckBookPrivacy.php +++ b/app/Http/Middleware/CheckBookPrivacy.php @@ -21,9 +21,11 @@ public function handle($request, Closure $next) $id = $request->route()->parameter('list'); $lista = Lista::find($id); - if(Auth::user()->id !== $lista->user_id && $lista->public_list==0){ + if($lista->public_list==0) { + if(Auth::user()->id !== $lista->user_id){ - return redirect()->route('home'); + return redirect()->route('home'); + } } diff --git a/resources/views/book/create.blade.php b/resources/views/book/create.blade.php index cd34e7a8..486c8e8c 100644 --- a/resources/views/book/create.blade.php +++ b/resources/views/book/create.blade.php @@ -64,7 +64,7 @@
diff --git a/resources/views/book/edit.blade.php b/resources/views/book/edit.blade.php index 53ce1abe..e608a1a4 100644 --- a/resources/views/book/edit.blade.php +++ b/resources/views/book/edit.blade.php @@ -63,9 +63,9 @@
- @foreach($lists as $key => $list) - + @endforeach diff --git a/resources/views/book/index.blade.php b/resources/views/book/index.blade.php index d9f21787..8f87d983 100644 --- a/resources/views/book/index.blade.php +++ b/resources/views/book/index.blade.php @@ -41,15 +41,17 @@ Editar - @endforeach - -
+
+ +
@endsection \ No newline at end of file diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index b661b230..d293336d 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -5,17 +5,23 @@
-
Dashboard
+
Panel de Control
+ + + + + + + + -
- @if (session('status')) - - @endif - Has ingresado correctamente! -
+ +
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 6b12dd16..3b14846f 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -21,56 +21,8 @@
- + @include('layouts.assets.header')
@yield('content') diff --git a/resources/views/layouts/assets/header.blade.php b/resources/views/layouts/assets/header.blade.php new file mode 100644 index 00000000..29922cf3 --- /dev/null +++ b/resources/views/layouts/assets/header.blade.php @@ -0,0 +1,59 @@ + + \ No newline at end of file diff --git a/resources/views/lista/index.blade.php b/resources/views/lista/index.blade.php index 9810a43b..fdbfb8a8 100644 --- a/resources/views/lista/index.blade.php +++ b/resources/views/lista/index.blade.php @@ -37,12 +37,15 @@ @endforeach - -
+
+ +
@endsection \ No newline at end of file diff --git a/resources/views/profile/index.blade.php b/resources/views/profile/index.blade.php index 4ee8678c..9825cd53 100644 --- a/resources/views/profile/index.blade.php +++ b/resources/views/profile/index.blade.php @@ -13,26 +13,31 @@ {{ session('status') }} @endif - - - - - - - - - - - - - - - - - - -
NombreApellidoUsuarioE-mailTeléfonoDirección
{{ $userData->name }}{{ $userData->surname }}{{ $userData->username }}{{ $userData->email }}{{ $userData->telephone}}{{ $userData->address}}
-
Editar
+
+ + + + + + + + + + + + + + + + + + + + + +
NombreApellidoUsuarioE-mailTeléfonoDirección
{{ $userData->name }}{{ $userData->surname }}{{ $userData->username }}{{ $userData->email }}{{ $userData->telephone}}{{ $userData->address}}
+
Editar
+
From 9e9b0250af5cf0d30546d68efd3768b6d801015d Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 17:25:18 -0300 Subject: [PATCH 14/25] Update Procfile --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index d1eb6ac8..4d3ef5f1 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -"web: vendor/bin/heroku-php-apache2 public/" +web: vendor/bin/heroku-php-apache2 public/ From 1a71b083136ca38f60db79197f7015425153f13b Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 19:03:17 -0300 Subject: [PATCH 15/25] Update views for responsive --- resources/views/book/index.blade.php | 64 +++++++++---------- resources/views/book/list.blade.php | 45 ++++++------- .../views/layouts/assets/header.blade.php | 1 + resources/views/lista/index.blade.php | 3 +- resources/views/lista/publicLists.blade.php | 32 +++++----- resources/views/lista/show.blade.php | 37 ++++++----- resources/views/profile/show.blade.php | 35 +++++----- 7 files changed, 110 insertions(+), 107 deletions(-) diff --git a/resources/views/book/index.blade.php b/resources/views/book/index.blade.php index 8f87d983..5726308c 100644 --- a/resources/views/book/index.blade.php +++ b/resources/views/book/index.blade.php @@ -13,41 +13,41 @@ {{ session('status') }} @endif - - - - - - - - - - - @foreach($books as $book) - - - - - - - - - - - @endforeach -
IDNombreAutorISBNLista IDFecha de creación
{{ $book->id }}{{ $book->name }}{{ $book->author }}{{ $book->isbn }}{{ $book->list_id }}{{ $book->created_at}} -
- @csrf - @method('DELETE') - -
-
- Editar -
+
+ + + + + + + + + + @foreach($books as $book) + + + + + + + + + + + @endforeach +
IDNombreAutorISBNLista IDFecha de creación
{{ $book->id }}{{ $book->name }}{{ $book->author }}{{ $book->isbn }}{{ $book->list_id }}{{ $book->created_at}} +
+ @csrf + @method('DELETE') + +
+
+ Editar +
+
-
Agregar Libro
diff --git a/resources/views/book/list.blade.php b/resources/views/book/list.blade.php index 1da44482..5ac62aaa 100644 --- a/resources/views/book/list.blade.php +++ b/resources/views/book/list.blade.php @@ -13,29 +13,30 @@ {{ session('status') }}
@endif +
+ + + + + + + + + + @foreach($books as $book) + + + + + + + + + @endforeach + -
IDNombreAutorISBNUsuario IDFecha de creación
{{ $book->id }}{{ $book->name }}{{ $book->author }}{{ $book->isbn }}{{ $book->user_id }}{{ $book->created_at}}
- - - - - - - - - @foreach($books as $book) - - - - - - - - - @endforeach - - -
IDNombreAutorISBNUsuario IDFecha de creación
{{ $book->id }}{{ $book->name }}{{ $book->author }}{{ $book->isbn }}{{ $book->user_id }}{{ $book->created_at}}
+ +
diff --git a/resources/views/layouts/assets/header.blade.php b/resources/views/layouts/assets/header.blade.php index 29922cf3..2dbf127e 100644 --- a/resources/views/layouts/assets/header.blade.php +++ b/resources/views/layouts/assets/header.blade.php @@ -41,6 +41,7 @@ @endif - +
+
diff --git a/resources/views/lista/publicLists.blade.php b/resources/views/lista/publicLists.blade.php index 22c70df9..a8e3c270 100644 --- a/resources/views/lista/publicLists.blade.php +++ b/resources/views/lista/publicLists.blade.php @@ -8,22 +8,24 @@
Listas
-
ID Lista Nombre
- - - - - - @foreach($lists as $list) - - - - - - @endforeach - +
+
ID ListaNombre
{{ $list->id }}{{ $list->name }}Ver
+ + + + + + @foreach($lists as $list) + + + + + + @endforeach + -
ID ListaNombre
{{ $list->id }}{{ $list->name }}Ver
+ + diff --git a/resources/views/lista/show.blade.php b/resources/views/lista/show.blade.php index e8e42140..df6ef7d5 100644 --- a/resources/views/lista/show.blade.php +++ b/resources/views/lista/show.blade.php @@ -13,25 +13,24 @@ {{ session('status') }} @endif - - - - - - - - - @foreach($books as $book) - - - - - - - @endforeach - - -
ID LibroNombreAutorISBN
{{ $book->id }}{{ $book->name }}{{ $book->author }}{{ $book->isbn }}
+
+ + + + + + + + @foreach($books as $book) + + + + + + + @endforeach +
ID LibroNombreAutorISBN
{{ $book->id }}{{ $book->name }}{{ $book->author }}{{ $book->isbn }}
+
diff --git a/resources/views/profile/show.blade.php b/resources/views/profile/show.blade.php index b355e8c8..4f5ab21f 100644 --- a/resources/views/profile/show.blade.php +++ b/resources/views/profile/show.blade.php @@ -14,24 +14,23 @@ {{ session('status') }} @endif - - - - - - - - - - - - - - - -
NombreApellidoTeléfonoDirección
{{ $userData->name }}{{ $userData->surname }}{{ $userData->telephone}}{{ $userData->address}}
- - +
+ + + + + + + + + + + + + +
NombreApellidoTeléfonoDirección
{{ $userData->name }}{{ $userData->surname }}{{ $userData->telephone}}{{ $userData->address}}
+
+ From d99d45c0f8fd1011667c56dd118008f502ffcd52 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 20:10:55 -0300 Subject: [PATCH 16/25] - Home. - Add view home with public lists. - Add readme. - Update edit list. - Update routes. --- app/Http/Controllers/HomeController.php | 8 +++- app/Http/Controllers/ListaController.php | 1 - resources/views/home.blade.php | 36 ++++++++------- .../views/layouts/assets/header.blade.php | 3 ++ resources/views/lista/edit.blade.php | 8 +++- resources/views/readme.blade.php | 45 +++++++++++++++++++ routes/web.php | 9 ++-- 7 files changed, 89 insertions(+), 21 deletions(-) create mode 100644 resources/views/readme.blade.php diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 7cbc2c3f..0ab2dec2 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\Lista; class HomeController extends Controller { @@ -23,6 +24,11 @@ public function __construct() */ public function index() { - return view('home'); + + $lists = Lista::where('public_list', 1)->get(); + + $data['lists'] = $lists; + + return view('home', $data); } } diff --git a/app/Http/Controllers/ListaController.php b/app/Http/Controllers/ListaController.php index 057a3f2f..3e336775 100644 --- a/app/Http/Controllers/ListaController.php +++ b/app/Http/Controllers/ListaController.php @@ -36,7 +36,6 @@ public function index() public function publicLists($userid) { - try { $lists = User::findOrFail($userid)->list()->where('public_list', 1)->get(); diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index d293336d..0a13bd0e 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -5,23 +5,29 @@
-
Panel de Control
-
- - - +
Listas
+
+
+ + + + + + + + @foreach($lists as $list) + + + + + + + @endforeach - - - - - - +
ID ListaNombreUser id
{{ $list->id }}{{ $list->name }}{{ $list->user_id }}Ver
+
+
diff --git a/resources/views/layouts/assets/header.blade.php b/resources/views/layouts/assets/header.blade.php index 2dbf127e..7643a9eb 100644 --- a/resources/views/layouts/assets/header.blade.php +++ b/resources/views/layouts/assets/header.blade.php @@ -20,6 +20,9 @@ + diff --git a/resources/views/lista/edit.blade.php b/resources/views/lista/edit.blade.php index b621ffa0..c2d0f7b0 100644 --- a/resources/views/lista/edit.blade.php +++ b/resources/views/lista/edit.blade.php @@ -35,7 +35,13 @@
- + + + @if ($errors->has('public_list')) diff --git a/resources/views/readme.blade.php b/resources/views/readme.blade.php new file mode 100644 index 00000000..77f91591 --- /dev/null +++ b/resources/views/readme.blade.php @@ -0,0 +1,45 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
Read Me
+ +
+ @if (session('status')) + + @endif +
+ + + + + + + + + + + + + + + + + + + + + +
AlumnoLUMateriaProfesorAsistenteAño
Jonathan Alberto Fritz99761Ingeniería de Aplicaciones WebDiego MartinezMariano Tucat2019
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 1ba80229..e30418a7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -11,9 +11,8 @@ | */ -Route::get('/', function () { - return view('layouts/app'); -}); +Route::get('/', 'HomeController@index'); + Auth::routes(); @@ -36,6 +35,10 @@ Route::get('profile/{userid}/show', 'ProfileController@show'); +Route::get('/readme', function () { + return view('readme'); +}); + Route::get('/template', function () { return view('template'); From c7c0902f1e054733c979edecf5ee5a92f4b95af3 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 20:27:25 -0300 Subject: [PATCH 17/25] - ListRequest added. - Update views. --- app/Http/Controllers/ListaController.php | 1 + app/Http/Requests/ListRequest.php | 30 +++++++++++++++++++ resources/views/auth/login.blade.php | 12 ++++---- resources/views/auth/register.blade.php | 12 ++++---- .../views/layouts/assets/header.blade.php | 13 ++++---- resources/views/lista/index.blade.php | 4 ++- 6 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 app/Http/Requests/ListRequest.php diff --git a/app/Http/Controllers/ListaController.php b/app/Http/Controllers/ListaController.php index 3e336775..aabb15cf 100644 --- a/app/Http/Controllers/ListaController.php +++ b/app/Http/Controllers/ListaController.php @@ -7,6 +7,7 @@ use Auth; use App\User; use App\Book; +use App\Http\Requests\BookRequest; class ListaController extends Controller { diff --git a/app/Http/Requests/ListRequest.php b/app/Http/Requests/ListRequest.php new file mode 100644 index 00000000..3cc1f576 --- /dev/null +++ b/app/Http/Requests/ListRequest.php @@ -0,0 +1,30 @@ + 'required|min:3|max:255', + ]; + } +} diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 9edb920e..feec569b 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -5,14 +5,14 @@
-
{{ __('Login') }}
+
{{ __('Ingresar') }}
@csrf
- +
@@ -26,7 +26,7 @@
- +
@@ -45,7 +45,7 @@
@@ -54,12 +54,12 @@
@if (Route::has('password.request')) - {{ __('Forgot Your Password?') }} + {{ __('¿Olvidó su contraseña?') }} @endif
diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index ad95f2cf..03ae3cd2 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -5,14 +5,14 @@
-
{{ __('Register') }}
+
{{ __('Registrarse') }}
@csrf
- +
@@ -26,7 +26,7 @@
- +
@@ -40,7 +40,7 @@
- +
@@ -54,7 +54,7 @@
- +
@@ -64,7 +64,7 @@
diff --git a/resources/views/layouts/assets/header.blade.php b/resources/views/layouts/assets/header.blade.php index 7643a9eb..82e5ee92 100644 --- a/resources/views/layouts/assets/header.blade.php +++ b/resources/views/layouts/assets/header.blade.php @@ -12,16 +12,13 @@ @@ -30,11 +27,11 @@ @guest @if (Route::has('register')) @endif @else diff --git a/resources/views/lista/index.blade.php b/resources/views/lista/index.blade.php index b3fda06f..94ab6f72 100644 --- a/resources/views/lista/index.blade.php +++ b/resources/views/lista/index.blade.php @@ -20,12 +20,14 @@ ID Lista Nombre Creada en + ¿Es Pública? @foreach($listas as $lista) {{ $lista->id }} {{ $lista->name }} {{ $lista->created_at }} + {{($lista->public_list ==0) ? 'No' : 'Si'}} @csrf @@ -36,7 +38,7 @@ Ver Editar - + @endforeach
From 798673ead2032fd78dec589a78582992ef8ee252 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 20:42:43 -0300 Subject: [PATCH 18/25] - Update book and book views. - Update home --- app/Http/Controllers/BookController.php | 8 +++ .../2019_04_15_185930_create_books_table.php | 4 ++ resources/views/book/create.blade.php | 56 +++++++++++++++++++ resources/views/book/edit.blade.php | 56 +++++++++++++++++++ resources/views/book/index.blade.php | 11 +++- resources/views/home.blade.php | 2 +- 6 files changed, 135 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index f34d6e30..206bf312 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -65,6 +65,10 @@ public function store(BookRequest $request) $book->name=$request->name; $book->author=$request->author; $book->isbn=$request->isbn; + $book->page_number=$request->page_number; + $book->language=$request->language; + $book->year=$request->year; + $book->editor=$request->editor; $book->user_id = Auth::user()->id; $book->list_id=$request->list_id; @@ -125,6 +129,10 @@ public function update(Request $request, $book) $book_->name=$request->name; $book_->author=$request->author; $book_->isbn=$request->isbn; + $book->page_number=$request->page_number; + $book->language=$request->language; + $book->year=$request->year; + $book->editor=$request->editor; $book_->list_id=$request->list_id; if ($book_->save()) { diff --git a/database/migrations/2019_04_15_185930_create_books_table.php b/database/migrations/2019_04_15_185930_create_books_table.php index cd41c3fc..b06a6bb6 100644 --- a/database/migrations/2019_04_15_185930_create_books_table.php +++ b/database/migrations/2019_04_15_185930_create_books_table.php @@ -18,6 +18,10 @@ public function up() $table->string('name'); $table->string('author'); $table->string('isbn'); + $table->bigInteger('page_number'); + $table->string('language'); + $table->bigInteger('year'); + $table->string('editor'); $table->bigInteger('user_id'); $table->bigInteger('list_id')->nullable(); $table->timestamps(); diff --git a/resources/views/book/create.blade.php b/resources/views/book/create.blade.php index 486c8e8c..8a7c1741 100644 --- a/resources/views/book/create.blade.php +++ b/resources/views/book/create.blade.php @@ -59,6 +59,62 @@
+
+ + +
+ + + @if ($errors->has('page_number')) + + {{ $errors->first('page_number') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('language')) + + {{ $errors->first('language') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('year')) + + {{ $errors->first('year') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('editor')) + + {{ $errors->first('editor') }} + + @endif +
+
+
diff --git a/resources/views/book/edit.blade.php b/resources/views/book/edit.blade.php index e608a1a4..d5a40b60 100644 --- a/resources/views/book/edit.blade.php +++ b/resources/views/book/edit.blade.php @@ -60,6 +60,62 @@
+
+ + +
+ + + @if ($errors->has('page_number')) + + {{ $errors->first('page_number') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('language')) + + {{ $errors->first('language') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('year')) + + {{ $errors->first('year') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('editor')) + + {{ $errors->first('editor') }} + + @endif +
+
+
diff --git a/resources/views/book/index.blade.php b/resources/views/book/index.blade.php index 5726308c..1afa02ce 100644 --- a/resources/views/book/index.blade.php +++ b/resources/views/book/index.blade.php @@ -3,7 +3,7 @@ @section('content')
-
+
Mis Libros
@@ -20,6 +20,11 @@ Nombre Autor ISBN + Número de Páginas + Idioma + Año + Editorial + Lista ID Fecha de creación @@ -29,6 +34,10 @@ {{ $book->name }} {{ $book->author }} {{ $book->isbn }} + {{ $book->page_number }} + {{ $book->language }} + {{ $book->year }} + {{ $book->editor }} {{ $book->list_id }} {{ $book->created_at}} diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 0a13bd0e..368f0670 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -12,7 +12,7 @@ ID Lista Nombre - User id + ID Usuario @foreach($lists as $list) From 43658a023e3fe1f7fb7262d2556c747d7d54df91 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 21:03:26 -0300 Subject: [PATCH 19/25] - General updates. --- app/Http/Controllers/BookController.php | 8 ++---- app/Http/Requests/BookRequest.php | 2 ++ .../2019_04_15_185930_create_books_table.php | 2 -- resources/views/book/create.blade.php | 28 ------------------- resources/views/book/edit.blade.php | 28 ------------------- resources/views/book/index.blade.php | 2 -- 6 files changed, 4 insertions(+), 66 deletions(-) diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 206bf312..43673d2d 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -67,8 +67,6 @@ public function store(BookRequest $request) $book->isbn=$request->isbn; $book->page_number=$request->page_number; $book->language=$request->language; - $book->year=$request->year; - $book->editor=$request->editor; $book->user_id = Auth::user()->id; $book->list_id=$request->list_id; @@ -129,10 +127,8 @@ public function update(Request $request, $book) $book_->name=$request->name; $book_->author=$request->author; $book_->isbn=$request->isbn; - $book->page_number=$request->page_number; - $book->language=$request->language; - $book->year=$request->year; - $book->editor=$request->editor; + $book_->page_number=$request->page_number; + $book_->language=$request->language; $book_->list_id=$request->list_id; if ($book_->save()) { diff --git a/app/Http/Requests/BookRequest.php b/app/Http/Requests/BookRequest.php index 232b7fc4..0950df66 100644 --- a/app/Http/Requests/BookRequest.php +++ b/app/Http/Requests/BookRequest.php @@ -27,6 +27,8 @@ public function rules() 'name' => 'required|min:3|max:255', 'author' => 'required|min:3|max:255', 'isbn' => 'required|min:10|max:13', + 'page_number' => 'required|numeric|min:1|max:10000', + 'language' => 'required|min:3|max:255', 'list_id' => 'required|numeric' ]; } diff --git a/database/migrations/2019_04_15_185930_create_books_table.php b/database/migrations/2019_04_15_185930_create_books_table.php index b06a6bb6..a2a01273 100644 --- a/database/migrations/2019_04_15_185930_create_books_table.php +++ b/database/migrations/2019_04_15_185930_create_books_table.php @@ -20,8 +20,6 @@ public function up() $table->string('isbn'); $table->bigInteger('page_number'); $table->string('language'); - $table->bigInteger('year'); - $table->string('editor'); $table->bigInteger('user_id'); $table->bigInteger('list_id')->nullable(); $table->timestamps(); diff --git a/resources/views/book/create.blade.php b/resources/views/book/create.blade.php index 8a7c1741..d90559f4 100644 --- a/resources/views/book/create.blade.php +++ b/resources/views/book/create.blade.php @@ -87,34 +87,6 @@
-
- - -
- - - @if ($errors->has('year')) - - {{ $errors->first('year') }} - - @endif -
-
- -
- - -
- - - @if ($errors->has('editor')) - - {{ $errors->first('editor') }} - - @endif -
-
-
diff --git a/resources/views/book/edit.blade.php b/resources/views/book/edit.blade.php index d5a40b60..43c6c91f 100644 --- a/resources/views/book/edit.blade.php +++ b/resources/views/book/edit.blade.php @@ -88,34 +88,6 @@
-
- - -
- - - @if ($errors->has('year')) - - {{ $errors->first('year') }} - - @endif -
-
- -
- - -
- - - @if ($errors->has('editor')) - - {{ $errors->first('editor') }} - - @endif -
-
-
diff --git a/resources/views/book/index.blade.php b/resources/views/book/index.blade.php index 1afa02ce..ab48a494 100644 --- a/resources/views/book/index.blade.php +++ b/resources/views/book/index.blade.php @@ -22,7 +22,6 @@ ISBN Número de Páginas Idioma - Año Editorial Lista ID @@ -36,7 +35,6 @@ {{ $book->isbn }} {{ $book->page_number }} {{ $book->language }} - {{ $book->year }} {{ $book->editor }} {{ $book->list_id }} {{ $book->created_at}} From 58fa588ae4cda037a9c9bd3a64967877f4afe3be Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 21:32:23 -0300 Subject: [PATCH 20/25] -update readme --- resources/views/readme.blade.php | 51 +++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/resources/views/readme.blade.php b/resources/views/readme.blade.php index 77f91591..8265ce17 100644 --- a/resources/views/readme.blade.php +++ b/resources/views/readme.blade.php @@ -5,7 +5,7 @@
-
Read Me
+
Acerca de
@if (session('status')) @@ -38,6 +38,55 @@
+ +
Datos Obtenidos de Audit
+ +
+ @if (session('status')) + + @endif +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
URLPerformanceAccesibilidad
/home87%87%
/login88%89%
/book88%87%
/list89%87%
+
+
From 50406a977ee5ab649df81a68e8bac84d969be880 Mon Sep 17 00:00:00 2001 From: Jonathan Fritz Date: Tue, 30 Apr 2019 21:43:50 -0300 Subject: [PATCH 21/25] minor updates --- config/app.php | 2 +- resources/views/layouts/assets/header.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/app.php b/config/app.php index c9960cde..1f98d127 100644 --- a/config/app.php +++ b/config/app.php @@ -13,7 +13,7 @@ | */ - 'name' => env('APP_NAME', 'Laravel'), + 'name' => env('APP_NAME', 'IAWEB - Libros'), /* |-------------------------------------------------------------------------- diff --git a/resources/views/layouts/assets/header.blade.php b/resources/views/layouts/assets/header.blade.php index 82e5ee92..d3c4980f 100644 --- a/resources/views/layouts/assets/header.blade.php +++ b/resources/views/layouts/assets/header.blade.php @@ -2,7 +2,7 @@