You have the wrong syntax here. It should be this
$table->foreign('created_by')->references('id')->on('users')->onDelete('cascade');
$table->foreign('updated_by')->references('id')->on('users')->onDelete('cascade');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm having a problem with this method.
$table->foreign(['created_by', 'updated_by'])->references('id')->on(['users', 'users'])->onDelete('cascade');
on old Laravel version the syntax above works, but when I do it in current version of Laravel it throw an exception
ErrorException : Array to string conversion
at C:\Users\japet\Desktop\mh\vendor\laravel\framework\src\Illuminate\Database\Grammar.php:39
35| */
36| public function wrapTable($table)
37| {
38| if (! $this->isExpression($table)) {
> 39| return $this->wrap($this->tablePrefix.$table, true);
40| }
41|
42| return $this->getValue($table);
43| }
Exception trace:
1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Array to string conversion", "C:\Users\japet\Desktop\mh\vendor\
laravel\framework\src\Illuminate\Database\Grammar.php", [])
C:\Users\japet\Desktop\mh\vendor\laravel\framework\src\Illuminate\Database\Grammar.php:39
2 Illuminate\Database\Grammar::wrapTable()
C:\Users\japet\Desktop\mh\vendor\laravel\framework\src\Illuminate\Database\Schema\Grammars\Grammar.php:216
Is this deprecated or just have other syntax to use
Please or to participate in this conversation.