110 lines
2.9 KiB
PHP
110 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use App\Models\Persona;
|
|
|
|
class PersonaController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
$persona = Persona::withTrashed()-> get();
|
|
|
|
return view('personas.index',["personas"=>$persona]);
|
|
|
|
// $categorias = Categorias::findOrFail(13);
|
|
//$cat = Categorias::where('id_categoria', 1)->first();
|
|
//$categorias = Categorias::where('descripcion', 'Cursos, capacitaciones y formación')->get();
|
|
//$categorias = Categorias::where('descripcion', 'like', '%Prod%')->get();
|
|
|
|
//$categorias = Categorias::orderBy('nombre', 'desc')->get();
|
|
|
|
//$categorias = Categorias::first();
|
|
//$categorias = Categorias::last();
|
|
/*Categorias::count();*/
|
|
}
|
|
public function show($id){
|
|
$persona = Persona::findOrfail($id);
|
|
return view('personas.show', ["per"=>$persona]);
|
|
}
|
|
|
|
public function destroy(Request $request, $id){
|
|
$persona = Persona::findOrfail($id);
|
|
$persona->delete();
|
|
return redirect('/personas');
|
|
}
|
|
|
|
|
|
public function create(){
|
|
return view('personas.new');
|
|
}
|
|
|
|
public function store(Request $request){
|
|
|
|
$persona = new Persona();
|
|
$persona->fill([
|
|
'apellido' => $request->input('apellido'),
|
|
'nombre' => $request->input('nombre'),
|
|
'dni' => $request->input('dni'),
|
|
]);
|
|
$persona->save();
|
|
return redirect('/personas');
|
|
}
|
|
|
|
public function edit($id){
|
|
$persona = Persona::findOrfail($id);
|
|
//$categoria = Categorias::where('id_categoria',$id)->first();
|
|
return view('personas.edit', ["per"=>$persona]);
|
|
}
|
|
|
|
public function update(Request $request, $id){
|
|
$persona = Persona::findOrfail($id);
|
|
$persona->fill([
|
|
'apellido' => $request->input('apellido'),
|
|
'nombre' => $request->input('nombre'),
|
|
'dni' => $request->input('dni'),
|
|
]);
|
|
$persona->update();
|
|
return redirect('/personas');
|
|
}
|
|
|
|
public function restaurar(Request $request, $id){
|
|
$persona = Persona::withTrashed()->findOrfail($id);
|
|
$persona->restore();
|
|
return redirect('/personas');
|
|
}
|
|
/*
|
|
|
|
|
|
|
|
public function show($id){
|
|
$categorias = Categorias::findOrfail($id);
|
|
|
|
return view('categorias.show', ["cat"=>$categorias]);
|
|
}
|
|
|
|
|
|
public function edit($id){
|
|
$categorias = Categorias::findOrfail($id);
|
|
return view('categorias.edit', ["cat"=>$categorias]);
|
|
}
|
|
|
|
|
|
public function update(Request $request, $id){
|
|
$categorias = Categorias::findOrfail($id);
|
|
$categorias->fill([
|
|
'nombre' => $request->input('nombre'),
|
|
'descripcion' => $request->input('descripcion'),
|
|
]);
|
|
$categorias->update();
|
|
return redirect('/categorias');
|
|
}
|
|
|
|
|
|
*/
|
|
|
|
|
|
}
|