console.clear();
var root = 'https://jsonplaceholder.typicode.com';
function requestOne(callback) {
return $.ajax({
type: "GET",
url: root + '/posts/1',
// dataType: "json",
success: callback
});
}
function requestTwo(callback) {
return $.ajax({
type: "GET",
url: root + '/posts/2',
// dataType: "json",
success: callback
});
}
function result() {
var deffered1 = requestOne();
var deffered2 = requestTwo();
$.when(deffered1, deffered2).done(function(r1, r2) {
console.log(r1[0].id + r2[0].id);
})
// результатом хотел видеть сложение двух айдишников
// console.log(r1 + r2);
}
result();
...
public function get(Array $options = [])
{
if (isset($options['by_name']) {
$query = "WHERE `name` LIKE %". $options['by_name'] ."% ";
}
...
}
public $post_slug;
public function setPhotoAttribute($value) {
if ($value instanceOf UploadedFile) {
$fileNameWithExt = $value->getClientOriginalName();
$filename = pathinfo($fileNameWithExt, PATHINFO_FILENAME);
$extension = $value->getClientOriginalExtension();
$fileNameToStore = $filename . '_' . time() . '.' . $extension;
$file->storeAs('public/articles', $fileNameToStore);
return $this->attributes['photo'] = $fileNameToStore;
}
}
$.each([{id: 1, label: 'test'},{id: 2, label: 'test1'},{id: 3, label: 'test2'},{id: 4, label: 'test3'},{id: 5, label: 'test4'},{id: 6, label: 'test5'}], function(item) {
$('body').append('<input type="checkbox" id="id' + item.id + '" name="test"/><label for="id"'+ item.id + '">' + item.label + '</label>');
});
Route::controller('/products', 'ProductsController')
Роут метода GET к : /products/some-category/2
public function getSomeCategory($id)
{
// ...
}
public function getSomeCategory($id, $subid, $subid, $subid)
{
// ...
}
Роут метода GET к : /products/some-category/2/15/10/20