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,
],
];
}
}
foreach ($users as $user){
// получаем id пользователя
$uid = $user->get('member');
// получаем объект пользователя
$user = $modx->getObject('modUser', $uid);
// получаем имя пользователя
$name = $user->get('username');
// получаем профиль пользователя
$profile = $user->getOne('Profile');
/****тут остальной код*****/
//end for each
}
document.dispatchEvent(new CustomEvent('af_complete;))
но т.к. судя по всему вы не можете изменить исходники modx, то остается использовать только первый вариант [[!if?
&subject=`[[+tv.TV1]]`
&operator=`!empty`
&then=`<div class="col-md-3 col-sm-3 col-xs-6 text-center gallery-p">
<a rel="gallery1" class="popap" href="[[+TV1]]" title="[[+zag]]"><img src="[[+image:phpthumbof=`w=215&h=215&zc=1`]]" alt="[[+pagetitle]]" /></a>
</div>`
&else=`<div class="col-md-3 col-sm-3 col-xs-6 text-center gallery-p">
<a rel="gallery1" class="popap" href="[[+TV2]]" title="[[+zag]]"><img src="[[+image:phpthumbof=`w=315&h=315&zc=1`]]" alt="[[+pagetitle]]" /></a>
</div>`
]]
<form role="form" id="form" action="catalog/vse-tovaryi/" data-def="catalog/vse-tovaryi/">
<select name="ms|price">
<option value="">Любая</option>
<option value="500">500 рублей</option>
</select>
<select name="msoption|tags">
<option value="1">Тэг 1</option>
<option value="2">Тэг 2</option>
</select>
<button type="submit">Подобрать</button>
</form>
window.onload = function () {
var form = $('#form'), def = form.data('def'), data = {}, action;
$(document).on('change', '#form select', function () {
var el = $(this), val = el.val(), name = el.attr('name');
if (val) {
data[name] = val;
} else {
delete data[name];
}
action = def + "?";
for(var i in data) {
action += i + "=" + data[i] + '&';
}
action = action.substr(0, action.length - 1);
form.attr('action', action);
});
};