mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 06:27:59 +01:00
Merging accounts now redirects old URL
This commit is contained in:
parent
c7c962e91b
commit
e844054643
4 changed files with 45 additions and 2 deletions
|
@ -129,6 +129,7 @@ class MergeAccountsCommand extends CommandBase
|
|||
}
|
||||
|
||||
$this->sourceAccount->disabled_at = Carbon::now();
|
||||
$this->sourceAccount->redirect_to = $this->destinationAccount->id;
|
||||
$this->sourceAccount->save();
|
||||
});
|
||||
|
||||
|
|
|
@ -44,8 +44,17 @@ class ArtistsController extends Controller
|
|||
|
||||
public function getProfile($slug)
|
||||
{
|
||||
$user = User::whereSlug($slug)->whereNull('disabled_at')->first();
|
||||
if (!$user) {
|
||||
$user = User::whereSlug($slug)->first();
|
||||
|
||||
if ($user->redirect_to) {
|
||||
$newUser = User::find($user->redirect_to)->first();
|
||||
|
||||
if ($newUser) {
|
||||
return Redirect::action('ArtistsController@getProfile', [$newUser->slug]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($user->disabled_at) {
|
||||
App::abort('404');
|
||||
}
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||
'comment_count' => 'integer',
|
||||
'avatar_id' => 'integer',
|
||||
'is_archived' => 'boolean',
|
||||
'redirect_to' => 'integer'
|
||||
];
|
||||
protected $dates = ['created_at', 'updated_at', 'disabled_at'];
|
||||
protected $hidden = ['disabled_at', 'remember_token'];
|
||||
|
|
32
database/migrations/2017_09_20_200156_AddRedirectToUsers.php
Normal file
32
database/migrations/2017_09_20_200156_AddRedirectToUsers.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddRedirectToUsers extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->integer('redirect_to')->unsigned()->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('redirect_to');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue