app/Http/Controllers/Api/AlunosController.php
/**
   * Store a newly created resource in storage.
   *
   * @param  \Illuminate\Http\Request  $request
   * @return \Illuminate\Http\Response
   */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
  {
    $this->validator($request);
    $novoAluno = new Aluno();
    $novoAluno->name = $request->name;
    $novoAluno->email = $request->email;
    $novoAluno->curso_id = $request->curso_id;
    $novoAluno->save();
    $aluno = $novoAluno->where('id', $novoAluno->id)->with('Curso')->first();
    return response()->json(['aluno' => $aluno]);
  }
public function store ( Request $ request ) { $ this -> validator ( $ request ) ; $ novoAluno = new Aluno ( ) ; $ novoAluno -> name = $ request -> name ; $ novoAluno -> email = $ request -> email ; $ novoAluno -> curso_id = $ request -> curso_id ; $ novoAluno -> save ( ) ; $ aluno = $ novoAluno -> where ( 'id' , $ novoAluno -> id ) -> with ( 'Curso' ) -> first ( ) ; return response ( ) -> json ( [ 'aluno' => $ aluno ] ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .