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

Commit

Permalink
Merge branch 'main' of https://github.com/rats4final/citas
Browse files Browse the repository at this point in the history
  • Loading branch information
XSlayer67 committed Dec 1, 2022
2 parents 9d630bf + 742acbc commit 1b91bf8
Show file tree
Hide file tree
Showing 26 changed files with 986 additions and 136 deletions.
5 changes: 3 additions & 2 deletions app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CreateNewUser implements CreatesNewUsers
public function create(array $input)
{
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
//'name' => ['required', 'string', 'max:255'],
'email' => [
'required',
'string',
Expand All @@ -34,10 +34,11 @@ public function create(array $input)
])->validate();

return User::create([
'name' => $input['name'],
//'name' => $input['name'],
'email' => $input['email'],
'username' => $input['username'],
'password' => Hash::make($input['password']),
'rol' => 1,
]);
}
}
11 changes: 6 additions & 5 deletions app/Http/Controllers/HistorialController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
use App\Models\User;
use App\Models\Persona;
use Illuminate\Http\Request;
use App\Http\Requests\StoreHistorialRequest;
use App\Http\Requests\EditHistorialRequest;



class HistorialController extends Controller
{
Expand All @@ -32,7 +36,7 @@ public function create()
//return $Users;
}

public function store(Request $request)
public function store(StoreHistorialRequest $request)
{
//
$Datos_Historia=request()->except('_token');
Expand Down Expand Up @@ -70,7 +74,7 @@ public function edit($Historial)
}


public function update(Request $request, $historial)
public function update(EditHistorialRequest $request, $historial)
{
//
$input = $request->all();
Expand All @@ -89,9 +93,6 @@ public function destroy( $Historial)
{
//
Historial::destroy($Historial);

// $Historial->delete();

return redirect('/Historial');
}
}
4 changes: 3 additions & 1 deletion app/Http/Controllers/PersonaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function show(Persona $persona)
*/
public function edit(Persona $persona)
{
return view('admin.Persona.edit', compact('persona'));
$personas = Persona::get();
$tipos_sangre = TipoSangre::get();
return view('admin.Persona.edit', compact('tipos_sangre','personas','persona'));
}

/**
Expand Down
7 changes: 5 additions & 2 deletions app/Http/Controllers/SedeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Illuminate\Http\Request;

use App\Models\Sede;
use App\Http\Requests\StoreSedeRequest;
use App\Http\Requests\EditSedeRequest;


class SedeController extends Controller
{
Expand All @@ -24,7 +27,7 @@ public function create()
}


public function store(Request $request)
public function store(StoreSedeRequest $request)
{
//
$Datos_Sedes=request()->except('_token');
Expand All @@ -50,7 +53,7 @@ public function edit($Id_Sede)
return View ('admin.Sedes.edit',compact('Sede'));
}

public function update(Request $request, $Id_Sede)
public function update(EditSedeRequest $request, $Id_Sede)
{
//

Expand Down
38 changes: 32 additions & 6 deletions app/Http/Controllers/UsuarioController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

namespace App\Http\Controllers;

use App\Models\Usuario;
//use App\Models\Usuario;
use App\Models\User;
use App\Models\Persona;
use App\Models\TipoSangre;

use Illuminate\Http\Request;
class UsuarioController extends Controller
{
Expand All @@ -13,7 +17,9 @@ class UsuarioController extends Controller
*/
public function index()
{
//
$usuarios = user::with(['persona'])->get();
return view('admin.user.index', compact('usuarios'));
//return $usuario;
}
/**
* Show the form for creating a new resource.
Expand All @@ -22,7 +28,9 @@ public function index()
*/
public function create()
{
//
$personas = Persona::get();
$tipos_sangre = TipoSangre::get();
return view('admin.user.create', compact('tipos_sangre','personas'));
}

/**
Expand All @@ -33,7 +41,16 @@ public function create()
*/
public function store(Request $request)
{
//
$datos = $request->all();
Persona::create($datos);
$id = Persona::latest('id_persona')->first();
//return to_route('personas.index');
$datos1 = ['rol'=>"1", 'estado'=>1, 'id_persona'=>$id->id_persona];
$datosUser = array_merge($datos, $datos1);
User::create($datosUser);
return redirect('/Usuario');


}

/**
Expand Down Expand Up @@ -76,8 +93,17 @@ public function update(Request $request, Usuario $usuario)
* @param \App\Models\Usuario $usuario
* @return \Illuminate\Http\Response
*/
public function destroy(Usuario $usuario)
public function destroy(Request $request, $usuario)
{
//
$input = $request->all();

$usuarios = User::find($usuario);

$estado = ['estado'=>0];

$usuarios->update($estado);

//Redirecionas para no bugear el jalar de datos con reddirect para recargar la vista totalmente
return redirect('/Usuario');
}
}
28 changes: 28 additions & 0 deletions app/Http/Requests/EditHistorialRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class EditHistorialRequest extends FormRequest
{
public function authorize()
{
return true;
}

public function rules()
{
return [
'detalles_historial' => 'required|string|min:20|max:255',
];
}
public function messages()
{
return [
'detalles_historial.required' => 'Es necesesario que tenga datos en estte campo',
'detalles_historial.min' => 'Los detalles minimamente deben tener mas de 20 caracteres',
'detalles_historial.max' => 'Los detalles no deben superar los 255 caracteres'
];
}
}
41 changes: 41 additions & 0 deletions app/Http/Requests/EditSedeRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class EditSedeRequest extends FormRequest
{
public function authorize()
{
return true;
}

public function rules()
{
return [
'nombre_sede' => 'required|string|min:10|max:100',
'direccion_sede' => 'required|string|min:10|max:120',
'telefono_sede' => 'required|integer|min:8'

];
}
public function messages()
{
return [
'nombre_sede.required' => 'Es neceserio que este campo este llenado',
'nombre_sede.min' => 'El nombre minimamente debe tener mas de 10 caracteres',
'nombre_sede.max' => 'El nombre no debe superar los 120 caracteres',

'direccion_sede.required' => 'Es neceserio que este campo este llenado',
'direccion_sede.min' => 'La dirrecion minimamente debe tener mas de 10 caracteres',
'direccion_sede.max' => 'La dirrecion no debe superar los 120 caracteres',

'telefono_sede.required' => 'Es neceserio que este campo este llenado',
'telefono_sede.integer' => 'Debe ser un numero no una palabra',
'telefono_sede.min' => 'El telefono minimamente debe tener 8 numeros',
'telefono_sede.max' => 'El telefono maximo debe tener 10 numeros'

];
}
}
29 changes: 29 additions & 0 deletions app/Http/Requests/StoreHistorialRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreHistorialRequest extends FormRequest
{

public function authorize()
{
return true;
}

public function rules()
{
return [
'detalles_historial' => 'required|string|min:20|max:255',
];
}
public function messages()
{
return [
'detalles_historial.required' => 'Es necesesario que tenga datos en estte campo',
'detalles_historial.min' => 'Los detalles minimamente deben tener mas de 20 caracteres',
'detalles_historial.max' => 'Los detalles no deben superar los 255 caracteres'
];
}
}
10 changes: 0 additions & 10 deletions app/Http/Requests/StorePersonaRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,11 @@

class StorePersonaRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
Expand Down
37 changes: 25 additions & 12 deletions app/Http/Requests/StoreSedeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,41 @@
namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

use Illuminate\Http\Request;
class StoreSedeRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/

public function authorize()
{
return true;
}

/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
//
'nombre_sede' => 'required|string|min:10|max:100',
'direccion_sede' => 'required|string|min:10|max:120',
'telefono_sede' => 'required|integer|min:8'

];
}
public function messages()
{
return [
'nombre_sede.required' => 'Es neceserio que este campo este llenado',
'nombre_sede.min' => 'El nombre minimamente debe tener mas de 10 caracteres',
'nombre_sede.max' => 'El nombre no debe superar los 120 caracteres',

'direccion_sede.required' => 'Es neceserio que este campo este llenado',
'direccion_sede.min' => 'La dirrecion minimamente debe tener mas de 10 caracteres',
'direccion_sede.max' => 'La dirrecion no debe superar los 120 caracteres',

'telefono_sede.required' => 'Es neceserio que este campo este llenado',
'telefono_sede.integer' => 'Debe ser un numero no una palabra',
'telefono_sede.min' => 'El telefono minimamente debe tener 8 numeros',
'telefono_sede.max' => 'El telefono maximo debe tener 10 numeros'

];
}
}

3 changes: 3 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class User extends Authenticatable
'name',
'email',
'username',
'id_persona',
'rol',
'estado',
'password',
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->Integer('id_persona')->unsigned();
$table->Integer('id_persona')->unsigned()->nullable();
$table->foreign('id_persona')->references('id_persona')->on('personas');
});
}
Expand Down
11 changes: 8 additions & 3 deletions resources/views/admin/Historial/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@
</select>

<label>Fecha de la historia</label></br>
<input type="datetime-local" name="fecha_historial" id="fecha_historial" class="form-control" required></br>
<input type="datetime-local" name="fecha_historial" id="fecha_historial" min="2022-11-26 00:00" max="2022-12-30 10:00" class="form-control" required></br>

<label>Detalles de la historia</label></br>
<input type="text" name="detalles_historial" id="detalles_historial" class="form-control" required></br>
<input type="text" name="detalles_historial" id="detalles_historial" class="form-control" required>
@error('detalles_historial')
<li class="text-danger">{{$message}}</li><br>
@enderror
</br>

<input type="submit" value="Save" class="btn btn-success"></br>

<input type="submit" value="Subir la Historia" class="btn btn-success"></br>
</form>

</div>
Expand Down
Loading

0 comments on commit 1b91bf8

Please sign in to comment.