php - view or redirect in laravel not working for another method -


i'm new in laravel 5 framework. make form. in form, create 1 button search inventory codes , fill text input in form. controllers work well. but, when try return view('cari'), browser doesn't show anything. these codes: in controller:

public function search(){       echo "212";       return view('cari'); } 

the index method in controller works well.

public function checkaction()     {         if(input::get('submit')) {             $this->create();          } else if(input::get('cari')) {             $this->search();         }     } 

then, try way use return redirect('cari'); in controller no display anything. if edit post in routes.php , directly call mycontroller@search display cari.blade.php. but, want search form trigger browse inventory items. give me clues?.

this permintaan.blade.php created button checkaction():

<form class="form-horizontal" role="form" method="post" action="{{ url('/permintaan') }}">                         <input type="hidden" name="_token" value="{{ csrf_token() }}">                          <div class="form-group">                             <label class="col-md-4 control-label">kode inventaris</label>                             <div class="col-md-6">                                 <input type="text" class="form-control" name="kodeinventaris" value="{{ old('kdinventaris') }}">                             </div>                             <button type="submit" class="btn btn-primary" name="cari" value="cari">                                 cari                             </button>                         </div> .... </form> 

these create , store functions:

public function create(request $request)     {         $data = $request->except('_token');         $validator = $this->validator($data);          if ($validator->fails())         {             $this->throwvalidationexception(                 $request, $validator             );         }         $this->store($data);         $request->find($request);         return redirect()->back()->with('message', 'permintaan berhasil diinput');     }      public function store(array $data){         permintaan::create([             'kdinventaris' => $data['kodeinventaris'],             'namainventaris' => $data['namainventaris'],             'jenis' => $data['optinventaris'],             'jumlah' => $data['jumlah'],             'spesifikasi' => $data['spesifikasi'],             'keterangan' => $data['keterangan'],         ]);     } 

when redirect. works, got blank page again. , replace echo. works, has message , got successful redirect: "http/1.0 302 found cache-control: no-cache date: mon, 01 jun 2015 16:04:33 gmt location: http://localhost:8000/permintaan redirecting http://localhost:8000/permintaan." wonder return redirect()->back()->with('message', 'permintaan berhasil diinput');

you're doing operation , not returning view in controller

you can by

public function checkaction()     {         if(input::get('submit')) {             $this->create();              return view('cari')->with('message', 'succesfully created');         } else if(input::get('cari')) {             $this->search();              return view('cari')->with('message', 'search done');         }     } 

note :

i dont know of view name using same name cari can replace view have.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -