I´m trying to after save chamada in the function store then show it in the view show.
I'm using this route to create: /tipificacao/2/chamada/create chamada is saved in the DB but when i call the view it gives me a error or dont show any data the URI the is presented is http://localhost:8000/despiste/{despiste}/chamada and it should be ../despiste/2/chamada/8
after save chamada if i call the link ../tipificacao/2/chamada/8 (8 is id of chamada that was created) it show me correct
this is my function store
public function store()
{
//
$chamada = new Chamada;
$chamada->nrCliente = Input::get('nrCliente');
$chamada->idUser = 1;//$idUser;
$chamada->idTipificacao = Input::get('idTipificacao');
$chamada->textoDespiste = Input::get('tDespiste');
if ($chamada->nrCliente)
$chamada->contacto = Input::get('telefone');
$chamada->userSessao = getenv("username");//OR $_SERVER['username']
$chamada->save();
//$chamada = $chamada->id; UPDATE I comment this line to show data in the view
return View::make('despiste.chamada.show')->with('chamada', $chamada);
//Also tried with
//return View::make('despiste.chamada.show', compact('chamada')); //not showing values
//return View::make('despiste.chamada.show', ['idTipificacao' => $chamada->idTipificacao, 'idChamada' => $chamada->id]); --> ErrorException (E_UNKNOWN) Trying to get property of non-object
}
function show
public function show($idTipificacao, $idChamada)
{
$chamada = Chamada::find($idChamada);
return View::make('despiste.chamada.show')->with('chamada', $chamada);
}
this function are in DespisteChamadaController
the view show.blade.php
@extends('layouts.default')
@section('content')
<h1>Despiste: {{ $chamada['idTipificacao'] }}</h1> <!-- -->
<h2>Chamada: {{ $chamada['id'] }}</h2>
<div class="jumbotron text-center">
<p>
<strong>#Cliente:</strong> {{ $chamada['nrCliente'] }}<br>
<strong>User:</strong> {{ $chamada['idUser'] }}<br>
<strong>Despiste:</strong> {{ $chamada['textoDespiste'] }}<br>
<strong>Contacto:</strong> {{ $chamada['contacto'] }}
</p>
</div>
@stop
What i'm my doing wrong?
UPDATE Find one error, i'm getting now the data but my URI is /despiste/{despiste}/chamada and it should be /despiste/2/chamada/9 (9 the id chamada that was created)
I find the problem! I needed to
return Redirect::route('despiste.chamada.show', ['despiste' => $chamada->idTipificacao ,'chamada' => $chamada->id]);
and not make a view
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community