Add tag details. #558
This commit is contained in:
parent
6ac92eba30
commit
bbc0647925
3 changed files with 47 additions and 2 deletions
|
|
@ -139,7 +139,8 @@ class CustomerTagController extends Controller
|
|||
$obj = new CustomerTag();
|
||||
|
||||
$obj->setID($req->request->get('id'))
|
||||
->setName($req->request->get('name'));
|
||||
->setName($req->request->get('name'))
|
||||
->setTagDetails($req->request->get('tag_details'));
|
||||
|
||||
// validate
|
||||
$errors = $validator->validate($obj);
|
||||
|
|
@ -206,7 +207,8 @@ class CustomerTagController extends Controller
|
|||
throw $this->createNotFoundException('The item does not exist');
|
||||
|
||||
$obj->setID($req->request->get('id'))
|
||||
->setName($req->request->get('name'));
|
||||
->setName($req->request->get('name'))
|
||||
->setTagDetails($req->request->get('tag_details'));
|
||||
|
||||
// validate
|
||||
$errors = $validator->validate($obj);
|
||||
|
|
|
|||
|
|
@ -33,10 +33,17 @@ class CustomerTag
|
|||
*/
|
||||
protected $customers;
|
||||
|
||||
// tag details
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
protected $tag_details;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->date_create = new DateTime();
|
||||
$this->customers = new ArrayCollection();
|
||||
$this->tag_details = [];
|
||||
}
|
||||
|
||||
public function getID()
|
||||
|
|
@ -83,4 +90,30 @@ class CustomerTag
|
|||
{
|
||||
return $this->customers;
|
||||
}
|
||||
|
||||
public function addTagDetails($id, $value)
|
||||
{
|
||||
$this->tag_details[$id] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTagDetails($tag_details)
|
||||
{
|
||||
$this->tag_details = $tag_details;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTagDetails($id)
|
||||
{
|
||||
// return null if we don't have it
|
||||
if (!isset($this->tag_details[$id]))
|
||||
return null;
|
||||
|
||||
return $this->tag_details[$id];
|
||||
}
|
||||
|
||||
public function getAllTagDetails()
|
||||
{
|
||||
return $this->tag_details;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,16 @@
|
|||
<div class="form-control-feedback hide" data-field="name"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group m-form__group row no-border">
|
||||
<div class="col-lg-6">
|
||||
<label for="tag_details" data-field="tag_details">
|
||||
Tag Details
|
||||
</label>
|
||||
<input type="text" name="tag_details" class="form-control m-input" value="{{ obj.getAllTagDetails|default('') }}">
|
||||
<div class="form-control-feedback hide" data-field="tag_details"></div>
|
||||
<span class="m-form__help">JSON format e.g. {type: 'discount', discount_type: 'percent', ...}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-portlet__foot m-portlet__foot--fit">
|
||||
<div class="m-form__actions m-form__actions--solid m-form__actions--right">
|
||||
|
|
|
|||
Loading…
Reference in a new issue