-
-
Save fayqLs/c4c35b97d8266f5fb5cf025da1c3f0db to your computer and use it in GitHub Desktop.
BUSCA O REGISTRO PELO ID E POR OUTRA COLUNA DA TABELA
This file contains hidden or 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 | |
# BUSCA O REGISTRO PELO ID USANDO O MÉTODO find | |
$id = 1; | |
$cliente = Cliente::find($id); | |
if ($cliente) | |
{ | |
echo "Cliente: {$cliente->nome}"; | |
} | |
# BUSCA O REGISTRO POR OUTRO CAMPO USANDO O MÉTODO where | |
$cpf = '03025652199'; | |
$cliente = Cliente::where('cpf', '=', $cpf)->first(); | |
if($cliente) | |
{ | |
echo "Cliente: {$cliente->nome}"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment