$store.state.loading === true
.this.loadData();
this.$store.dispatch('loadData');
class Config {
private static $configData;
public static function get($parameter = null, $default = null)
{
if (is_null(self::$configData)) {
self::$configData = include '../config.php';
}
if ($parameter) {
return self::$configData[$parameter] ?? $default;
}
return self::$configData;
}
}
// в клиентском методе
public function someMethod() {
$config = Config::get();
}
<?php
// в config.php
return [
'param' => 'value',
];
?>
$str = '<div class="stove-preview__main-img" style="background-image: url(\'/upload/resize_cache/iblock/114/245_600_2.jpg\')>';
preg_match('/background-image:\s*url\([\'"]?(?<image_url>[^\'")]+)[\'"]?\s*\)/', $str, $matches);
$imageUrl = $matches['image_url'] ?? null;
// /upload/resize_cache/iblock/114/245_600_2.jpg
// Заменить:
$table->foreignId('category_id')->constrained($tables['categories'])->onDelete('cascade');
// На:
$table->unsignedInteger('category_id');
$table->foreign('category_id')->references('id')->on($tables['categories'])->onDelete('cascade');
public function incomeMessages()
{
return $this->hasMany(Message::class, 'receiver_id');
}
public function sentMessages()
{
return $this->hasMany(Message::class, 'sender_id');
}
public function sender()
{
return $this->belongsTo(User::class, 'sender_id');
}
public function receiver()
{
return $this->belongsTo(User::class, 'receiver_id');
}
public function handleForm(Request $request)
{
// dispatch(...); Тут отправляем Email
return back()->withSuccess('Письмо успешно отправлено!');
}
@include('includes.alerts')
@if (($isSuccess = isset($success)) || isset($error))
<div class="alert {{ $isSuccess ? 'alert-success' : 'alert-error' }} mb-3">
<p>{{ $success ?? $error }}</p>
</div>
@endif
$array = [
['value' => 'photo-wallpapers', 'label' => 'Фотообои'],
['value' => 'fresco', 'label' => 'Фреска'],
['value' => 'panno', 'label' => 'Панно'],
['value' => 'fresco', 'label' => 'Test'],
['value' => 'ttt', 'label' => 'WoW'],
];
function sortArrayByFresco(array &$array) {
usort($array, function ($a, $b) {
$isFrescoA = $a['value'] === 'fresco';
$isFrescoB = $b['value'] === 'fresco';
if ($isFrescoA && $isFrescoB) {
return 0;
}
return $isFrescoA ? -1 : $isFrescoB;
});
}
// Test
sortArrayByFresco($array);
print_r($array);
/*
Array
(
[0] => Array
(
[value] => fresco
[label] => Фреска
)
[1] => Array
(
[value] => fresco
[label] => Test
)
[2] => Array
(
[value] => photo-wallpapers
[label] => Фотообои
)
[3] => Array
(
[value] => panno
[label] => Панно
)
[4] => Array
(
[value] => ttt
[label] => WoW
)
)
*/