Laravel
- 1 ответ
- 0 вопросов
1
Вклад в тег
$rules = array(
'url' => 'required|unique:products,url,{{$id}}',
);
public function validate($data, $id = null)
{
$rules = $this->rules;
foreach($rules as $keys => $value) {
$validations = explode('|', $value);
foreach($validations as $key => $value) {
$validations[$key] = str_replace('{{$id}}', $id, $value);
}
$implode = implode("|", $validations);
$rules[$keys] = $implode;
}
return \Validator::make($data, $rules);
}
<input type="plain/text" placeholder='Enter name' ng-model='products.new.name'/>
<input type="plain/text" placeholder='Enter price' ng-model='products.new.price' />
this.addProduct = function() {
this.products.push(this.new);
this.new = {price:'', name:''};
};
<ul>
<li>
{{ products.new_product_name }}: {{ products.new_product_price | currency }}
<span ng-click="products.remove($index)">удалить</span>
</li>
</ul>
this.remove = function($index){
this.products.splice($index, 1);
}