fixes on merchandise

This commit is contained in:
Ludovic CANDELLIER
2022-05-02 08:34:40 +02:00
parent 2ee339a022
commit 439a339027
13 changed files with 230 additions and 18 deletions

View File

@@ -29,7 +29,7 @@ class SpeciesDataTable extends DataTable
->editColumn('tags2', function (Specie $specie) {
$html = '';
foreach ($specie->tags as $tag) {
$html .= '<span class="btn btn-xs btn-secondary pb-2">' . $tag->slug . '</span> ';
$html .= Tags::getTagHtml($tag);
}
return $html;
})

View File

@@ -6,6 +6,7 @@ use Yajra\DataTables\Html\Column;
use App\Datatables\ParentDataTable as DataTable;
use App\Models\Botanic\Variety;
use App\Repositories\Botanic\Varieties;
use App\Repositories\Shop\Tags;
class VarietiesDataTable extends DataTable
{
@@ -17,7 +18,6 @@ class VarietiesDataTable extends DataTable
return $this->buildQuery($model);
}
public function modifier($datatables)
{
$datatables
@@ -27,7 +27,7 @@ class VarietiesDataTable extends DataTable
->editColumn('tags2', function (Variety $variety) {
$html = '';
foreach ($variety->tags as $tag) {
$html .= '<span class="btn btn-xs btn-secondary pb-2">' . $tag->slug . '</span> ';
$html .= Tags::getTagHtml($tag);
}
return $html;
})

View File

@@ -76,7 +76,7 @@ class ArticlesDataTable extends DataTable
->editColumn('tags2', function (Article $article) {
$html = '';
foreach ($article->tags as $tag) {
$html .= '<span class="btn btn-xs btn-success pb-2 mb-1" style="font-size: 0.8em;">' . Tags::getFullnameByTag($tag) . '</span> ';
$html .= Tags::getTagHtml($tag);
}
return $html;
})

View File

@@ -6,6 +6,7 @@ use Yajra\DataTables\Html\Column;
use App\Datatables\ParentDataTable as DataTable;
use App\Models\Shop\Merchandise;
use App\Repositories\Shop\Merchandises;
use App\Repositories\Shop\Tags;
class MerchandisesDataTable extends DataTable
{
@@ -27,7 +28,7 @@ class MerchandisesDataTable extends DataTable
->editColumn('tags2', function (Merchandise $merchandise) {
$html = '';
foreach ($merchandise->tags as $tag) {
$html .= '<span class="btn btn-xs btn-secondary pb-2">' . $tag->slug . '</span> ';
$html .= Tags::getTagHtml($tag);
}
return $html;
})

View File

@@ -6,6 +6,7 @@ use Yajra\DataTables\Html\Column;
use App\Datatables\ParentDataTable as DataTable;
use App\Models\Shop\Producer;
use App\Repositories\Shop\Producers;
use App\Repositories\Shop\Tags;
class ProducersDataTable extends DataTable
{
@@ -27,7 +28,7 @@ class ProducersDataTable extends DataTable
->editColumn('tags2', function (Producer $producer) {
$html = '';
foreach ($producer->tags as $tag) {
$html .= '<span class="btn btn-xs btn-secondary pb-2">' . $tag->slug . '</span> ';
$html .= Tags::getTagHtml($tag);
}
return $html;
})

View File

@@ -50,21 +50,22 @@ class Merchandises
return Merchandise::find($id);
}
public static function getFull($id)
{
$data = self::get($id)->toArray();
return $data;
}
public static function getTags($id)
{
return self::get($id)->tags;
}
public static function storeTags($merchandise, $tags)
{
return Tag::storeTags($merchandise, $tags);
}
public static function store($data)
{
$id = isset($data['id']) ? $data['id'] : false;
$item = $id ? self::update($data, $id) : self::create($data);
return $item->id;
return $item;
}
public static function storeFull($data)
@@ -79,6 +80,11 @@ class Merchandises
return $merchandise;
}
public static function storeTags($merchandise, $tags)
{
return Tag::storeTags($merchandise, $tags);
}
public static function create($data)
{
return Merchandise::create($data);

View File

@@ -8,6 +8,11 @@ use App\Models\Shop\Tag;
class Tags
{
public static function getTagHtml($tag)
{
return '<span class="btn btn-xs btn-secondary pb-2">' . self::getFullnameByTag($tag) . '</span>';
}
public static function getOptions()
{
return Tag::pluck('name', 'id')->toArray();