@selmonal You know what? The easiest way is to pull that package: https://github.com/laracasts/Laravel-5-Generators-Extended
Install it and delete enrollments table. Then run artisan command to create this table again, but with Laravel's convention :
php artisan make:migration:pivot batches students
and then
php artisan migrate
In your Students model use that method
public function batches()
{
return $this->belongsToMany(App\Batch::class);
}
In your Batch model use:
public function students()
{
return $this->belongsToMany(App\Student::class);
}
Just follow conventions and you will never have to think why smth doesn't work.