Skip to content

Instantly share code, notes, and snippets.

@ollieread
Created November 18, 2014 14:37
Show Gist options
  • Save ollieread/2be55db54c411df33a8a to your computer and use it in GitHub Desktop.
Save ollieread/2be55db54c411df33a8a to your computer and use it in GitHub Desktop.
<?php
// This would be for the logs model
public function scopeCode($query, $code)
{
return $query->where('code', $code);
}
// Then this would be your main model
public function scopeNotTransferred($query)
{
return $query->whereHas('logs', function($query)
{
$query->code('transferred');
}, '<', 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment