Cache::set('key');
Cache::put('key', 'value');
$key = Cache::get('key'); // 'value'
// а это на всякий случай
Cache::forget('key');
$str = '100 9';
function test($str) {
$arr = explode(' ', $str);
// Если нужен текст после последнего пробела
return array_pop($arr);
// Если нужен текст после первого пробела
array_shift($arr);
return implode(' ', $arr);
}
echo test($str); // 9
$data = $request->only('id', 'url_id', 'img_url');
// создаст или обновит запись в модели Data в зависимости от того
// было ли найдено в модели Data поле url_id равное $request->url_id
Data::updateOrCreate(['url_id' => $request->url_id], $data);
// создаст запись в модели Data_trans
// если в модели Data_trans не найдена запись с data_id равной $request->id
Data_trans::firstOrCreate(['data_id' => $request->id], [
'data_id' => $request->id,
'local' => '',
'title' => '',
'content' => '',
]); // возвращает найденную или вновь созданную запись
$('#block1, #block2').on('click', function() {
$('#block1, #block2').not(this).hide();
});
window.videoPercentage = 0;
video.addEventListener('progress', function() {
var range = 0;
var bf = this.buffered;
var time = this.currentTime;
while(!(bf.start(range) <= time && time <= bf.end(range))) {
range += 1;
}
var loadStartPercentage = bf.start(range) / this.duration;
var loadEndPercentage = bf.end(range) / this.duration;
var loadPercentage = loadEndPercentage - loadStartPercentage;
videoPercentage = loadPercentage;
});
$('video').on('click', function() {
console.log(videoPercentage);
});
protected function tryRunMethod(Object $controller, $method)
{
try {
$controller->$method();
} catch (\Exception $e) {
$this->sandResponseCode(Response::HTTP_METHOD_NOT_ALLOWED);
throw new \Exception($e);
}
}
protected function tryRunMethod(ControllerClass $controller, $method)
{
...
}
if (!String.prototype.replaceLast) {
String.prototype.replaceLast = function(find, replace) {
var index = this.lastIndexOf(find);
if (index >= 0) {
return this.substring(0, index) + replace + this.substring(index + find.length);
}
return this.toString();
};
}
$('li').each(function() {
var text = $(this).text().replaceLast('(', '<span>(');
text = text.replaceLast(')', ')</span>');
$(this).text(text);
});