-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into team-logo-size
- Loading branch information
Showing
514 changed files
with
5,808 additions
and
986 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Casts; | ||
|
||
use Carbon\Carbon; | ||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||
|
||
/** | ||
* For columns which use unix timestamp as its value and repurpose 0 as null. | ||
*/ | ||
class TimestampOrZero implements CastsAttributes | ||
{ | ||
public function get($model, string $key, $value, array $attributes) | ||
{ | ||
return $value === null || $value === 0 ? null : Carbon::createFromTimestamp($value); | ||
} | ||
|
||
public function set($model, string $key, $value, array $attributes) | ||
{ | ||
return $value === null ? 0 : $value->getTimestamp(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers\Teams; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Team; | ||
use App\Models\TeamMember; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class MembersController extends Controller | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->middleware('auth'); | ||
} | ||
|
||
public function destroy(string $teamId, string $userId): Response | ||
{ | ||
$teamMember = TeamMember::where([ | ||
'team_id' => $teamId, | ||
'user_id' => $userId, | ||
])->firstOrFail(); | ||
|
||
if ($teamMember->user_id === \Auth::user()->getKey()) { | ||
abort(422, 'can not remove self from team'); | ||
} | ||
|
||
priv_check('TeamUpdate', $teamMember->team)->ensureCan(); | ||
|
||
$teamMember->delete(); | ||
\Session::flash('popup', osu_trans('teams.members.destroy.success')); | ||
|
||
return response(null, 204); | ||
} | ||
|
||
public function index(string $teamId): Response | ||
{ | ||
$team = Team::findOrFail($teamId); | ||
|
||
priv_check('TeamUpdate', $team)->ensureCan(); | ||
|
||
$team->load('members.user'); | ||
|
||
return ext_view('teams.members.index', compact('team')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.