Skip to content

Commit

Permalink
Merge pull request #1367 from shikorism/develop
Browse files Browse the repository at this point in the history
Release 2024.12.1
shibafu528 authored Dec 6, 2024
2 parents 956d260 + ce19d50 commit dd9ee82
Showing 34 changed files with 1,103 additions and 1,397 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ a.k.a. shikorism.net

## 構成

- Laravel 9
- Laravel 11
- Bootstrap 4.5.0

## 実行環境
9 changes: 2 additions & 7 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -9,21 +9,16 @@ class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
$schedule->command('tissue:lock:clean')->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__.'/Commands');

6 changes: 2 additions & 4 deletions app/ContentProvider.php
Original file line number Diff line number Diff line change
@@ -19,9 +19,7 @@ class ContentProvider extends Model
'robots_cached_at',
];

protected $dates = [
'created_at',
'updated_at',
'robots_cached_at',
protected $casts = [
'robots_cached_at' => 'datetime',
];
}
7 changes: 3 additions & 4 deletions app/Ejaculation.php
Original file line number Diff line number Diff line change
@@ -8,11 +8,10 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Staudenmeir\EloquentEagerLimit\HasEagerLimit;

class Ejaculation extends Model
{
use HasEagerLimit, HasFactory;
use HasFactory;

const SOURCE_WEB = 'web';
const SOURCE_CSV = 'csv';
@@ -26,8 +25,8 @@ class Ejaculation extends Model
'checkin_webhook_id', 'oauth_access_token_id',
];

protected $dates = [
'ejaculated_date'
protected $casts = [
'ejaculated_date' => 'datetime'
];

/** @var bool|null */
4 changes: 2 additions & 2 deletions app/Http/Controllers/Api/V1/UserStats/MostlyUsedLinks.php
Original file line number Diff line number Diff line change
@@ -61,13 +61,13 @@ private function countMostFrequentlyUsedOkazu(User $user, CarbonInterface $dateS
SQL;

if ($dateSince === null) {
$dateSince = CarbonImmutable::minValue();
$dateSince = CarbonImmutable::create(1);
}
if ($dateUntil === null) {
$dateUntil = now()->addMonth()->startOfMonth();
}

return DB::select(DB::raw($sql), [
return DB::select($sql, [
$user->id, false, Auth::check() && $user->id === Auth::id(), $dateSince, $dateUntil
]);
}
3 changes: 1 addition & 2 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -3,11 +3,10 @@
namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
use AuthorizesRequests, ValidatesRequests;
}
8 changes: 0 additions & 8 deletions app/Http/Controllers/Setting/TokenController.php
Original file line number Diff line number Diff line change
@@ -29,14 +29,6 @@ public function index()
->get();
$tokensLimit = User::PERSONAL_TOKEN_PER_USER_LIMIT;

// FIXME: どうしてこんなことをする羽目に...
$dateHacker = function () {
$this->dates[] = 'created_at';
};
foreach ($tokens as $token) {
$dateHacker->call($token);
}

return view('setting.tokens')->with(compact('tokens', 'tokensLimit'));
}

8 changes: 4 additions & 4 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
@@ -372,13 +372,13 @@ private function countUsedTagsIncludesMetadata(User $user, CarbonInterface $date
SQL;

if ($dateSince === null) {
$dateSince = Carbon::minValue();
$dateSince = Carbon::create(1);
}
if ($dateUntil === null) {
$dateUntil = now()->addMonth()->startOfMonth();
}

return DB::select(DB::raw($sql), [
return DB::select($sql, [
$user->id, false, Auth::check() && $user->id === Auth::id(), $dateSince, $dateUntil,
$user->id, false, Auth::check() && $user->id === Auth::id(), $dateSince, $dateUntil
]);
@@ -406,13 +406,13 @@ private function countMostFrequentlyUsedOkazu(User $user, CarbonInterface $dateS
SQL;

if ($dateSince === null) {
$dateSince = Carbon::minValue();
$dateSince = Carbon::create(1);
}
if ($dateUntil === null) {
$dateUntil = now()->addMonth()->startOfMonth();
}

return DB::select(DB::raw($sql), [
return DB::select($sql, [
$user->id, false, Auth::check() && $user->id === Auth::id(), $dateSince, $dateUntil
]);
}
8 changes: 3 additions & 5 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
@@ -52,13 +52,11 @@ class Kernel extends HttpKernel
];

/**
* The application's route middleware.
* The application's middleware aliases.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
protected $middlewareAliases = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
10 changes: 3 additions & 7 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
@@ -3,19 +3,15 @@
namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;

class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
protected function redirectTo(Request $request): ?string
{
if (! $request->expectsJson()) {
return route('login');
}
return $request->expectsJson() ? null : route('login');
}
}
6 changes: 2 additions & 4 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
@@ -6,18 +6,16 @@
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;

class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @param string|null ...$guards
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next, ...$guards)
public function handle(Request $request, Closure $next, string ...$guards): Response
{
$guards = empty($guards) ? [null] : $guards;

4 changes: 2 additions & 2 deletions app/Http/Middleware/TrustHosts.php
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@ class TrustHosts extends Middleware
/**
* Get the host patterns that should be trusted.
*
* @return array
* @return array<int, string|null>
*/
public function hosts()
public function hosts(): array
{
return [
$this->allSubdomainsOfApplicationUrl(),
4 changes: 3 additions & 1 deletion app/Information.php
Original file line number Diff line number Diff line change
@@ -20,5 +20,7 @@ class Information extends Model
'category', 'pinned', 'title', 'content'
];

protected $dates = ['deleted_at'];
protected $casts = [
'deleted_at' => 'datetime'
];
}
3 changes: 1 addition & 2 deletions app/Like.php
Original file line number Diff line number Diff line change
@@ -4,11 +4,10 @@

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Staudenmeir\EloquentEagerLimit\HasEagerLimit;

class Like extends Model
{
use HasEagerLimit, HasFactory;
use HasFactory;

protected $fillable = ['user_id', 'ejaculation_id'];

5 changes: 4 additions & 1 deletion app/Metadata.php
Original file line number Diff line number Diff line change
@@ -15,7 +15,10 @@ class Metadata extends Model
protected $fillable = ['url', 'title', 'description', 'image', 'expires_at'];
protected $visible = ['url', 'title', 'description', 'image', 'expires_at', 'tags'];

protected $dates = ['created_at', 'updated_at', 'expires_at', 'error_at'];
protected $casts = [
'expires_at' => 'datetime',
'error_at' => 'datetime',
];

public function tags()
{
8 changes: 2 additions & 6 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
@@ -23,10 +23,8 @@ class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
public function boot(): void
{
Blade::directive('parsedown', function ($expression) {
return "<?php echo app('parsedown')->text($expression); ?>";
@@ -77,10 +75,8 @@ public function boot()

/**
* Register any application services.
*
* @return void
*/
public function register()
public function register(): void
{
$this->app->singleton(MetadataResolver::class);
$this->app->singleton('parsedown', function () {
8 changes: 2 additions & 6 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ class AuthServiceProvider extends ServiceProvider
/**
* The policy mappings for the application.
*
* @var array
* @var array<class-string, class-string>
*/
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
@@ -22,13 +22,9 @@ class AuthServiceProvider extends ServiceProvider

/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
public function boot(): void
{
$this->registerPolicies();

Passport::hashClientSecrets();
Passport::personalAccessTokensExpireIn(now()->addYears(10));

4 changes: 1 addition & 3 deletions app/Providers/BroadcastServiceProvider.php
Original file line number Diff line number Diff line change
@@ -9,10 +9,8 @@ class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
public function boot(): void
{
Broadcast::routes();

16 changes: 10 additions & 6 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ class EventServiceProvider extends ServiceProvider
/**
* The event listener mappings for the application.
*
* @var array
* @var array<class-string, array<int, class-string>>
*/
protected $listen = [
Registered::class => [
@@ -25,13 +25,17 @@ class EventServiceProvider extends ServiceProvider

/**
* Register any events for your application.
*
* @return void
*/
public function boot()
public function boot(): void
{
parent::boot();

//
}

/**
* Determine if events and listeners should be automatically discovered.
*/
public function shouldDiscoverEvents(): bool
{
return false;
}
}
Loading

0 comments on commit dd9ee82

Please sign in to comment.