Release inicial 1.0.0
This commit is contained in:
50
Models/Localidad.php
Normal file
50
Models/Localidad.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Koneko\SatCatalogs\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Localidad extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'sat_localidad';
|
||||
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $fillable = [
|
||||
'c_localidad',
|
||||
'c_estado',
|
||||
'descripcion',
|
||||
'fecha_inicio_vigencia',
|
||||
'fecha_fin_vigencia',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'fecha_inicio_vigencia' => 'datetime',
|
||||
'fecha_fin_vigencia' => 'datetime',
|
||||
];
|
||||
|
||||
public static function selectList($c_estado, $c_localidad = false)
|
||||
{
|
||||
return self::select('c_localidad', 'descripcion')
|
||||
->where('c_estado', $c_estado)
|
||||
->when($c_localidad, function ($query) use ($c_localidad) {
|
||||
$query->where('c_localidad', $c_localidad);
|
||||
})
|
||||
->orderBy('descripcion')
|
||||
->pluck('descripcion', 'c_localidad');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user