You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

74 lines
1.8 KiB

<?php
namespace App\Http\Controllers;
use App\Models\Docentes;
use Illuminate\Http\Request;
class DocentesController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$docentes = Docentes::all();
return view('docentes', ['docentes' => $docentes]);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$docentes = Docentes::all();
return view('docentesCrearEditar',['docentes'=>$docentes]);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
$docente = new Docentes($request->all());
$docente->save();
return redirect()->route('docentes.index')->with('success', 'Docente creado exitosamente.');
}
/**
* Display the specified resource.
*/
public function show(Docentes $docente)
{
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$docentes = Docentes::all();
$docente = Docentes::find($id);
return view('docentesCrearEditar', ['docentes' => $docentes, 'docente' => $docente]) ;
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id)
{
$docente = Docentes::find($id);
$docente->update($request->all());
return redirect()->route('docentes.index')->with('success', 'Docente actualizado correctamente');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
$docente = Docentes::find($id);
$docente->delete();
return redirect()->route('docentes.index')->with('success', 'Docente eliminado correctamente');
}
}