The toArray method converts the collection into a plain PHP array. If the collection's values are Eloquent models, the models will also be converted to arrays
The get method returns an Illuminate\Support\Collection instance containing the results of the query where each result is an instance of the PHP stdClass object.
$aComments = Comment::where('Name', $name)
->get()
->toArray();
$$foo[1]
-> ${$foo[1]}
Для того чтобы использовать переменные переменных с массивами, вы должны решить проблему двусмысленности. То есть, если вы напишете $$a[1], обработчику необходимо знать, хотите ли вы использовать $a[1] в качестве переменной, либо вам нужна как переменная $$a, а затем её индекс [1]. Синтаксис для разрешения этой двусмысленности таков: ${$a[1]} для первого случая и ${$a}[1] для второго.https://www.php.net/manual/ru/language.variables.v...
public function scopeByPartnerId($query, int|array $partnerId)
{
if (is_countable($partnerId)) {
$query->whereIn('partner_id', $partnerId);
} else {
$query->where('partner_id', $partnerId);
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up()
{
Schema::create('{{ table }}', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('{{ table }}');
}
};
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up()
{
}
public function down()
{
}
};
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up()
{
Schema::table('{{ table }}', function (Blueprint $table) {
});
}
public function down()
{
Schema::table('{{ table }}', function (Blueprint $table) {
});
}
};
Например, чтобы в ссылке не было видно ID группы, а само ID отправлялось другим способом, не через URL, и чтобы запросы вида www.site.ru/group/delete/2 не работали.