Files
ikea/app/Models/IkeaProducts.php
Jaroslav Drzik a5c3da9436
Some checks are pending
deploy / deploy (push) Waiting to run
search in typename if lengith > 2
2024-01-03 18:17:04 +01:00

43 lines
961 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class IkeaProducts extends Model
{
use HasFactory;
protected $table = 't_ikea_products';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = null;
/**
* Indicates if the model's ID is auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
protected function search($item)
{
if (strlen($item) >= 2 && strlen($item) <= 5) {
return $this->where('name', 'LIKE', $item . '%')->get();
} else if (strlen($item >= 5)) {
return $this->where('typeName', 'LIKE', '%' . $item . '%')->orWhere('name', 'LIKE', '%' . $item . '%')->get();
} else {
return [];
}
}
protected function multisearch($codes, $countries) {
//$countries = $
// return $this->where('code',$codes)->where('country',$countries);
}
}