-
-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom pivot model: order_column doesn't have a default value #66
Comments
This event not firing on Pivot. |
I believe we can't solve this error in this package. If you do know a good solution, feel free to PR it. |
Just wanted to share that I had the same question and I'm pretty sure I have it working. Laravel 5.8 added model events for pivot table models, so that event does fire now. @esl51 it looks like you just didn't create the class CreateQuestionnaireAttributeTable extends Migration
{
public function up()
{
Schema::create('questionnaire_attribute', function (Blueprint $table) {
// ...
$table->integer('order_column');
});
}
}
class Questionnaire extends Model
{
public function attributes()
{
return $this->belongsToMany(Attribute::class, 'questionnaire_attribute')
->using(QuestionnaireAttribute::class);
}
}
class Attribute extends Model
{
public function questionnaires()
{
return $this->belongsToMany(Questionnaire::class, 'questionnaire_attribute')
->using(QuestionnaireAttribute::class);
}
}
class QuestionnaireAttribute extends Pivot implements Sortable
{
use SortableTrait;
public $incrementing = true;
} Now if you |
Hey @bakerkretzmar I'm just getting the following error following with what you've posted.
|
On attach works fine, but it seems to loose references when calling
The two where are missing foreignKey & relatedKey. Any suggestions? |
Hello! I can't make work this behavior with custom pivot model.
I have models:
And when try to attach, I get this error:
Laravel 5.7, MariaDB 10.3.9
The text was updated successfully, but these errors were encountered: