Add display articles & categories, raw mode
This commit is contained in:
@@ -28,9 +28,9 @@ class HomeController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$data['categories'] = Categories::getTree();
|
$data['categories'] = Categories::getTree();
|
||||||
|
$data['category'] = Categories::get(15)->toArray();
|
||||||
$data['articles'] = Articles::getByCategory(0)->toArray();
|
$data['articles'] = Articles::getByCategory(0)->toArray();
|
||||||
dump($data);
|
// dump($data);
|
||||||
exit;
|
|
||||||
return view('Shop.home', $data);
|
return view('Shop.home', $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
app/Models/Core/Media.php
Normal file
12
app/Models/Core/Media.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Core;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Media extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'media';
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,9 +26,14 @@ class Article extends Model implements HasMedia
|
|||||||
return $this->hasMany('App\Models\Shop\ArticleAttribute');
|
return $this->hasMany('App\Models\Shop\ArticleAttribute');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prices()
|
public function images()
|
||||||
{
|
{
|
||||||
return $this->hasManyThrough('App\Models\Shop\ArticlePrice','App\Models\Shop\ArticleAttribute');
|
return $this->hasMany('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function image()
|
||||||
|
{
|
||||||
|
return $this->hasOne('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function inventories()
|
public function inventories()
|
||||||
@@ -41,6 +46,11 @@ class Article extends Model implements HasMedia
|
|||||||
return $this->hasMany('App\Models\Shop\InvoiceItem');
|
return $this->hasMany('App\Models\Shop\InvoiceItem');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function prices()
|
||||||
|
{
|
||||||
|
return $this->hasManyThrough('App\Models\Shop\ArticlePrice','App\Models\Shop\ArticleAttribute');
|
||||||
|
}
|
||||||
|
|
||||||
public function product()
|
public function product()
|
||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class Articles
|
|||||||
|
|
||||||
public static function getByCategory($category_id)
|
public static function getByCategory($category_id)
|
||||||
{
|
{
|
||||||
return Article::with(['prices.article_attribute.attribute_value'])->get();
|
return Article::with(['prices.article_attribute.attribute_value','product','image'])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCategoriesByArticle($article)
|
public static function getCategoriesByArticle($article)
|
||||||
@@ -92,7 +92,7 @@ class Articles
|
|||||||
self::storeCategories($article, $categories);
|
self::storeCategories($article, $categories);
|
||||||
self::storeTags($article, $tags);
|
self::storeTags($article, $tags);
|
||||||
self::storePrices($article, $prices);
|
self::storePrices($article, $prices);
|
||||||
return $article_id;
|
return $article->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function store($data)
|
public static function store($data)
|
||||||
@@ -175,6 +175,17 @@ class Articles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getThumbSrc($image)
|
||||||
|
{
|
||||||
|
$id = $image['id'];
|
||||||
|
$images = json_decode($image['responsive_images'], true);
|
||||||
|
$urls = $images['medialibrary_original']['urls'];
|
||||||
|
|
||||||
|
$img = $urls[count($urls)-1];
|
||||||
|
$src = "storage/$id/responsive-images/$img";
|
||||||
|
return $src;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function deleteImage($id, $index)
|
public static function deleteImage($id, $index)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
{{ Form::label('model', 'Familles de produit') }}<br>
|
{{ Form::label('model', 'Familles de produit') }}<br>
|
||||||
@include('components.select', ['name' => 'model', 'id_name' => 'model', 'list' => $models_options, 'value' => isset($model) ? $model : null, 'class' => 'select2 form-control'])
|
@include('components.select', ['name' => 'product_type', 'id_name' => 'product_type', 'list' => $models_options, 'value' => isset($product_type) ? $product_type : null, 'class' => 'select2 form-control'])
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
{{ Form::label('model_id', 'Produit') }}<br>
|
{{ Form::label('model_id', 'Produit') }}<br>
|
||||||
@include('components.select2', ['name' => 'model_id', 'id_name' => 'model_id', 'value' => isset($model_id) ? $model_id : null, 'class' => 'select2 form-control'])
|
@include('components.select2', ['name' => 'product_id', 'id_name' => 'product_id', 'value' => isset($product_id) ? $product_id : null, 'class' => 'select2 form-control'])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -57,13 +57,13 @@
|
|||||||
@push('js')
|
@push('js')
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$("#model_id").change( function(e) {
|
$("#product_id").change( function(e) {
|
||||||
var model = $('#model_id').select2('data');
|
var product = $('#product_id').select2('data');
|
||||||
var name = model[0]['text'];
|
var name = product[0]['text'];
|
||||||
$('input[name="name"]').val(name);
|
$('input[name="name"]').val(name);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#model').change( function() {
|
$('#product_type').change( function() {
|
||||||
loadVarieties();
|
loadVarieties();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -71,10 +71,10 @@
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
url : '{{ route('Botanic.Admin.Varieties.getSelect') }}',
|
url : '{{ route('Botanic.Admin.Varieties.getSelect') }}',
|
||||||
method : 'POST',
|
method : 'POST',
|
||||||
data: {model: $('#model').val()},
|
data: {model: $('#product_type').val()},
|
||||||
success : function(data) {
|
success : function(data) {
|
||||||
$("#model_id").select2({data: data});
|
$("#product_id").select2({data: data});
|
||||||
$("#model_id").val({{ $model_id }}).trigger('change');
|
$("#product_id").trigger('change');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
@include("Shop.layout.partials.block-breadcrumb")
|
@include("Shop.layout.partials.block-breadcrumb")
|
||||||
|
@include("Shop.layout.partials.category")
|
||||||
@include("Shop.layout.partials.block-products")
|
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||||
|
|
||||||
<title>OpenSemis</title>
|
<title>OpenSemis</title>
|
||||||
<meta name="description" content="Boutique propulsée par HumaN.E.T">
|
<meta name="description" content="Vente de semences, variété anciennes">
|
||||||
<meta name="keywords" content="">
|
<meta name="keywords" content="">
|
||||||
|
|
||||||
<link rel="icon" type="image/vnd.microsoft.icon" href="img/favicon.ico">
|
<link rel="icon" type="image/vnd.microsoft.icon" href="img/favicon.ico">
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@include("Shop._partials.footer")
|
@include("Shop.layout.partials.footer")
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
<div class="article">
|
<div class="card" style="width: 18rem;">
|
||||||
<div class="row">
|
<img src="{{ App\Repositories\Shop\Articles::getThumbSrc($article['image']) }}" class="card-img-top" alt="...">
|
||||||
<div class="col-12">
|
<div class="card-body">
|
||||||
<img src="{{ $article['img'] ?? '/img/logo'}}" class="img-responsive">
|
<span class="card-title">{{ $article['name'] }}</span>
|
||||||
{{ $article['name'] }}
|
<span class="pull-right">
|
||||||
<span class="pull-right">
|
<i class="fa fa-heart"></i>
|
||||||
<i class="fa fa-heart"></i>
|
</span>
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
<p class="card-text">
|
||||||
<div class="col-6">
|
<div class="row">
|
||||||
3.10 €<br>
|
<div class="col-6">
|
||||||
Semence
|
3.10 €<br>
|
||||||
</div>
|
Semence
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
1.65 €<br>
|
1.65 €<br>
|
||||||
Plant
|
Plant
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<div class="row">
|
||||||
|
@foreach ($articles as $article)
|
||||||
|
<div class="col-3">
|
||||||
|
@include('Shop.layout.partials.article')
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<div id="ishiproductsblock" class="container clearfix">
|
|
||||||
<div class="ishiproductsblock-container">
|
|
||||||
<h2 class="home-title">Meilleurs produits</h2>
|
|
||||||
|
|
||||||
<ul id="ishiproductstab" class="nav nav-tabs clearfix">
|
|
||||||
<li class="nav-item first_item">
|
|
||||||
<a class="nav-link active" href="#featured-products-block" data-toggle="tab">En vedette</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item ">
|
|
||||||
<a class="nav-link " href="#new-products-block" data-toggle="tab">Dernier</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item last_item">
|
|
||||||
<a class="nav-link " href="#bestseller-products-block" data-toggle="tab">Meilleures ventes</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="product_content ">
|
|
||||||
<div class="tab-content">
|
|
||||||
<div id="featured-products-block" class="tab-pane active">
|
|
||||||
<div class="block_content row">
|
|
||||||
<div id="ishi-featured-products" class="owl-carousel">
|
|
||||||
{{ include("Shop._partials.product", {index:1}) }}
|
|
||||||
{{ include("Shop._partials.product", {index:2}) }}
|
|
||||||
{{ include("Shop._partials.product", {index:3}) }}
|
|
||||||
{{ include("Shop._partials.product", {index:4}) }}
|
|
||||||
{{ include("Shop._partials.product", {index:5}) }}
|
|
||||||
{{ include("Shop._partials.product", {index:6}) }}
|
|
||||||
{{ include("Shop._partials.product", {index:7}) }}
|
|
||||||
{{ include("Shop._partials.product", {index:8}) }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="new-products-block">
|
|
||||||
</div>
|
|
||||||
<div id="bestseller-products-block">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<h1>{{ $category['name'] }}</h1>
|
<h1 style="font-size: 2em;">{{ $category['name'] }}</h1>
|
||||||
<h3>{{ $category['description'] }}</h3>
|
<h3 style="font-size: 1.2em;">{!! $category['description'] !!}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
@include('Shop.layout.partials.category_add')
|
@include('Shop.layout.partials.category_add')
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
Ajouter au panier la liste des semences
|
<button type="button" class="btn btn-success">
|
||||||
|
<i class="fa fa-seedling"></i>
|
||||||
|
Ajouter au panier la liste des <strong>semences</strong>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
Ajouter au panier la liste des plants
|
<button type="button" class="btn btn-warning">
|
||||||
|
Ajouter au panier la liste des <strong>plants</strong>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -12,7 +17,7 @@
|
|||||||
Il y a {{ $nb ?? 0 }} article(s) dans la liste
|
Il y a {{ $nb ?? 0 }} article(s) dans la liste
|
||||||
<form name="product_sorting">
|
<form name="product_sorting">
|
||||||
<label>Trier par</label>
|
<label>Trier par</label>
|
||||||
@include('components.select', ['name' => ])
|
@include('components.select', ['name' => 'sorting', 'list' => ['Pertinence']])
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
@foreach ($articles as $article)
|
<div class="row">
|
||||||
@include('Shop.layout.partials.article')
|
@foreach ($articles as $article)
|
||||||
@endforeach
|
<div class="col-3">
|
||||||
|
@include('Shop.layout.partials.article')
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
6
resources/views/Shop/layout/partials/footer.blade.php
Normal file
6
resources/views/Shop/layout/partials/footer.blade.php
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<footer id="footer">
|
||||||
|
|
||||||
|
@include("Shop._partials.footer-after")
|
||||||
|
|
||||||
|
|
||||||
|
</footer>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
@if (isset($id_name))id="{{ $id_name }}"@endif
|
@if (isset($id_name))id="{{ $id_name }}"@endif
|
||||||
class="form-control @if (isset($class)){{ $class }} @endif"
|
class="form-control @if (isset($class)){{ $class }} @endif"
|
||||||
@if (isset($style))style="{{ $style }}" @endif
|
@if (isset($style))style="{{ $style }}" @endif
|
||||||
@if (isset($required))required="required"@endif
|
@if (isset($required) && $required)required="required"@endif
|
||||||
@if (isset($multiple))multiple="multiple"@endif
|
@if (isset($multiple))multiple="multiple"@endif
|
||||||
>
|
>
|
||||||
@if (isset($with_empty))
|
@if (isset($with_empty))
|
||||||
|
|||||||
Reference in New Issue
Block a user