File manager - Edit - /home/linknsbh/proffy.online/app/Models/State.php
Back
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; /** * App\Models\State * * @property int $id * @property string $name * @property int $country_id * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at * @property-read \App\Models\City $city * @property-read \App\Models\Country $country * @property-read string $country_name * * @method static \Illuminate\Database\Eloquent\Builder|State newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|State newQuery() * @method static \Illuminate\Database\Eloquent\Builder|State query() * @method static \Illuminate\Database\Eloquent\Builder|State whereCountryId($value) * @method static \Illuminate\Database\Eloquent\Builder|State whereCreatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|State whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|State whereName($value) * @method static \Illuminate\Database\Eloquent\Builder|State whereUpdatedAt($value) * * @mixin \Eloquent */ class State extends Model { use HasFactory; public $table = 'states'; public $fillable = [ 'name', 'country_id', ]; /** * The attributes that should be casted to native types. * * @var array */ protected $casts = [ 'id' => 'integer', 'name' => 'string', 'country_id' => 'integer', ]; /** * Validation rules * * @var array */ public static $rules = [ 'name' => 'required|string|max:170|unique:states,name', 'country_id' => 'required', ]; protected $appends = ['country_name']; public function getCountryNameAttribute(): string { return $this->country->name ?? 'N/A'; } public function country(): BelongsTo { return $this->belongsTo(Country::class, 'country_id'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.2.31 | Generation time: 0.57 |
proxy
|
phpinfo
|
Settings