D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
forge
/
almahero.online
/
app
/
Models
/
Filename :
Student.php
back
Copy
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Str; class Student extends Model { use HasFactory; use SoftDeletes; protected $table = 'students'; protected $fillable = [ 'user_id', 'country_id', 'province_id', 'state_id', 'city_id', 'first_name', 'last_name', 'phone_number', 'postal_code', 'address', 'about_me', 'gender', 'status', 'organization_id', ]; public function user() { return $this->belongsTo(User::class, 'user_id'); } public function organization() { return $this->belongsTo(Organization::class, 'organization_id'); } public function country() { return $this->belongsTo(Country::class, 'country_id'); } public function state() { return $this->belongsTo(State::class, 'state_id'); } public function city() { return $this->belongsTo(City::class, 'city_id'); } public function getNameAttribute() { return $this->first_name .' '. $this->last_name; } public function scopeApproved($query) { return $query->where('status', 1); } public function scopePending($query) { return $query->where('status', 0); } protected static function boot() { parent::boot(); self::creating(function($model){ $model->uuid = Str::uuid()->toString(); }); } }