Files
ikea/app/Models/IkeaProducts.php
Jaroslav Drzik fbcc3226fe
Some checks are pending
deploy / deploy (push) Waiting to run
search with country
2024-01-03 20:44:19 +01:00

47 lines
1.2 KiB
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,$country = '')
{
if (strlen($item) >= 2 && strlen($item) < 5) {
$result = $this->where('name', 'LIKE', $item . '%');
if ($country != '') $result = $result->where('country',$country);
return $result->get();
} else if (strlen($item >= 5)) {
if ($country != '') $result = $this->where('country',$country);
$result = $result->where(function ($query) use ($item) { $query->where('typeName', 'LIKE', '%' . $item . '%')->orWhere('name', 'LIKE', '%' . $item . '%'); } );
return $result->get();
}
}
protected function multisearch($codes, $countries) {
//$countries = $
// return $this->where('code',$codes)->where('country',$countries);
}
}