Framework updates, merges from other packages
This commit is contained in:
@@ -6,23 +6,43 @@ use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// When a query should return 1 object, or FAIL if it doesnt
|
||||
Builder::macro('singleOrFail',function () {
|
||||
$result = $this->get();
|
||||
|
||||
if (($x=$result->count()) == 1) {
|
||||
return $result->first();
|
||||
}
|
||||
|
||||
throw new \Exception(sprintf('Query brings back %d record(s) called for singleOrFail()',$x));
|
||||
});
|
||||
|
||||
// When a query should return 1 object, or NULL if it doesnt
|
||||
Builder::macro('single',function () {
|
||||
$result = $this->get();
|
||||
|
||||
if ($result->count() == 1) {
|
||||
return $result->first();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user