Apologies, apparently my code is not coming in..
-edit: i used ''' instead of ```
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey guys!
I am doing some practise with Eloquent and i get the following error:
PHP warning: Illegal offset type in C:\Users\[USER]\Code\project\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 2794
i have the following files:
migration:
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateFreightsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('freights', function (Blueprint $table) {
$table->increments('fNo')->unique();
$table->date('loadedDate');
$table->date('arrivalDate');
$table->date('deliverydate');
$table->string('shippingCompany');
$table->string('containerNo');
$table->string('blNo');
$table->string('warehouseName');
$table->string('freightManager');
$table->string('portOfLoading');
$table->string('portOfDischarge');
$table->string('freightWay');
$table->string('freightContainerType');
$table->string('contents');
$table->string('weights');
$table->string('m3');
$table->string('customsClearance');
$table->string('notifyParty');
$table->string('logistics');
$table->string('exportGroup');
$table->string('importRemarks');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('freights');
}
}
The FreightFactory.php:
<?php
$factory->define(App\Freight::class, function (Faker\Generator $faker) {
return [
'fNo' => $faker->unique()->numberBetween($min = 701001, $max = 702001),
'loadedDate' => $faker->date('Y-m-d'),
'arrivalDate' => $faker->date('Y-m-d'),
'deliverydate' => $faker->date('Y-m-d'),
'shippingCompany' => $faker->company,
'containerNo' => $faker->randomNumber($nbDigits = NULL),
'blNo' => $faker->randomNumber($nbDigits = NULL),
'warehouseName' => $faker->company,
'freightManager' => $faker->name,
'portOfLoading' => $faker->city,
'portOfDischarge' => $faker->city,
'freightWay' => $faker->word,
'freightContainerType' => $faker->randomLetter,
'contents' => $faker->words($nb = 3, $asText = false),
'weights' => $faker->numberBetween($min = 100, $max = 20000),
'm3' => $faker->randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL),
'CustomsClearance' => $faker->name,
'notifyParty' => $faker->company,
'logisitics' => $faker->company,
'exportGroup' => $faker->company,
'importRemarks' => $faker->sentences($nb = 3, $asText = false),
];
});
routes.php:
Route::controller('datatables', 'DatatablesController', [
'anyData' => 'datatables.data',
'getIndex' => 'datatables',
]);
DatabaseSeeder.php:
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// $this->call(UsersTableSeeder::class);
}
public function testFreight()
{
$freight = factory(App\Freight::class)->create(); }
}
Anyone have an idea why i am getting this error? Can't seem to figure it out
If there is more code needed i can provide ofcourse :)
Please or to participate in this conversation.