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

Commit

Permalink
Validaciones Sedes y Historial
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc15975 committed Nov 26, 2022
1 parent f39cf03 commit fb14224
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 42 deletions.
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');
}
}
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
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'

];
}
}

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
11 changes: 8 additions & 3 deletions resources/views/admin/Historial/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@
</select>

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

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

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

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

</div>
Expand Down
19 changes: 16 additions & 3 deletions resources/views/admin/Sedes/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,24 @@
<form action="{{ url('sedes') }}" class="was-validated" method="post">
{!! csrf_field() !!}
<label>Nombre sede</label></br>
<input type="text" name="nombre_sede" id="nombre_sede" class="form-control" required></br>
<input type="text" name="nombre_sede" id="nombre_sede" class="form-control" required>
@error('nombre_sede')
<li class="text-danger">{{$message}}</li>
@enderror

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

</br>
<label>Telefono de la Sede</label></br>
<input type="text" name="telefono_sede" id="telefono_sede" class="form-control" required></br>
<input type="text" name="telefono_sede" id="telefono_sede" pattern="[0-9]{1,10}" oninput="this.value = this.value.replace(/[^0-9.]+/g, '').slice(0,8) ;" class="form-control" required>
@error('telefono_sede')
<li class="text-danger">{{$message}}</li>
@enderror</br>

<label>Ciudad Sede</label></br>
<select class="form-select" name="ciudad_sede" id="ciudad_sede" required aria-label="Default select example">
Expand Down
19 changes: 15 additions & 4 deletions resources/views/admin/Sedes/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@
<input type="hidden" name="Id_Sede" id="Id_Sede" value="{{$Sede->id_sede}}" />

<label>Name</label></br>
<input type="text" required name="nombre_sede" id="nombre_sede" value="{{$Sede->nombre_sede}}" class="form-control"></br>
<input type="text" required name="nombre_sede" id="nombre_sede" value="{{$Sede->nombre_sede}}" class="form-control">
@error('nombre_sede')
<li class="text-danger">{{$message}}</li>
@enderror</br>
<label>Dirrecion de la sede</label></br>
<input type="text" required name="direccion_sede" id="direccion_sede" value="{{$Sede->direccion_sede}}" class="form-control"></br>
<input type="text" required name="direccion_sede" id="direccion_sede" value="{{$Sede->direccion_sede}}" class="form-control">
@error('direccion_sede')
<li class="text-danger">{{$message}}</li>
@enderror</br>
<label>telefono_sede</label></br>
<input type="text" required name="telefono_sede" id="telefono_sede" value="{{$Sede->telefono_sede}}" class="form-control"></br>
<input type="text" required name="telefono_sede" id="telefono_sede" value="{{$Sede->telefono_sede}}" class="form-control">
@error('telefono_sede')
<li class="text-danger">{{$message}}</li>
@enderror

</br>
<label>Ciudad sede</label></br>
<select class="form-select" required name="ciudad_sede" id="ciudad_sede" aria-label="Default select example">
<option selected>Selecione la ciudad</option>
<option selected value="">Selecione la ciudad</option>
<option value="La Paz">La Paz</option>
<option value="Santa Cruz">Santa cruz</option>
<option value="Cochabamba">Cochabamba</option>
Expand Down

0 comments on commit fb14224

Please sign in to comment.