This commit is contained in:
Ludovic CANDELLIER
2021-08-21 19:48:21 +02:00
parent 9a0601d473
commit 81fbec892c
24 changed files with 423 additions and 65 deletions

View File

@@ -6,6 +6,7 @@ use Illuminate\Support\Str;
use App\Repositories\Core\Tag;
use App\Repositories\Core\Media;
use App\Repositories\Core\Comments;
use App\Repositories\Botanic\Species;
use App\Repositories\Botanic\Varieties;
use App\Models\Shop\Article;
@@ -37,6 +38,10 @@ class Articles
$data['article']['categories'] = self::getCategoriesByArticle($article);
$data['article']['tags'] = self::getTagsByArticle($article);
// $data['article']['prices'] = self::getPricesByArticle($article);
// $data['datatables']['comments'] = Comments::getDatatable();
$data['article']['comments'] = $article->comments;
self::getMeta($data);
return $data;
}

View File

@@ -0,0 +1,53 @@
<?php
namespace App\Repositories\Shop;
use App\Models\Shop\Offer;
class Offers
{
public static function getOptions()
{
return Offer::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
}
public static function getOptionsByPackage($package_id)
{
return Offer::byPackage($package_id)->orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
}
public static function getAll()
{
return Offer::orderBy('value', 'asc')->get();
}
public static function get($id)
{
return Offer::findOrFail($id);
}
public static function store($data)
{
$id = isset($data['id']) ? $data['id'] : false;
$item = $id ? self::update($data, $id) : self::create($data);
return $item->id;
}
public static function create($data)
{
return Offer::create($data);
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function destroy($id)
{
return Offer::destroy($id);
}
}

View File

@@ -8,7 +8,7 @@ class Tariffs
{
public static function autocomplete($str)
{
$data = Tariff::where('name', 'LIKE', "%${str}%")->orderBy('name')->limit(30)->get()->pluck('name', 'id');
$data = Tariff::where('name', 'LIKE', "%${str}%")->orWhere('ref', 'LIKE', "${str}%")->orWhere('code', 'LIKE', "${str}%")->orderBy('name')->limit(30)->get()->pluck('name', 'id');
$export = [];
foreach ($data as $key => $name) {
$export[] = ['value' => $key, 'text' => $name];