The presence of this code:
class SearchIndex extends Eloquent {
protected $table = 'searchindex';
public $timestamps = false;
public $fillable = array('url', 'content', 'version', 'digest');
public $guarded = array();
public static function updateIndex($url, $version, $content)
{
self::retrieveSearchEntry($url, $version)->updateContent($content)->save();
}
public static function retrieveSearchEntry($url, $version)
{
try
{
return self::withoutContent()->where('url', $url)->where('version', $version)->firstOrFail(array('url', 'version', 'digest'));
}
catch(\Illuminate\Database\Eloquent\ModelNotFoundException $e)
{
return new SearchIndex(array('url' => $url, 'version' => $version));
}
}
public function updateContent($content)
{
$hash = md5($content);
if (!isset($this->digest) || ($this->digest != $hash))
{
$this->content = $content;
$this->digest = $hash;
}
return $this;
}
public static function search($content)
{
}
}
If I call updateIndex, providing a new combination of url + version, an entry is created.
If I call updateIndexby providing an existing url + version, pair , the record is not updated with new content . I see that this has something to do with the fact that I omit the "content" field (reason: it is huge, and I want to set it, not get it in this function).
a question . How can I not get the content field, but be able to set it when saving?
source
share