Skip to content

Commit

Permalink
add interface
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 29, 2017
1 parent 1f37ccc commit be7dccc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ protected function filter($data)
return $this->merge($data, $index, $this->filter($value->data));
}

if ($value instanceof MissingValue ||
if (($value instanceof PotentiallyMissing && $value->isMissing()) ||
($value instanceof self &&
$value->resource instanceof MissingValue)) {
$value->resource instanceof PotentiallyMissing &&
$value->isMissing())) {
unset($data[$key]);

$index--;
Expand Down
12 changes: 10 additions & 2 deletions src/Illuminate/Http/Resources/MissingValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

namespace Illuminate\Http\Resources;

class MissingValue
class MissingValue implements PotentiallyMissing
{
//
/**
* Determine if the object should be considered "missing".
*
* @return bool
*/
public function isMissing()
{
return true;
}
}
13 changes: 13 additions & 0 deletions src/Illuminate/Http/Resources/PotentiallyMissing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Illuminate\Http\Resources;

interface PotentiallyMissing
{
/**
* Determine if the object should be considered "missing".
*
* @return bool
*/
public function isMissing();
}

0 comments on commit be7dccc

Please sign in to comment.