app/Http/Controllers/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;
    if ($request->hasFile('avatar') && $request->file('avatar')->isValid())
    {
      $novoAluno->avatar = $request->avatar->store('alunos');
    }
    $novoAluno->save();
    return redirect()
      ->route('alunos.index')
      ->with('success', 'Aluno cadastrado com sucesso!');
  }
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 ; if ( $ request -> hasFile ( 'avatar' ) && $ request -> file ( 'avatar' ) -> isValid ( ) ) { $ novoAluno -> avatar = $ request -> avatar -> store ( 'alunos' ) ; } $ novoAluno -> save ( ) ; return redirect ( ) -> route ( 'alunos.index' ) -> with ( 'success' , 'Aluno cadastrado com sucesso!' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .