public static function getAttributesByGroupId($group_id)
 {
     $user = \Auth::user();
     if (!$user) {
         return [];
     }
     $attributes = \App\Models\AttributeModel::where('attribute_group_id', '=', $group_id)->get();
     if (!$attributes) {
         return [];
     }
     return $attributes;
 }
 public function postSave(Request $request)
 {
     $post_fields_arr = $request->all();
     if (isset($post_fields_arr['id'])) {
         $widget_model = \App\Models\AttributeModel::find($post_fields_arr['id']);
         if (!$widget_model) {
             return 'Ошибка: нет виджета с таким ID - ' . $post_fields_arr['id'];
         }
         $widget_model->title = $post_fields_arr['name'];
         $widget_model->name = $post_fields_arr['name'];
         $widget_model->attribute_group_id = $post_fields_arr['attribute_group_id'];
         $widget_model->save();
     } else {
         \App\Models\AttributeModel::create($post_fields_arr);
     }
     return redirect('/seller/attribute-group/' . $post_fields_arr['attribute_group_id']);
 }
Пример #3
0
 /**
  * Возвращает значение атрибута, связанного с продуктом
  * @param $attribute_name
  * @return mixed
  */
 public function attr($attribute_name)
 {
     $attribute_name = trim($attribute_name);
     $attribute_obj = \App\Models\AttributeModel::where('name', '=', $attribute_name)->first(['id']);
     $attribute_value_obj = $this->attributes()->where('attribute_id', '=', $attribute_obj->id)->first(['value']);
     if (!$attribute_value_obj) {
         return null;
     }
     return $attribute_value_obj->value;
 }
Пример #4
0
@extends('seller.layout')

@section('content')

<?php 
$project_id = 1;
$project = \App\Models\ProjectModel::find($project_id);
$categories_models = \App\Helpers\ProjectHelper::getCategoriesByProjectId($project_id);
$attributes_group_id = \App\Helpers\ProjectHelper::getDefaultAttributesGroupId();
$attributes = \App\Models\AttributeModel::where('attribute_group_id', '=', $attributes_group_id)->get();
?>

<div class="container">
    <div class="row">
        <div class="col-md-12">
            <?php 
$supplier_id = \Input::get('supplier_id');
$supplier_model = null;
if ($supplier_id) {
    $supplier_model = $user->suppliers()->find($supplier_id);
    \App\Helpers\Assistant::assertModel($supplier_model);
}
?>

            <div class="btn-toolbar" role="toolbar" style="padding: 10px 0;">
                <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#editProduct">
                    Добавить товар
                </button>
            </div>

            <table class="table table-condensed table-striped table-hover table-bordered">