Commit dcc8f539 by Angel MAS

new vars

parent 84d2b8c0
...@@ -6,17 +6,53 @@ use Illuminate\Http\Request; ...@@ -6,17 +6,53 @@ use Illuminate\Http\Request;
use App\Http\Requests; use App\Http\Requests;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Yajra\Datatables\Datatables; use Yajra\Datatables\Datatables;
//use Onestartup\Blog\Model\EntryCategory as Category; use Onestartup\Product\Model\Product;
use Onestartup\Product\Model\ProductCategory as Category;
class ProductController extends Controller class ProductController extends Controller
{ {
public function index(Request $request) public function index(Request $request)
{ {
if(isset($request->category)){
$category = Category::where('slug', $request->category)->first();
$products = $category->products()->where('active', true)->paginate(15);
} else {
$products = Product::where('active', true)->paginate(3);
}
$otros = Product::where('active', true)->inRandomOrder()->take(3)->get();
$categories = Category::where('active', true)->get();
return view('product-public::list')
->with('categories', $categories)
->with('otros', $otros)
->with('products', $products);
} }
public function show($slug) public function show($slug)
{ {
$product = Product::where('slug',$slug)->first();
$otros = $product->category->products()->where('active', true)->take(3)->get();
$categories = Category::all();
if ($product != null) {
if (!$product->active) {
return redirect('inactivo');
}
} else {
return redirect('no_existe');
}
return view('product-public::single')
->with('product', $product)
->with('categories', $categories)
->with('otros', $otros);
} }
......
{!! Form::open(['route'=> ['add.comment', $post->slug],'method'=>'POST']) !!}
{!! Form::label('name', 'Nombre', ['class'=>'control-label']) !!}<br>
{!! Form::text('name', null, ["required"=>"required"]) !!}<br>
{!! Form::label('email', 'Correo', ['class'=>'control-label']) !!}<br>
{!! Form::email('email', null, ["required"=>"required"]) !!}<br>
{!! Form::label('comment', 'Deja tu comentario', ['class'=>'control-label']) !!}<br>
{!! Form::textarea('comment', null, ["required"=>"required", "cols"=>"30", "rows"=>"5"]) !!}<br>
{!! Form::submit('Enviar comentario', ['class' => 'btn btn-submit']) !!}
{!! Form::close() !!}
\ No newline at end of file
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
<html> <html>
<head> <head>
<title> <title>
{{$post->title or "Titulo general"}} {{$product->name or "PCatalogo de proeudtos"}}
</title> </title>
@include('blog-public::metatags') @include('product-public::metatags')
</head> </head>
<body> <body>
{{-- Aqui toda la estructura del blog--}} {{-- Aqui toda la estructura del blog--}}
...@@ -17,11 +17,6 @@ ...@@ -17,11 +17,6 @@
<script src='https://unpkg.com/sweetalert/dist/sweetalert.min.js'></script> <script src='https://unpkg.com/sweetalert/dist/sweetalert.min.js'></script>
<script src='https://cdn.jsdelivr.net/jquery.jssocials/1.4.0/jssocials.min.js' type='text/javascript'></script> <script src='https://cdn.jsdelivr.net/jquery.jssocials/1.4.0/jssocials.min.js' type='text/javascript'></script>
<script src='//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5a139cd3addf2e26' type='text/javascript'></script> <script src='//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5a139cd3addf2e26' type='text/javascript'></script>
@if(Session::has('comment'))
<script type="text/javascript">
swal("Gracias por tu comentario", "Tu comentario está siendo moderado", "success")
</script>
@endif
<!-- ******************************************* --> <!-- ******************************************* -->
......
@extends('blog-public::layout') @extends('product-public::layout')
@section('content') @section('content')
...@@ -9,12 +9,12 @@ Listado de entradas ...@@ -9,12 +9,12 @@ Listado de entradas
</p> </p>
<p> <p>
Entradas todas Productos todas
{{$posts}} {{$products}}
</p> </p>
<p> <p>
Entradas al azar Productos al azar
{{$otros}} {{$otros}}
</p> </p>
...@@ -22,6 +22,6 @@ Listado de entradas ...@@ -22,6 +22,6 @@ Listado de entradas
<p> <p>
Paginacion: Paginacion:
{!! $posts->links() !!} {!! $products->links() !!}
</p> </p>
@endsection @endsection
\ No newline at end of file
...@@ -4,19 +4,19 @@ ...@@ -4,19 +4,19 @@
<meta content='' name='description'> <meta content='' name='description'>
<meta content='width=device-width, initial-scale=1' name='viewport'> <meta content='width=device-width, initial-scale=1' name='viewport'>
<meta content="{{isset($post) ? strip_tags(substr($post->body, 0, 120), '') :'Descripcion general del blog'}}" name='description'> <meta content="{{isset($product) ? strip_tags(substr($product->description, 0, 120), '') :'Descripcion general del product'}}" name='description'>
<link href="{{isset($post) ? route('show.blog', $post->slug) : route('main.blog')}}" rel='canonical'> <link href="{{isset($product) ? route('show.product', $product->slug) : route('main.product')}}" rel='canonical'>
<meta content='es_MX' property='og:locale'> <meta content='es_MX' property='og:locale'>
<meta content='website' property='og:type'> <meta content='website' property='og:type'>
<meta content="{{$post->title or 'Titulo general del blog'}}" property='og:title'> <meta content="{{$product->name or 'Titulo general del blog'}}" property='og:title'>
<meta content="{{isset($post) ? strip_tags(substr($post->body, 0, 120), '') :'Descripcion general del blog'}}" property='og:description'> <meta content="{{isset($product) ? strip_tags(substr($product->description, 0, 120), '') :'Descripcion general del product'}}" property='og:description'>
<meta content="{{isset($post) ? route('show.blog', $post->slug) : route('main.blog')}}" property='og:url'> <meta content="{{isset($product) ? route('show.product', $product->slug) : route('main.product')}}" property='og:url'>
<meta content='ODESSA' property='og:site_name'> <meta content='{{env('APP_NAME')}}' property='og:site_name'>
<meta content="{{isset($post) ? asset('storage').'/'.$post->cover : asset('assets/img/Odessa-Seguros-alta-2.png')}}" property='og:image'> <meta content="{{asset('assets/img/Odessa-Seguros-alta-2.png')}}" property='og:image'>
<meta content="{{isset($post) ? asset('storage').'/'.$post->cover : asset('assets/img/Odessa-Seguros-alta-2.png')}}" property='og:image:secure_url'> <meta content="{{asset('assets/img/Odessa-Seguros-alta-2.png')}}" property='og:image:secure_url'>
<meta content='summary' name='twitter:card'> <meta content='summary' name='twitter:card'>
<meta content="{{isset($post) ? strip_tags(substr($post->body, 0, 120), '') :'Descripcion general del blog'}}" name='twitter:description'> <meta content="{{isset($product) ? strip_tags(substr($product->description, 0, 120), '') :'Descripcion general del product'}}" name='twitter:description'>
<meta content="{{$post->title or 'titulo general del blog'}}" name='twitter:title'> <meta content="{{$product->name or 'titulo general del product'}}" name='twitter:title'>
<meta content='@odessa_seguros' name='twitter:site'> <meta content='@odessa_seguros' name='twitter:site'>
<meta content="{{isset($post) ? asset('storage').'/'.$post->cover : asset('assets/img/Odessa-Seguros-alta-2.png')}}" name='twitter:image'> <meta content="{{asset('assets/img/Odessa-Seguros-alta-2.png')}}" name='twitter:image'>
<meta content='@odessa_seguros' name='twitter:creator'> <meta content='@odessa_seguros' name='twitter:creator'>
@extends('blog-public::layout') @extends('product-public::layout')
@section('content') @section('content')
<h1>
Titulo: {{$post->title}}
</h1>
<p>Portada:</p>
<img width="150" src="{{asset('storage/'.$post->cover)}}">
<p> <p>
Publicacion: {{$post->publication_date}} Producto: {{$product}}
</p> </p>
<p> <p>
Tags: {{$post->tags}} Categoria: {{$product->category}}
</p> </p>
<p> <p>
Categoria: {{$post->category->name}} Categorias: Listado de categorias:
</p> </p>
<p>{{$categories}}</p>
<p> <p>
Contenido: {!! $post->body !!} Listado de productos relacionados con sus categorias:
</p> </p>
<p> <p>
Categorias: Listado de categorias: {{$otros}}
</p> </p>
<ul>
@foreach($categories as $category)
<li>
{{$category->name}}
</li>
@endforeach
</ul>
<p>
Listado de post relacionados con sus tags:
</p>
<ul>
@foreach($otros as $entry)
<li>
<img width="100" src="{{asset('storage/'.$entry->cover)}}">
<a href="{{route('show.blog', $entry->slug)}}">
{{$entry->title}}
</a>
</li>
@endforeach
</ul>
{{-- Caja de compartir con redes sociales--}} {{-- Caja de compartir con redes sociales--}}
<div class="addthis_inline_share_toolbox_le2j"></div> <div class="addthis_inline_share_toolbox_le2j"></div>
{{-- *********************************** --}} {{-- *********************************** --}}
{{-- Listado de comentarios de la entrada--}}
@if($comments->count() > 0)
<p>Listado de comentarios</p>
<ul>
@foreach($comments as $comment)
<li>
{{$comment}}
</li>
@endforeach
</ul>
@else
<h4>No hay comentarios</h4>
@endif
{{-- *********************************** --}}
{{-- Formulario para hacer comentarios --}}
@include('blog-public::form-comments')
{{-- *********************************** --}}
@endsection @endsection
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment