return $request->wantsJson()
? new JsonResponse([
'user' => $request->user(),
])
: back();
$url = url('/').'?'.($condition ? 'ain' : 'cin').'='.$this->customer_id;
// VS
if ($condition) {
$url = url('/').'?ain='.$this->customer_id;
} else {
$url = url('/').'?cin='.$this->customer_id;
}
$data = [
'url' => url('/').'?'.($condition ? 'ain' : 'cin').'='.$this->customer_id;
];
// VS
if ($condition) {
$url = url('/').'?ain='.$this->customer_id;
} else {
$url = url('/').'?cin='.$this->customer_id;
}
$data = [
'url' => $url;
];
class Weight extends Product
{
function buy()
{
return $this; // возвращаем объект, методы которого сможем использовать дальше
}
function weight($amout)
{
parent::$profit += parent::getPrice() * $amout;
echo "Весовой товар куплен. <br> Доход с продаж весовых товаров " . parent::$profit . "<br>";
}
}
$productWeight::buy()->weight(5.5);
async function postData(url = '', data = {}) {
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
return await response.json();
}
postData('/handler.php', { number: 42 })
.then((data) => {
console.log(data.number);
});
$number = (int)$_POST['number'];
$number += 1;
echo json_encode(['number' => $number]);