Randy_Johnson's avatar

Call to undefined method App\Models\TimeTable::setContainer()

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
    {
        //
    }
}
0 likes
4 replies
Amaury's avatar

@randy_johnson did you import classes for the relationships?

use App\Models\School;
use App\Models\Building;
use App\Models\Room;
Snapey's avatar

You get this error when you do what?

1 like
Randy_Johnson's avatar
Randy_Johnson
OP
Best Answer
Level 8

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.