Skip to content
This repository has been archived by the owner on Apr 12, 2020. It is now read-only.

Entrega de Proyecto 1 #38

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
422a5c4
Funcionando el registro y login de la pagina
MicaelaWaigel Apr 27, 2019
b33c0ef
Agregado el mostrado de listas e items
MicaelaWaigel May 1, 2019
13447c1
Eliminar una coleccion y otros arreglos y cambios
MicaelaWaigel May 2, 2019
7df040d
Procfile for Heroku
MicaelaWaigel May 2, 2019
e5cdd6d
modificacion de AppServiceProviders
MicaelaWaigel May 2, 2019
0ca6ed9
base de datos
MicaelaWaigel May 2, 2019
2553561
Arreglo detalles carga de comics
MicaelaWaigel May 5, 2019
0d0a0e9
prueba rutas
MicaelaWaigel May 5, 2019
88694b7
Vuelvo a lo normal
MicaelaWaigel May 5, 2019
87a7ea0
Agrego funciones al modelo Colection
MicaelaWaigel May 6, 2019
8eddf7b
update
MicaelaWaigel May 7, 2019
6f9dee4
update
MicaelaWaigel May 7, 2019
a0c3047
update
MicaelaWaigel May 7, 2019
62954cd
update
MicaelaWaigel May 7, 2019
87b5867
update
MicaelaWaigel May 7, 2019
34cc102
update
MicaelaWaigel May 8, 2019
683034f
update
MicaelaWaigel May 8, 2019
505e591
update
MicaelaWaigel May 8, 2019
69e2376
update
MicaelaWaigel May 8, 2019
eb31d50
update
MicaelaWaigel May 8, 2019
67a96e0
update
MicaelaWaigel May 9, 2019
397bc61
update
MicaelaWaigel May 9, 2019
afdf8c0
update
MicaelaWaigel May 9, 2019
5ebbcde
update
MicaelaWaigel May 9, 2019
8c453b5
update
MicaelaWaigel May 9, 2019
546cd1f
update
MicaelaWaigel May 9, 2019
a8a4c1e
update
MicaelaWaigel May 9, 2019
8093a34
update
MicaelaWaigel May 9, 2019
ac05c55
update
MicaelaWaigel May 9, 2019
1d637fc
update
MicaelaWaigel May 9, 2019
0810c0f
update
MicaelaWaigel May 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: vendor/bin/heroku-php-apache2 public/
49 changes: 49 additions & 0 deletions app/Colection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\Element;

class Colection extends Model
{
protected $fillable = [
'name', 'description', 'user_id','estado'
];


static public function findPublics(){

return Colection::where('estado',1)->get();

}

public function findColection($id){

$c = Colection::where('id', $id)->get();
return $c[0];

}

public function findElementos(){
return Element::where('colection_id', $this->id)->get();
}

public function findColecForUser($id){
return Colection::where('user_id', $id)->get();
}

public function existe($id){
try{
$c = $this->findColection($id);

if(is_null($c)){
return false;
}else{
return true;
}
}catch(Exception $e){
return false;
}
}
}
19 changes: 19 additions & 0 deletions app/Custom/Http/Request.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php namespace App\Custom\Http;
use \Illuminate\Http\Request as Base;

class Request extends Base {

public function isSecure() {
$isSecure = parent::isSecure();
if ($isSecure) {
return true;
}
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
return true;
} else if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
return true;
}
return false;
}

}
12 changes: 12 additions & 0 deletions app/Element.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Element extends Model
{
protected $fillable = [
'name', 'description', 'colection_id', 'nroPaginas', 'edicion'
];
}
2 changes: 2 additions & 0 deletions app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'lastName' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
Expand All @@ -65,6 +66,7 @@ protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'lastName' => $data['lastName'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
Expand Down
38 changes: 38 additions & 0 deletions app/Http/Controllers/ColeccionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\User;
use App\Colection;

class ColeccionController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}

public function index()
{
return view('crearColeccion');
}

public function create($id){

Colection::create([
'name'=>request('nameColec'),
'description'=>request('desColec'),
'estado'=>0,
'user_id'=>$id
]);

return redirect('home');
}
}
68 changes: 68 additions & 0 deletions app/Http/Controllers/ElementController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\User;
use App\Colection;
use App\Element;

class ElementController extends Controller
{

public function __construct()
{
$this->middleware('auth');
}

public function index($idUsuario, $idColeccion){
$idU=intval($idUsuario);

$coleccion = new Colection;
$coleccion=$coleccion ->findColection($idColeccion);

if($coleccion->user_id !== $idU){
abort(403);
}

$items= $coleccion ->findElementos();
$datos=[$coleccion, $items];
return view('insertarItem', compact('datos'));
}

public function create($idUsuario, $idColeccion){

Element::create([
'name'=>request('nameItem'),
'description'=>request('desItem'),
'colection_id'=>$idColeccion,
'nroPaginas'=>request('nroPag'),
'edicion'=>request('edicion')
]);

return redirect('home');
}

public function update($idUsuario, $idColeccion){

$coleccion = new Colection;
$coleccion=$coleccion ->findColection($idColeccion);
if($coleccion->estado){
$coleccion->estado=0;
}else{
$coleccion->estado=1;
}
$coleccion->save();

return redirect('home');

}

public function destroy($idUsuario, $idColeccion){

Colection::find($idColeccion)->delete();

return redirect('home');
}
}
34 changes: 34 additions & 0 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\User;
use App\Colection;

class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}

/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
$id=auth()->user()->id;
$coleccion = new Colection;
$colecciones=$coleccion ->findColecForUser($id);
return view('home', compact('colecciones'));
}
}
34 changes: 34 additions & 0 deletions app/Http/Controllers/WelcomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use App\Colection;
use App\Element;

class WelcomeController extends Controller
{


public function index(){
$colecciones=Colection::findPublics();

return view('welcome', compact('colecciones'));
}

public function show($id){

$coleccion= new Colection;
if($coleccion->existe($id)){
$coleccion = $coleccion ->findColection($id);
$items= $coleccion ->findElementos();
$usuario=User::find($coleccion->user_id);
$datos=[$coleccion, $items, $usuario];

return view('showItems', compact('datos'));
}else{
abort(404);
}
}
}
52 changes: 52 additions & 0 deletions app/Http/Controllers/perfilController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\User;

class perfilController extends Controller
{

public function __construct()
{
$this->middleware('auth');
}

public function edit($id){

return view('editarPerfil');
}

public function update($id){

if (request('password') == NULL) {
request()->validate([
'name' => 'required',
'lastName' => 'required'
]);
$usuario = User::find($id);
$usuario->name=request('name');
$usuario->lastName=request('lastName');

$usuario->save();

} else {
request()->validate([
'name' => 'required',
'lastName' => 'required',
'password' => ['required', 'confirmed'],
'password_confirmation' => 'required'
]);
$usuario = User::find($id);
$usuario->name=request('name');
$usuario->lastName=request('lastName');
$usuario->password=request('password');

$usuario->save();
}

return redirect('/home');
}
}
3 changes: 2 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -23,6 +24,6 @@ public function register()
*/
public function boot()
{
//
Schema::defaultStringLength(191);
}
}
2 changes: 1 addition & 1 deletion app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
'name','lastName', 'email', 'password',
];

/**
Expand Down
8 changes: 4 additions & 4 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@

'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'host' => env('DB_HOST', 'us-cdbr-gcp-east-01.cleardb.net'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'database' => env('DB_DATABASE', 'gcp_6ae4bb28c0551a2064c7'),
'username' => env('DB_USERNAME', 'b40d64490173b2'),
'password' => env('DB_PASSWORD', 'f9a51705'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
Expand Down
6 changes: 4 additions & 2 deletions database/migrations/2014_10_12_000000_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->string('name')->nullable();
$table->string('lastName')->nullable();
$table->string('email',30)->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();

});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CreatePasswordResetsTable extends Migration
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('email',30)->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Expand Down
Loading