mercredi 5 janvier 2022

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mkstudent.classes_teacher' doesn't exist (SQL: select `teachers`.*, `classes_teacher`.`cla

here is my Classes model

class Classes extends Model
{
   protected $fillable = [
        'name','course_catagory_id','teacher_id'
    ];

    public function coursecatagory()
    {
        return $this->belongsTo(CourseCatagory::class);
    }
    public function teacher()
    {
        return $this->belongsToMany(Teacher::class);
    }
}

and migrations

public function up()
    {
        Schema::create('classes', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->integer('course_catagory_id');
            $table->integer('teacher_id');
            
            $table->timestamps();
        });
    }

and create classes page

  <div class="card-body">
            @if(session()->has('success'))
             <div class="alert alert-success">
                 
               </div>
             @endif
            <form method="POST" action="">
               @csrf 
               
            <table class="table table-boreder">
               <tr>
                  <th>Name</th>
                  <td>
                     <input type="text" name="name" class="form-control">
                  </td>
               </tr>
               <tr>
                  <td colspan="2">
                     <input type="submit" value="submit" class="btn btn-primary ">
                     
                  </td>
               </tr>
                                  
               </table>
          </form>
            </div>
          </div>

and classes index page

<div class="card-body">
        @if($data->count()>0)
        <table class="table">
            <thead>
                <th>name</th>
                <th>Course Catagory</th>
                <th>
                    Teacher
                </th>
            </thead>
            <tbody>
                @foreach($data as $d)
                <tr>
                    
                    <td>
                        

                    </td>
                    <td>
                        

                    </td>
                    
                    
                    <td>
                    <a href="#">
                        
                    </a>
                    </td>
            
                    
                </tr>
                @endforeach
            </tbody>
        </table>
        @else
        <h3 class="text-center">No class Yet!</h3>
        @endif
        
    </div>

and when i create a new class it saved in the database but dose not restricted to the index view and when i tray to see the index view only the class name is displayed the other fields are not dispalyed and the error face the error



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3zCbYXa
via IFTTT

Aucun commentaire:

Enregistrer un commentaire