I'm new in laravel, i'm trying to pass data from view to controller but getting some errors. I have searched but didn't got how can i solve this issue. Please view my code and advice me where i'm wrong?
echo Form::open(array( 'method' => 'post','action' => 'DemoController@savess'));
echo Form::label('name', 'Name');
echo Form::text('name');
echo Form::label('email', 'E-Mail Address');
echo Form::text('email');
echo Form::close();
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class DemoController extends Controller {
/*
|--------------------------------------------------------------------------
| Welcome Controller
|--------------------------------------------------------------------------
|
| This controller renders the "marketing page" for the application and
| is configured to only allow guests. Like most of the other sample
| controllers, you are free to modify or remove it as you desire.
|
*/
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Show the application welcome screen to the user.
*
* @return Response
*/
public function demofunction()
{
$users = \DB::table('user')->get();
foreach ($users as $user)
{
echo $user->name;
echo $user->email;
}
return view('demoview');
}
public function savess(){
}
}
Route::get('demo', 'DemoController@demofunction');
ErrorException in compiled.php line 8658:
Action App\Http\Controllers\DemoController@savess not defined. (View: E:\xampp\htdocs\ayaz\resources\views\demoview.blade.php)
InvalidArgumentException in compiled.php line 8658:
Action App\Http\Controllers\DemoController@savess not defined.
add a different rout: Route::POST('/dashboard/update/{id}', 'DashboardController@update'); Controller: public function update(Request $request, $id) { $the_id = $id; //this is the id. dd($id); //to check your id value. }
$varbl = App::make("ControllerName")->FunctionName($params);
There are various ways of passing data to views:By using the name array. By using with() function. By using compact() function.
Add to routes.php
this line:
Route::post("savess", "DemoController@savess");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With