Created
February 11, 2017 18:31
-
-
Save ludioao/e53db1b84375cb85817313f68d89aeac to your computer and use it in GitHub Desktop.
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
// 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