Skip to content

Instantly share code, notes, and snippets.

@Kindari
Last active November 11, 2022 00:28
Show Gist options
  • Save Kindari/6591313 to your computer and use it in GitHub Desktop.
Save Kindari/6591313 to your computer and use it in GitHub Desktop.
<?php
class Bar extends Eloquent {
public function foo() {
return $this->belongsTo('Foo');
}
}
<?php
Bar::saving(function($bar) {
if ( $bar->isDirty('foo_id') ) {
// relation being created or updated
}
}
<?php
class Foo extends Eloquent {
public function bars() {
return $this->hasMany('Bar');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment