Created
March 11, 2020 03:48
-
-
Save parzibyte/ce93e4745890eee354d137e34f4547e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Cliente; | |
use Illuminate\Http\Request; | |
class ClientesController extends Controller | |
{ | |
/** | |
* Display a listing of the resource. | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function index() | |
{ | |
return view("clientes.clientes_index", ["clientes" => Cliente::all()]); | |
} | |
/** | |
* Show the form for creating a new resource. | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function create() | |
{ | |
return view("clientes.clientes_create"); | |
} | |
/** | |
* Store a newly created resource in storage. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return \Illuminate\Http\Response | |
*/ | |
public function store(Request $request) | |
{ | |
(new Cliente($request->input()))->saveOrFail(); | |
return redirect()->route("clientes.index")->with("mensaje", "Cliente agregado"); | |
} | |
/** | |
* Display the specified resource. | |
* | |
* @param \App\Cliente $cliente | |
* @return \Illuminate\Http\Response | |
*/ | |
public function show(Cliente $cliente) | |
{ | |
// | |
} | |
/** | |
* Show the form for editing the specified resource. | |
* | |
* @param \App\Cliente $cliente | |
* @return \Illuminate\Http\Response | |
*/ | |
public function edit(Cliente $cliente) | |
{ | |
return view("clientes.clientes_edit", ["cliente" => $cliente]); | |
} | |
/** | |
* Update the specified resource in storage. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \App\Cliente $cliente | |
* @return \Illuminate\Http\Response | |
*/ | |
public function update(Request $request, Cliente $cliente) | |
{ | |
$cliente->fill($request->input()); | |
$cliente->saveOrFail(); | |
return redirect()->route("clientes.index")->with("mensaje", "Cliente actualizado"); | |
} | |
/** | |
* Remove the specified resource from storage. | |
* | |
* @param \App\Cliente $cliente | |
* @return \Illuminate\Http\Response | |
*/ | |
public function destroy(Cliente $cliente) | |
{ | |
$cliente->delete(); | |
return redirect()->route("clientes.index")->with("mensaje", "Cliente eliminado"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment