Support the ongoing development of Laravel.io →
posted 10 years ago
Database

i have the following model:

class Agent extends Eloquent
{
	protected $fillable = [];
	protected $table = 'agents';
	protected $primaryKey = 'id_user';
	protected $userTable = 'users';

	public function user()
	{
		return $this->hasOne('Cartalyst\Sentry\Users\Eloquent\User', 'id', 'id_user');
	}

	public function plans()
	{
		return $this->belongsToMany('Plan', 'agents_plans', 'id_user', 'id_plan');
	}

	public function promotions()
	{
		return $this->belongsToMany('Promotion', 'agents_promotions', 'id_user', 'id_promotion');
	}

	public function sales()
	{
		return $this->hasMany('Sale', 'id_user');
	}
}

how can i delete a record from one of the relational tables like agents_plans?

Last updated 3 years ago.
0

Everything is beautifully described here: http://laravel.com/docs/4.2/eloquent#inserting-related-models

Read the docs, then ask.

0

Sign in to participate in this thread!

PHPverse

Your banner here too?

TehHector tehhector Joined 31 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.