class UserRepository {
public function save(User $user)
{
$user->save();
}
public function findMale()
{
return User::find()->active()->male();
}
}
$password = crypt($_POST['password'], $salt);
use GuzzleHttp\Pool;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
$client = new Client();
$requests = function ($total) {
$uri = 'http://127.0.0.1:8126/guzzle-server/perf';
for ($i = 0; $i < $total; $i++) {
yield new Request('GET', $uri);
}
};
$pool = new Pool($client, $requests(100), [
'concurrency' => 5,
'fulfilled' => function ($response, $index) {
// this is delivered each successful response
},
'rejected' => function ($reason, $index) {
// this is delivered each failed request
},
]);
// Initiate the transfers and create a promise
$promise = $pool->promise();
// Force the pool of requests to complete.
$promise->wait();
<input :value="user.getAttribute('name')" @input="e => user.setAttribute('name', e.target.value)"/>
// age будет высчитывать возраст по birthday
Object.defineProperty(this, "age", {
get: function() {
var today = new Date();
var yearDelta = today.getFullYear() - this.birthday.getFullYear();
if (today.getMonth() > this.birthday.getMonth() ||
(today.getMonth() === this.birthday.getMonth() && today.getDate() >= this.birthday.getDate())) {
return yearDelta;
}
return yearDelta - 1;
}
});
var Car = (function(){
var speed, color, doors, pub;
function setSpeed(new_speed) {
speed = new_speed;
return pub;
}
function setColor(new_color) {
color = new_color;
return pub;
}
function setDoors(new_doors) {
doors = new_doors;
return pub;
}
pub = {
'setSpeed': setSpeed,
'setColor': setColor,
'setDoors': setDoors,
};
return pub;
})
// Обычная реализация
myCar2 = Car();
myCar2.setSpeed(100);
myCar2.setColor('blue');
myCar2.setDoors(5);
// Текучий интерфейс
myCar = Car();
myCar.setSpeed(100).setColor('blue').setDoors(5);
в router.push или router.replace в качестве 2-го и 3-го аргументов
router.push('path', () => { console.log('onSuccess') }, () => { console.log('onAbort') })
export default {
props: {
paramType: {
type: String
},
productId: {
type: Number
}
},
data () {
return {
param: 123
}
},
watch: {
param (value) {
this.$store.dispatch('calcPriceAction', { productId: this.productId, paramType: this.paramType, value })
}
}
}
calcPriceAction (context, { productId, paramType, value }) {
const productApiService = context.getters.productApiService
return productApiService.getPriceFor(productId, paramType, value)
.then(price => {
context.commit('setProductPrice', { productId, price })
})
}
import qs from 'qs';
const data = { 'bar': 123 };
const options = {
method: 'POST',
headers: { 'content-type': 'application/x-www-form-urlencoded' },
data: qs.stringify(data),
url,
};
axios(options);
{
path: '/transfers',
name: 'transfers',
component: transfers,
children: [
{
path: 'new',
name: 'new',
component: transferFormWidget
},
{
path: '',
redirect: 'new'
}
]
},
function truncate($string, $length)
{
if (strlen($string) > $length) {
$string = substr($string, 0, $length) . '...';
}
return $string;
}
function truncate($string, $length)
{
if (mb_strlen($string) > $length) {
$string = mb_substr($string, 0, $length) . '...';
}
return $string;
}
<?php
if(isset($_POST['btn'])) {
$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
$pass = htmlspecialchars($_POST['pass']);
$pass2 = htmlspecialchars($_POST['pass2']);
$errors = array();
if($name == "" && $email == "" && $pass == "" && $pass2 == ""){
$errors[] = "<span style='color: red; font-size: 18x;'>Все поля ОБЯЗАТЕЛЬНЫ к заполнению</span></br>";
}
if($name < 4 || $name > 10){
$errors[] = "<span style='color: red; font-size: 18px;'>Ваше имя не соответствует длине</span></br>";
}
if(preg_match('/[a-zA-Z0-9]/', $name)){
$errors[] = "<span style='color: red; font-size: 18px;'>В вашем имени запрещенные знаки</span></br>";
}
if(!empty($errors)) {
echo "<div style='text-align: center; background-color: rgba(124, 124, 124, 0.78); width: 400px; heigth: 300px; margin: auto; margin-top: 10px; '>";
foreach ($errors as $error) {
echo $error;
}
echo "</div>";
}
}
?>
$(document).ready(function () {
var $tabs = $('.s-services__tab_item');
$tabs.first().addClass('active');
$tabs.not('.active').hide();
$('.s-services__controls_item').on('click',function (e) {
e.preventDefault();
var tabItem = $(this).closest('.s-services__controls_item'),
tabContentItem = $('.s-services__tab_item'),
tabItemPosition = tabItem.data('services');
tabContentItem.filter('.s-services__tab_item-' + tabItemPosition)
.fadeIn()
.siblings()
.hide();
$(e.currentTarget)
.addClass('active')
.siblings()
.removeClass('active');
});
});