<div>
<i class="иконка сердечка" onClick="addLike({!! $comment->id !!})"></i>
<span c-id={!! $comment->id !!}>15</span>
</div>
function addLike(id) {
$.ajax({
url: '/comments/like',
dataType: 'json',
data: {
'id': id,
},
method: 'POST',
}).done(function(data) {
$("span[c-id="' + data.id + '").text( data.likes );
});
}
$comment = Comment::findOrFail($request->id);
$comment->likes += 1;
$comment->update();
return Response::json(['id' => $comment->id, 'likes' => $comment->likes]);
$purse = Purse::where('purse_name', $request->trans_pay_purse_name)->first();
if ($purse) {
$purse->decrement('purse_balance', $request->trans_pay_sum);
$purse->save();
} else {
return redirect()->back()->withInput()->with('error', 'Кошелек не найден!');
}
'locale' => 'ru'
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Имя:</label>
<div class="col-md-6">
<input type="text" class="form-control" name="name" value="{{ old('name') }}">
@if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
@endif
</div>
</div>
{!! Form::text('name', null, array('class' => 'form-control input-sm')) !!}
// Правила можешь вынести в функцию в модели
$rules = [
'file' => 'required|mimes:jpg,png,mp4,webm',
];
$validation = Validator::make($request->all(), $rules);
if( $validation->fails() ) {
$errors = $validation->messages()->toJson();
}
return response()->json([ "errors" => $errors ]);