Skip to content

Instantly share code, notes, and snippets.

@fayqLs
Last active March 22, 2023 12:56
Show Gist options
  • Save fayqLs/c4c35b97d8266f5fb5cf025da1c3f0db to your computer and use it in GitHub Desktop.
Save fayqLs/c4c35b97d8266f5fb5cf025da1c3f0db to your computer and use it in GitHub Desktop.
BUSCA O REGISTRO PELO ID E POR OUTRA COLUNA DA TABELA
<?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