상속: extends Illuminate\Database\Eloquent\Model, use trait App\Traits\Validatable
예제 #1
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     Validator::extend('mixture', function ($attribute, $value, $parameters, $validator) {
         return preg_match('/[\\d]/', $value) === 1 && preg_match('/[^\\d\\s]/', $value) === 1;
     });
     BeatmapDiscussion::saving(function ($discussion) {
         return $discussion->isValid();
     });
     BeatmapDiscussionPost::saving(function ($post) {
         return $post->isValid();
     });
     ForumPollVote::saving(function ($vote) {
         return $vote->isValid();
     });
 }
예제 #2
0
파일: PollOption.php 프로젝트: ppy/osu-web
 public static function updateTotals($filters)
 {
     $staticTable = (new static())->table;
     $countQuery = PollVote::where(['topic_id' => DB::raw($staticTable . '.topic_id'), 'poll_option_id' => DB::raw($staticTable . '.poll_option_id')])->select(DB::raw('COUNT(DISTINCT vote_user_id)'))->toSql();
     return static::where($filters)->update(['poll_option_total' => DB::raw("({$countQuery})")]);
 }