Skip to content

Commit

Permalink
Update ReadOnlyTrait.php (#26)
Browse files Browse the repository at this point in the history
Declaration of class functions (e.g: firstOrCreate, firstOrNew, updateOrCreate) should be compatible with Illuminate\Database\Eloquent\Model
  • Loading branch information
putchi authored and michaelachrisco committed Oct 22, 2018
1 parent eb09087 commit 218aac0
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/ReadOnlyTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,33 @@ public function update(array $attributes = [], array $options = [])

/**
* Throws ReadOnlyException on firstOrCreate
* @param array $arr
* @param array $attributes
* @param array $values
* @throws ReadOnlyException
*/
public static function firstOrCreate(array $arr)
public static function firstOrCreate(array $attributes, array $values = [])
{
throw new ReadOnlyException(__FUNCTION__, get_called_class());
}

/**
* Throws ReadOnlyException on firstOrNew
* @param array $arr
* @param array $attributes
* @param array $values
* @throws ReadOnlyException
*/
public static function firstOrNew(array $arr)
public static function firstOrNew(array $attributes, array $values = [])
{
throw new ReadOnlyException(__FUNCTION__, get_called_class());
}

/**
* Throws ReadOnlyException on updateOrCreate
* @param array $attributes
* @param array $values
* @throws ReadOnlyException
*/
public static function updateOrCreate(array $attributes, array $values = [])
{
throw new ReadOnlyException(__FUNCTION__, get_called_class());
}
Expand Down Expand Up @@ -169,4 +182,4 @@ public function truncate()
{
throw new ReadOnlyException(__FUNCTION__, get_called_class());
}
}
}

0 comments on commit 218aac0

Please sign in to comment.