Last active
July 20, 2020 21:26
-
-
Save sabid/14bf8a4a03368c1e6e2ac39cb7c94ea2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// resources\view\products\index.blade.php | |
@section('content') | |
// $products | |
@foreach ($products as $product) | |
{{ $product->name; }} | |
@endforeach | |
@endsection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class Product extends Model | |
{ | |
/** | |
* The attributes that are mass assignable. | |
* | |
* @var array | |
*/ | |
// protected $fillable = [ | |
// 'name', | |
// 'description', | |
// 'price' | |
// ]; | |
/** | |
* The attributes that aren't mass assignable. | |
* | |
* @var array | |
*/ | |
protected $guarded = []; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Product; | |
use Illuminate\Http\Request; | |
class ProductController extends Controller | |
{ | |
/** | |
* Display a listing of the product. | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function index() | |
{ | |
$products = collect([ | |
new Product([ | |
'id' => 1, | |
'name' => 'Juego de sala', | |
'price' => 6000 | |
]), | |
new Product([ | |
'id' => 2, | |
'name' => 'Estufa', | |
'price' => 9000 | |
]) | |
]); | |
//dd($products); | |
return view('products.index', [ | |
'products' => $products | |
]); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Route\web.php */ | |
/* | |
* Resource Controller | |
* El nombre en plural y el nombre del controlador en singular, | |
* unido con la palabra controller | |
*/ | |
Route::resource('products', 'ProductController'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment