Skip to content

Commit

Permalink
Merge pull request #71 from chorkleines/refactor
Browse files Browse the repository at this point in the history
Remove unused functions and models
  • Loading branch information
nozomu-y authored Aug 4, 2023
2 parents a494cd2 + a8506db commit b77e6dc
Show file tree
Hide file tree
Showing 18 changed files with 131 additions and 350 deletions.
26 changes: 0 additions & 26 deletions api/app/Enums/BulletinBoardStatus.php

This file was deleted.

36 changes: 0 additions & 36 deletions api/app/Enums/Part.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,4 @@ final class Part extends Enum
const TENOR = 'T';

const BASS = 'B';

public static function getDescriptionAbbrev($value): string
{
if ($value == self::SOPRANO) {
return 'Sop.';
}
if ($value == self::ALTO) {
return 'Alt.';
}
if ($value == self::TENOR) {
return 'Ten.';
}
if ($value == self::BASS) {
return 'Bas.';
}

return parent::getDescription($value);
}

public static function getDescriptionJp($value): string
{
if ($value == self::SOPRANO) {
return 'ソプラノ';
}
if ($value == self::ALTO) {
return 'アルト';
}
if ($value == self::TENOR) {
return 'テナー';
}
if ($value == self::BASS) {
return 'ベース';
}

return parent::getDescription($value);
}
}
12 changes: 0 additions & 12 deletions api/app/Enums/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,4 @@ final class PaymentMethod extends Enum
const CASH = 'CASH';

const INDIVIDUAL_ACCOUNTING = 'INDIVIDUAL_ACCOUNTING';

public static function getDescription(mixed $value): string
{
if ($value == self::CASH) {
return '現金';
}
if ($value == self::INDIVIDUAL_ACCOUNTING) {
return '個別会計';
}

return parent::getDescription($value);
}
}
16 changes: 0 additions & 16 deletions api/app/Enums/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,4 @@ final class Role extends Enum
const ACCOUNTANT = 'ACCOUNTANT';

const CAMP = 'CAMP';

public static function getDescription($value): string
{
if ($value === self::MASTER) {
return '管理人';
}
if ($value === self::MANAGER) {
return '運営';
}
if ($value === self::ACCOUNTANT) {
return '会計';
}
if ($value === self::CAMP) {
return '合宿委員';
}
}
}
15 changes: 0 additions & 15 deletions api/app/Enums/UserStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,4 @@ final class UserStatus extends Enum
const ABSENT = 'ABSENT';

const RESIGNED = 'RESIGNED';

public static function getDescription($value): string
{
if ($value == self::PRESENT) {
return '在団';
}
if ($value == self::ABSENT) {
return '休団';
}
if ($value == self::RESIGNED) {
return '退団';
}

return parent::getDescription($value);
}
}
40 changes: 0 additions & 40 deletions api/app/Models/BulletinBoard.php

This file was deleted.

28 changes: 0 additions & 28 deletions api/app/Models/BulletinBoardContent.php

This file was deleted.

24 changes: 0 additions & 24 deletions api/app/Models/BulletinBoardHashtag.php

This file was deleted.

27 changes: 0 additions & 27 deletions api/app/Models/BulletinBoardView.php

This file was deleted.

46 changes: 1 addition & 45 deletions api/app/Models/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Kyslik\ColumnSortable\Sortable;

class Profile extends Model
{
use HasFactory, Sortable;
use HasFactory;

protected $fillable = [
'user_id',
Expand Down Expand Up @@ -40,51 +39,8 @@ class Profile extends Model
'birthday',
];

public $sortable = ['name_kana', 'grade', 'part'];

private $partOrderRaw = 'CASE WHEN profiles.part LIKE "S" THEN 1 WHEN profiles.part LIKE "A" THEN 2 WHEN profiles.part LIKE "T" THEN 3 WHEN profiles.part LIKE "B" THEN 4 END';

public function nameSortable($query, $direction)
{
return $query
->orderBy('name_kana', $direction)
->orderBy('grade', 'ASC')
->orderByRaw($this->partOrderRaw.' ASC')
->select('profiles.*');
}

public function gradeSortable($query, $direction)
{
return $query
->orderBy('grade', $direction)
->orderByRaw($this->partOrderRaw.' ASC')
->orderBy('name_kana', 'ASC')
->select('profiles.*');
}

public function partSortable($query, $direction)
{
return $query
->orderByRaw($this->partOrderRaw.' '.$direction)
->orderBy('grade', 'ASC')
->orderBy('name_kana', 'ASC')
->select('profiles.*');
}

public function user()
{
return $this->hasOne(User::class, 'user_id');
}

public function display_name()
{
$display_name =
str_pad($this->grade, 2, 0, STR_PAD_LEFT).
$this->part->value.
' '.
$this->last_name.
$this->first_name;

return $display_name;
}
}
3 changes: 1 addition & 2 deletions api/app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Providers;

use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -24,6 +23,6 @@ public function register()
*/
public function boot()
{
Paginator::useBootstrap();
//
}
}
1 change: 0 additions & 1 deletion api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"bensampo/laravel-enum": "^6.0",
"doctrine/dbal": "^3.6",
"guzzlehttp/guzzle": "^7.2",
"kyslik/column-sortable": "^6.4",
"laravel/framework": "^9.19",
"laravel/sanctum": "^3.0",
"laravel/tinker": "^2.7"
Expand Down
Loading

0 comments on commit b77e6dc

Please sign in to comment.