guys.
I am newbie in laravel and I like to have a droplist with the values from the database table. How can I do it, actually I have an error: "Undefined variable: claims" (I think data is not passing) - I think it's because of few reasons: because of View function or different reasons.
Example of a droplist I like to have(taking the values from the db):
Definitions of my values and variables:
mainpage - my html page
Drop - my table with the name "claim_type" in the db
$claims - variable with info from the table "claim_type" from the database
Here is my Controller with the name MainController:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Main;
use App\Drop;
class MainController extends Controller
{
public function index()
{
$claims = Drop::all();
return View::make('mainpage')->with('users', $claims);
}
And my html:
<p> Claim type:
<select>
<option value="$claims->id"></option>
<option value="$claims->id"></option>
<option value="$claims->id"></option>
<option value="$claims->id"></option>
</select>
</p>
My route:
Route::post('/mainpage', 'MainController@index');
Actually, saw a lot of articles, please explain me how it works.
Thank you!
I hope this post will help also for the different coders
Reviewed articles: Laravel : Getting Single value from the database using pluck
get a single value from the database using laravel
Why I get "Undefined variable" in Laravel view?
Laravel 4: ErrorException Undefined variable
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2t2GQfu
via IFTTT
Aucun commentaire:
Enregistrer un commentaire