Level 43
@randy_johnson did you import classes for the relationships?
use App\Models\School;
use App\Models\Building;
use App\Models\Room;
Hey, can anyone spot the reasons I am getting this error ###Call to undefined method App\Models\TimeTable::setContainer()
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class TimeTable extends Model
{
use HasFactory;
public function school()
{
return $this->belongsTo(School::class);
}
public function building()
{
return $this->belongsTo(Building::class);
}
public function room()
{
return $this->belongsTo(Room::class);
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('time_tables', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id');
$table->foreignId('school_id');
$table->foreignId('building_id');
$table->foreignId('room_id');
$table->foreignId('subject_id');
$table->foreignId('group_id');
$table->date('date');
$table->time('start');
$table->time('finish');
$table->boolean('type');
$table->boolean('attended');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('time_tables');
}
};
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class TimeTableSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}
Hey guys, really sorry, always something stupid. I forgot to put Seeder in the name.
$this->call([
BookSeeder::class,
StudentSeeder::class,
SchoolSeeder::class,
LocationSeeder::class,
SubjectSeeder::class,
GroupSeeder::class,
BuildingSeeder::class,
RoomSeeder::class,
TimeTabler::class,
]);
It was like this.
Please or to participate in this conversation.