46 lines
970 B
PHP
46 lines
970 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($field, $text, $country)
|
|
{
|
|
if ((strlen($text) >= 2 && $field == "name") || (strlen($text) > 3 && $field == 'typeName')) {
|
|
$result = $this->where($field, 'LIKE', '%' . $text . '%');
|
|
if ($country != '') {
|
|
$result->where('country', $country);
|
|
}
|
|
return $result->get();
|
|
}
|
|
|
|
return [];
|
|
}
|
|
|
|
protected function multisearch($codes, $countries)
|
|
{
|
|
//$countries = $
|
|
// return $this->where('code',$codes)->where('country',$countries);
|
|
}
|
|
}
|