Server : Apache System : Linux 145.162.205.92.host.secureserver.net 5.14.0-611.45.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 1 05:56:53 EDT 2026 x86_64 User : tradze ( 1001) PHP Version : 8.1.34 Disable Function : NONE Directory : /home/tradze/www/test.tradze.com/app_old/Modules/Postcodes/Models/ |
<?php
namespace App\Modules\Postcodes\Models;
use Illuminate\Database\Eloquent\Model;
class Postcode extends Model
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table="postcodes";
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
/**
* The attributes that aren't mass assignable.
*
* @var array
*/
// protected $guarded = ['id'];
protected $fillable = ['postcode','zone_id','in_use'];
/**
* The postcode that belongs to zone
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function zone()
{
return $this->belongsTo('App\Modules\Postcodes\Models\Zone');
}
/**
* Scope a query to only include in use postcodes.
*
* @param $query
* @param null $search
* @return mixed
*/
public function scopeInUse($query,$search=null)
{
if ($search)
$query->where('in_use', '=', $search);
return $query;
}
/**
* Scope a query for a specific postcode.
*
* @param $query
* @param null $search
* @return mixed
*/
public function scopePostcode($query,$search=null)
{
if ($search)
$query->where('postcode', '=', $search);
return $query;
}
/**
* Scope a query for a specific county.
*
* @param $query
* @param null $search
* @return mixed
*/
public function scopeCounty($query,$search=null)
{
if ($search)
$query->where('county', '=', $search);
return $query;
}
/**
* Scope a query for a specific zone.
*
* @param $query
* @param null $search
* @return mixed
*/
public function scopeZone($query,$search=null)
{
if ($search)
$query->where('zone_id', '=', $search);
return $query;
}
}