저는 MVC를 처음 접했고 전혀 이해하지 못합니다. 나는 하나 개의 테이블이있는 데이터베이스가Eloquent ORM을 사용하여 Laravel의 데이터베이스에서 데이터를 검색하는 방법
products
라는이 I가 내가 그렇게
Route::get('products', function()
{
return View::make('products');
});
같은 경로를 그리고 내보기이
과 같은<?php
class Product extends Eloquent {
// MASS ASSIGNMENT -------------------------------------------------------
// define which attributes are mass assignable (for security)
// we only want these 3 attributes able to be filled
protected $fillable = array('type', 'brand', 'image');
}
과 같은
Product
라는 모델
@extends('master')
@section('content')
PRODUCTS
@foreach($products as $product)
{{ $product->type }}
@endforeach
@stop
이렇게 모든 행을 볼 수 있습니다. $products = Product::all();
그러나 나는 이것이 어디로 가는지 이해하지 못한다. 보기에 표시됩니까? 그것은 모델에 들어 있습니까? 그것은 루트에 가나 요? 내 현재 @foreach 루프는 단지 undefined variable: products
이 될 수 있습니까?
합니다. – arma