the browser-facing portion of osu!
at master 1.4 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Models; 7 8/** 9 * @property bool $build_on_tag 10 * @property \Illuminate\Database\Eloquent\Collection $changelogEntries ChangelogEntry 11 * @property \Carbon\Carbon|null $created_at 12 * @property string|null $default_category 13 * @property int $id 14 * @property UpdateStream $mainUpdateStream 15 * @property string $name 16 * @property int|null $stream_id 17 * @property \Carbon\Carbon|null $updated_at 18 */ 19class Repository extends Model 20{ 21 protected $casts = [ 22 'build_on_tag' => 'boolean', 23 ]; 24 25 public static function importFromGithub($data) 26 { 27 return static::firstOrCreate(['name' => $data['full_name']]); 28 } 29 30 public function mainUpdateStream() 31 { 32 return $this->belongsTo(UpdateStream::class, 'stream_id'); 33 } 34 35 public function updateStreams() 36 { 37 $bridgeTable = $GLOBALS['cfg']['database']['connections']['mysql']['database'].'.repository_update_stream'; 38 39 return $this->belongsToMany(UpdateStream::class, $bridgeTable, null, 'stream_id'); 40 } 41 42 public function changelogEntries() 43 { 44 return $this->hasMany(ChangelogEntry::class); 45 } 46 47 public function shortName() 48 { 49 return substr($this->name, 1 + strpos($this->name, '/')); 50 } 51}