/
proc
/
self
/
root
/
home
/
maktab
/
server
/
app
/
Models
/
File Upload :
llllll
Current File: //proc/self/root/home/maktab/server/app/Models/Maktab.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Maktab extends Model { use HasFactory; protected $fillable = [ 'title', 'address', 'count_student', 'year_establish', 'day_active', 'cloony_id', 'active', ]; protected $casts = [ 'active'=>"boolean" ]; public function users() { $cnt = Cnt::where('value', 'مربی')->first(); return $this->hasMany(User::class)->where(function ($query) use ($cnt) { $query->where('type', 3) ->orWhere(function ($query) use ($cnt) { $query->where('type', 4) ->where('type_employee', $cnt->id); }); }); } // public function users() // { // return $this->hasMany(User::class,'maktab_id') // ->where('type',3)->orWhere('type',4); // } public function master() { return $this->hasOne(User::class,'maktab_id') ->where('type',3); } public function cloony() { return $this->belongsTo(Cloony::class); } public function students() { return $this->hasMany(Student::class, 'maktab_id', 'id'); } }
Copyright ©2k19 -
Hexid
|
Tex7ure