Created
May 3, 2019 21:00
-
-
Save ricardobarantini/8a25328c98516975e4b9900bd669b5bc to your computer and use it in GitHub Desktop.
Exemplo de código para retornar dados em json no Laravel
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 | |
// ... | |
use App\Models\Aluno; | |
public function getAlunos($matricula) | |
{ | |
$alunos = Aluno::where('matricula', $matricula)->get(); | |
if ($alunos->count() > 0) { | |
$data['alunos'] = $alunos; | |
} else { | |
$data['mensagem'] = 'Nenhum aluno encontrado'; | |
} | |
return response()->json($data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment