add disable user method

This commit is contained in:
xiaomlove
2021-05-14 02:11:57 +08:00
parent 0742ed33f8
commit 6d3068eb8c
4 changed files with 40 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ use App\Http\Middleware\Locale;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
@@ -154,4 +155,13 @@ class User extends Authenticatable
return $this->belongsTo(User::class, 'invited_by');
}
public function updateWithModComment(array $update, $modComment)
{
if (!$this->exists) {
throw new \RuntimeException('User not exists!');
}
$update['modcomment'] = DB::raw("concat_ws('\n', $modComment, modcomment)");
return $this->update($update);
}
}