Created
July 9, 2016 20:35
-
-
Save MrBeerBrewer/7eb5b54708d79b86700e911149bdcdfa to your computer and use it in GitHub Desktop.
This file contains 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
Routes: | |
Route::resource('/', 'ShoppingController'); | |
Route::get('/prods', 'ProductsController@index'); | |
Controller: | |
<?php | |
#Fetches products on the db and sends them to a view: cart.blade.php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use App\Http\Requests; | |
use App\Product; | |
class ProductsController extends Controller | |
{ | |
/** | |
* List products in products table. | |
* | |
* @return \Illuminate\Http\Response | |
*/ | |
public function index() | |
{ | |
$products = Product::all(); | |
return view('cart')->with('products', $products); | |
} | |
} | |
Another controller: | |
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use App\Http\Requests; | |
use \Cart as Cart; | |
use Validator; | |
class ShoppingController extends Controller | |
{ | |
/** | |
* Main route for the shop. | |
* | |
* @return Response | |
*/ | |
public function index() | |
{ | |
// | |
} | |
public function add(Request $request) | |
{ | |
} | |
/** | |
* Store a newly created resource in storage. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return \Illuminate\Http\Response | |
*/ | |
public function store(Request $request) | |
{ | |
// | |
} | |
/** | |
* Update the specified resource in storage. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param int $id | |
* @return \Illuminate\Http\Response | |
*/ | |
public function update(Request $request, $id) | |
{ | |
// | |
} | |
/** | |
* Remove the specified resource from storage. | |
* | |
* @param int $id | |
* @return \Illuminate\Http\Response | |
*/ | |
public function destroy($id) | |
{ | |
// | |
} | |
} | |
blade: | |
@extends('layouts.master') | |
@section('title', 'Shopping Cart') | |
@section('content') | |
<div class="container"> | |
<h1>Sexy and Shiny promo. 30% flat off on these products!</h1> | |
@if (sizeof(Cart::content()) > 0) | |
@foreach ($products as $item) | |
<div class="row"> | |
<div class="col-md-12 well well-lg"> | |
<div class="col-md-3"> | |
<img src="{{ $item->img }} " alt="{{ $item->img }}" class="img-thumbnail"> | |
</div> | |
<div class="col-md-3"> | |
<h3>Name: {{ $item->name }}</h2> | |
<h4>Price: {{ $item->price }}</h3> | |
<h5>Stock: 3</h3> | |
</div> | |
<div class="col-md-3"> | |
<p><strong>Desc: {{ $item->desc }}</strong></p> | |
</div> | |
<div class="row"> | |
<div class="col-md-12 text-center"> | |
<small>Tags: {{ $item->seoInfo }}</small> | |
</div> | |
</div> | |
</div> | |
</div> | |
@endforeach | |
@else | |
<h3>You have no items in your cart</h3> | |
@endif | |
</div> <!-- end container --> | |
@endsection | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment