$this->primaryId(), 'logable_type' => get_class(), 'channel'=>$channel, ]); $Logable->logs()->save($Log); return $Log; } //访问记录 public function loglist() :MorphMany { return $this->morphMany(Log::class,'logable'); // return Log::where('logable_id',$this->primaryId())->where('logable_type',get_class())->get(); } public function haslog(Logable $Logable) { $result = log::where('logable_id',$this->primaryId()) ->where('logable_type',get_class()) ->where('log_id',$Logable->primaryId()) ->where('log_type', get_class($Logable)) ->exists(); return $result; } }