Skip to content

Commit

Permalink
style: fix (updated) code style
Browse files Browse the repository at this point in the history
  • Loading branch information
JaZo committed Mar 27, 2024
1 parent 5441932 commit 8d0061d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/Indexable.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function indexedRecord()

public function indexRecord()
{
if (null === $this->indexedRecord) {
if ($this->indexedRecord === null) {
$this->indexedRecord = new IndexedRecord();
$this->indexedRecord->indexable()->associate($this);
}
Expand All @@ -41,7 +41,7 @@ public function indexRecord()

public function unIndexRecord()
{
if (null !== $this->indexedRecord) {
if ($this->indexedRecord !== null) {
$this->indexedRecord->delete();
}
}
Expand Down
15 changes: 7 additions & 8 deletions src/ModelObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ModelObserver
/**
* Enable syncing for the given class.
*
* @param string $class
* @param string $class
*/
public static function enableSyncingFor($class)
{
Expand All @@ -24,7 +24,7 @@ public static function enableSyncingFor($class)
/**
* Disable syncing for the given class.
*
* @param string $class
* @param string $class
*/
public static function disableSyncingFor($class)
{
Expand All @@ -34,8 +34,7 @@ public static function disableSyncingFor($class)
/**
* Determine if syncing is disabled for the given class or model.
*
* @param object|string $class
*
* @param object|string $class
* @return bool
*/
public static function syncingDisabledFor($class)
Expand All @@ -48,7 +47,7 @@ public static function syncingDisabledFor($class)
/**
* Handle the created event for the model.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Database\Eloquent\Model $model
*/
public function created($model)
{
Expand All @@ -62,7 +61,7 @@ public function created($model)
/**
* Handle the updated event for the model.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Database\Eloquent\Model $model
*/
public function updated($model)
{
Expand All @@ -72,7 +71,7 @@ public function updated($model)
/**
* Handle the deleted event for the model.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Database\Eloquent\Model $model
*/
public function deleted($model)
{
Expand All @@ -86,7 +85,7 @@ public function deleted($model)
/**
* Handle the restored event for the model.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Database\Eloquent\Model $model
*/
public function restored($model)
{
Expand Down
19 changes: 8 additions & 11 deletions src/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
class Search implements SearchInterface
{
/**
* @param string $search
*
* @param string $search
* @return \Illuminate\Database\Eloquent\Collection|\Swis\Laravel\Fulltext\IndexedRecord[]
*/
public function run($search)
Expand All @@ -17,9 +16,8 @@ public function run($search)
}

/**
* @param string $search
* @param string $class
*
* @param string $search
* @param string $class
* @return \Illuminate\Database\Eloquent\Collection|\Swis\Laravel\Fulltext\IndexedRecord[]
*/
public function runForClass($search, $class)
Expand All @@ -31,8 +29,7 @@ public function runForClass($search, $class)
}

/**
* @param string $search
*
* @param string $search
* @return \Illuminate\Database\Eloquent\Builder
*/
public function searchQuery($search)
Expand All @@ -51,12 +48,12 @@ public function searchQuery($search)
$contentWeight = str_replace(',', '.', (float) config('laravel-fulltext.weight.content', 1.0));

$query = IndexedRecord::query()
->whereRaw('MATCH (indexed_title, indexed_content) AGAINST (? IN BOOLEAN MODE)', [$termsBool])
->orderByRaw(
'('.$titleWeight.' * (MATCH (indexed_title) AGAINST (?)) +
->whereRaw('MATCH (indexed_title, indexed_content) AGAINST (? IN BOOLEAN MODE)', [$termsBool])
->orderByRaw(
'('.$titleWeight.' * (MATCH (indexed_title) AGAINST (?)) +
'.$contentWeight.' * (MATCH (indexed_title, indexed_content) AGAINST (?))
) DESC',
[$termsMatch, $termsMatch])
[$termsMatch, $termsMatch])
->limit(config('laravel-fulltext.limit-results'));

if (config('laravel-fulltext.exclude_feature_enabled')) {
Expand Down

0 comments on commit 8d0061d

Please sign in to comment.