-
Notifications
You must be signed in to change notification settings - Fork 27
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
how to create Relationships Many To Many #733
Comments
Hi, can you confirm you said you had a success response but the relationship was not actually created? Could you provide some more info about your models and their relationships? You might find some help on this in the unit tests, for example https://github.com/flat3/lodata/blob/5.x/tests/Navigation/Navigation.php#L216 |
This is Event Model <?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Event extends Model
{
public $timestamps = true;
protected $guarded = [];
// 子事件編號
public function EventFeatures()
{
return $this->belongsToMany(EventFeature::class);
}
// 類別編號
public function EventTypes()
{
return $this->belongsToMany(EventType::class);
}
// 權限編號
public function EventPermissions()
{
return $this->belongsToMany(EventPermission::class);
}
} This is EventFeature Model <?php
namespace App\Models;
use App\Casts\PointCast;
use App\Casts\PolygonCast;
use Illuminate\Database\Eloquent\Model;
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
use Grimzy\LaravelMysqlSpatial\Types\Geometry;
class EventFeature extends Model
{
use SpatialTrait;
public $timestamps = true;
protected $guarded = [];
protected $casts = [
'geometry_scope' => PolygonCast::class
];
protected $spatialFields = [
'geometry_scope'
];
// 父事件編號
public function Events()
{
return $this->belongsToMany(Event::class);
}
// 影像編號
public function EventImages()
{
return $this->belongsToMany(EventImage::class);
}
public function setGeometryScopeGeojsonAttribute($value)
{
if (!empty($value))
$this->attributes['geometry_scope'] = Geometry::fromJson($value);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have response success but relationship can't create
I have another question how can i update relationship
This is my odata api use POST
BODY
Response
The text was updated successfully, but these errors were encountered: