Skip to content

Instantly share code, notes, and snippets.

@ludioao
Created February 11, 2017 18:31
Show Gist options
  • Save ludioao/e53db1b84375cb85817313f68d89aeac to your computer and use it in GitHub Desktop.
Save ludioao/e53db1b84375cb85817313f68d89aeac to your computer and use it in GitHub Desktop.
// na view
{!! Form::open(['method' => 'post', 'action' => 'GermoManager@storeAcesso', $germo->id]) !!}
fields...
{!! Form::close() !!}
// la em routes.php
Route::get('/cadastrar-acesso-germoplasma/{germo_id}', 'GermoManager@createAcesso');
Route::post('/cadastrar-acesso-germoplasma/{germo_id}/salvar', 'GermoManager@storeAcesso');
// no controller
class GermoManager extends Controller {
// form acesso.
public function createAcesso($germo_id) {
$germo = Germoplasma::findOrFail($germo_id);
return view('germoplasma.create_acesso', [
'germo' => $germo
]);
}
// store acesso.
public function storeAcesso(Request $request, $germo_id) {
$germo = Germoplasma::findOrFail($germo_id);
$data = $request->all();
$acesso = new Acesso($request->all());
if ($germo->acesso()->save($acesso)) {
$msg = 'Acesso criado com sucesso!';
}
else {
$msg = 'Falha na criação do acesso!';
}
return redirect()->back()->with('msg', $msg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment