Merge branch 'develop'

This commit is contained in:
snipe 2018-07-20 13:25:03 -07:00
commit 1956a16d1e
3 changed files with 21 additions and 2 deletions

View file

@ -156,6 +156,10 @@ class Consumable extends SnipeModel
return $this->belongsToMany('\App\Models\User', 'consumables_users', 'consumable_id', 'assigned_to')->count();
}
public function checkin_email()
{
return $this->category->checkin_email;
}
public function requireAcceptance()
{

View file

@ -228,7 +228,7 @@ class License extends Depreciable
public function checkin_email()
{
return $this->model->category->checkin_email;
return $this->category->checkin_email;
}
public function requireAcceptance()

View file

@ -53,7 +53,7 @@ trait Searchable {
* @param string $search The search term
* @return array An array of search terms
*/
private function prepeareSearchTerms(string $search) {
private function prepeareSearchTerms($search) {
return explode(' OR ', $search);
}
@ -68,6 +68,8 @@ trait Searchable {
$table = $this->getTable();
$firstConditionAdded = false;
foreach($this->getSearchableAttributes() as $column) {
foreach($terms as $term) {
@ -80,6 +82,19 @@ trait Searchable {
continue;
}
/**
* We need to form the query properly, starting with a "where",
* otherwise the generated select is wrong.
*
* @todo This does the job, but is inelegant and fragile
*/
if (!$firstConditionAdded) {
$query = $query->where($table . '.' . $column, 'LIKE', '%'.$term.'%');
$firstConditionAdded = true;
continue;
}
$query = $query->orWhere($table . '.' . $column, 'LIKE', '%'.$term.'%');
}
}