コード例 #1
0
ファイル: Topic.php プロジェクト: a4501150/FDUGroup
 /**
  * Override delete method
  * Delete topic itself and all it's comments, ratings, and view counter
  */
 public function delete()
 {
     $tid = $this->id;
     // delete view counter
     Counter::where("[entityId] = ? AND [entityTypeId] = ?", [$tid, Topic::ENTITY_TYPE])->delete();
     Rating::where("[entityId] = ? AND [entityType] = ?", [$tid, Topic::ENTITY_TYPE])->delete();
     RatingStatistic::where("[entityId] = ? AND [entityType] = ?", [$tid, Topic::ENTITY_TYPE])->delete();
     Comment::where("[topicId] = ?", $tid)->delete();
     parent::delete();
 }
コード例 #2
0
function average_view_count()
{
    $allvalue = Counter::where('page', 'home')->sum('count');
    $allday = Counter::where('page', 'home')->count();
    $perday = $allvalue / $allday;
    $perday = round($perday);
    return $perday;
}
コード例 #3
0
ファイル: Group.php プロジェクト: a4501150/FDUGroup
 public static function deleteGroup(Group $group)
 {
     Rating::where("[entityId] = ? AND [entityType] = ?", [$group->id, Group::ENTITY_TYPE])->delete();
     RatingStatistic::where("[entityId] = ? AND [entityType] = ?", [$group->id, Group::ENTITY_TYPE])->delete();
     Counter::where("[entityId] = ? AND [entityTypeId] = ?", [$group->id, Group::ENTITY_TYPE])->delete();
     $topics = Topic::find("groupId", $group->id)->all();
     foreach ($topics as $topic) {
         $topic->delete();
     }
     GroupUser::where("[groupId] = ?", $group->id)->delete();
     $group->delete();
 }