class CityFactory extends Factory
{
protected $model = City::class;
public function definition()
{
$tz = array_keys(Timezone::getData());
return [
'name' => $this->faker->city,
'timezone' => $this->faker->randomElement($tz),
'enabled' => true,
];
}
}
use Illuminate\Database\Eloquent\Factories\Sequence;
class CitySeeder extends Seeder
{
public function run()
{
$predefinedCities = array_reverse($this->getPredefinedCities());
City::factory(CITY_COUNT)
->state(new Sequence(function () use (&$predefinedCities) {
return array_pop($predefinedCities) ?? [];
}))
->create();
}
private function getPredefinedCities()
{
return [
[
'name' => 'Moscow',
'timezone' => '+0300',
'enabled' => true,
],
[
'name' => 'Saint-Petersburg',
'timezone' => '+0300',
'enabled' => true,
],
[
'name' => 'Sochi',
'timezone' => '+0300',
'enabled' => true,
],
];
}
}
<audio id="music-player" src="/storage/files/music-1.mp3" loop></audio>
<script>
(function () {
const player = document.getElementById('music-player');
if (!player) return;
const toggle = document.getElementById('toggle-music');
if (screen.width < 1220) return;
if (!toggle) return;
let playing = false;
let firstPlay = true;
let iPos;
const KEY_MP_PAUSED = 'music-player-paused';
const KEY_MP_POSITION = 'music-player-position' + player.src;
const startPosition = parseFloat(localStorage.getItem(KEY_MP_POSITION));
const mpPaused = +localStorage.getItem(KEY_MP_PAUSED);
function enablePlay() {
if (firstPlay) {
firstPlay = false;
if (startPosition) player.currentTime = startPosition;
}
player.play();
toggle.classList.add('music-on');
}
function userClick() {
document.removeEventListener('click', userClick);
enablePlay();
}
if (!mpPaused) document.addEventListener('click', userClick);
function updateCurrentPosition() {
localStorage.setItem(KEY_MP_POSITION, player.currentTime.toString());
}
player.addEventListener('play', e => {
playing = true;
localStorage.setItem(KEY_MP_PAUSED, '0');
iPos = setInterval(updateCurrentPosition, 1000);
});
player.addEventListener('pause', e => {
playing = false;
localStorage.setItem(KEY_MP_PAUSED, '1');
clearInterval(iPos);
});
toggle.addEventListener('click', e => {
e.preventDefault();
e.stopPropagation();
document.removeEventListener('click', userClick);
if (playing) {
player.pause();
toggle.classList.remove('music-on');
} else {
enablePlay();
}
});
})();
</script>
gulp.watch('./dist/scss/*.scss'
/dist
/scss
main.scss - отслеживается
/blocks
header.scss - не отслеживается
gulp.watch('./dist/scss/**/*.scss', gulp.series('sass'));
<div class="section">
<div class="container">
<div class="slider">
</div>
</div>
</div>
.section {
overflow: hidden;
}
.container {
width: 1000px;
margin: auto;
padding: 10px 0;
background: green;
}
.slider {
height: 100px;
background:red;
width: calc(50% + 50vw);
}
<div class="div">75</div>
.div {
position: relative;
width: 100px;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
font-size: 30px;
}
.div::before {
content: '';
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
border: 20px solid red;
border-color: red red green green;
border-radius: 100%;
transform: rotate(45deg);
pointer-events: none;
}