chore: code styling via pint
This commit is contained in:
@@ -8,14 +8,17 @@ use Session;
|
||||
class Bulk extends Component
|
||||
{
|
||||
public $bulkEmails = [];
|
||||
|
||||
public $bulkCount = 1;
|
||||
|
||||
private $isSubscribed = false;
|
||||
|
||||
public function mount() {
|
||||
public function mount()
|
||||
{
|
||||
$subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']);
|
||||
Session::put('isSubscribed', $subscriptionCheck);
|
||||
}
|
||||
|
||||
public function generateBulk()
|
||||
{
|
||||
$this->validate([
|
||||
@@ -34,11 +37,11 @@ class Bulk extends Component
|
||||
public function downloadBulk()
|
||||
{
|
||||
// Ensure there's something to download
|
||||
if (empty($this->bulkEmails) || !is_array($this->bulkEmails)) {
|
||||
if (empty($this->bulkEmails) || ! is_array($this->bulkEmails)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = 'bulk_emails_' . now()->format('Ymd_His') . '.txt';
|
||||
$filename = 'bulk_emails_'.now()->format('Ymd_His').'.txt';
|
||||
$content = implode(PHP_EOL, $this->bulkEmails);
|
||||
|
||||
return response()->streamDownload(function () use ($content) {
|
||||
@@ -49,40 +52,42 @@ class Bulk extends Component
|
||||
private function randomEmail(): string
|
||||
{
|
||||
$domain = $this->getRandomDomain();
|
||||
if ($domain == "gmail.com" || $domain == "googlemail.com") {
|
||||
if ($domain == 'gmail.com' || $domain == 'googlemail.com') {
|
||||
$uname = $this->getRandomGmailUser();
|
||||
$uname_len = strlen($uname);
|
||||
$len_power = $uname_len - 1;
|
||||
$combination = pow(2,$len_power);
|
||||
$rand_comb = mt_rand(1,$combination);
|
||||
$formatted = implode(' ',str_split($uname));
|
||||
$combination = pow(2, $len_power);
|
||||
$rand_comb = mt_rand(1, $combination);
|
||||
$formatted = implode(' ', str_split($uname));
|
||||
$uname_exp = explode(' ', $formatted);
|
||||
|
||||
$bin = intval("");
|
||||
for($i=0; $i<$len_power; $i++) {
|
||||
$bin .= mt_rand(0,1);
|
||||
$bin = intval('');
|
||||
for ($i = 0; $i < $len_power; $i++) {
|
||||
$bin .= mt_rand(0, 1);
|
||||
}
|
||||
$bin = explode(' ', implode(' ',str_split(strval($bin))));
|
||||
$bin = explode(' ', implode(' ', str_split(strval($bin))));
|
||||
|
||||
$email = "";
|
||||
for($i=0; $i<$len_power; $i++) {
|
||||
$email = '';
|
||||
for ($i = 0; $i < $len_power; $i++) {
|
||||
$email .= $uname_exp[$i];
|
||||
if($bin[$i]) {
|
||||
$email .= ".";
|
||||
if ($bin[$i]) {
|
||||
$email .= '.';
|
||||
}
|
||||
}
|
||||
$email .= $uname_exp[$i];
|
||||
$gmail_rand = mt_rand(1,10);
|
||||
if($gmail_rand > 5) {
|
||||
$email .= "@gmail.com";
|
||||
$gmail_rand = mt_rand(1, 10);
|
||||
if ($gmail_rand > 5) {
|
||||
$email .= '@gmail.com';
|
||||
} else {
|
||||
$email .= "@googlemail.com";
|
||||
$email .= '@googlemail.com';
|
||||
}
|
||||
|
||||
return $email;
|
||||
} else {
|
||||
return $this->generateRandomUsername().'@'.$domain;
|
||||
}
|
||||
}
|
||||
|
||||
private function generateRandomUsername(): string
|
||||
{
|
||||
$start = json_decode(config('app.settings.configuration_settings'))->random_username_length_min ?? 0;
|
||||
@@ -90,36 +95,48 @@ class Bulk extends Component
|
||||
if ($start == 0 && $end == 0) {
|
||||
return $this->generatePronounceableWord();
|
||||
}
|
||||
|
||||
return $this->generatedRandomBetweenLength($start, $end);
|
||||
}
|
||||
|
||||
private function generatedRandomBetweenLength($start, $end): string
|
||||
{
|
||||
$length = rand($start, $end);
|
||||
|
||||
return $this->generateRandomString($length);
|
||||
}
|
||||
private function getRandomDomain() {
|
||||
|
||||
private function getRandomDomain()
|
||||
{
|
||||
$domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
$count = count($domains);
|
||||
|
||||
return $count > 0 ? $domains[rand(1, $count) - 1] : '';
|
||||
}
|
||||
private function getRandomGmailUser() {
|
||||
|
||||
private function getRandomGmailUser()
|
||||
{
|
||||
$gmailusername = json_decode(config('app.settings.configuration_settings'))->premium_gmailUsernames ?? [];
|
||||
$count = count($gmailusername);
|
||||
|
||||
return $count > 0 ? $gmailusername[rand(1, $count) - 1] : '';
|
||||
}
|
||||
|
||||
private function generatePronounceableWord(): string
|
||||
{
|
||||
$c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones
|
||||
$v = 'aeiou'; //vowels
|
||||
$a = $c . $v; //both
|
||||
$c = 'bcdfghjklmnprstvwz'; // consonants except hard to speak ones
|
||||
$v = 'aeiou'; // vowels
|
||||
$a = $c.$v; // both
|
||||
$random = '';
|
||||
for ($j = 0; $j < 2; $j++) {
|
||||
$random .= $c[rand(0, strlen($c) - 1)];
|
||||
$random .= $v[rand(0, strlen($v) - 1)];
|
||||
$random .= $a[rand(0, strlen($a) - 1)];
|
||||
}
|
||||
|
||||
return $random;
|
||||
}
|
||||
|
||||
private function generateRandomString($length = 10): string
|
||||
{
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
@@ -128,6 +145,7 @@ class Bulk extends Component
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,15 +4,17 @@ namespace App\Livewire\Dashboard;
|
||||
|
||||
use Livewire\Component;
|
||||
use Session;
|
||||
use function Pest\Laravel\withoutMockingConsoleOutput;
|
||||
|
||||
class BulkGmail extends Component
|
||||
{
|
||||
public $email;
|
||||
|
||||
public int $quantity = 10;
|
||||
|
||||
public $bulkEmails = [];
|
||||
|
||||
public function mount() {
|
||||
public function mount()
|
||||
{
|
||||
$subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']);
|
||||
Session::put('isSubscribed', $subscriptionCheck);
|
||||
}
|
||||
@@ -32,17 +34,17 @@ class BulkGmail extends Component
|
||||
$this->bulkEmails = [];
|
||||
}
|
||||
|
||||
$this->bulkEmails = $this->generateDotVariants(explode("@", $this->email)[0], $this->quantity);
|
||||
$this->bulkEmails = $this->generateDotVariants(explode('@', $this->email)[0], $this->quantity);
|
||||
}
|
||||
|
||||
public function downloadBulk()
|
||||
{
|
||||
// Ensure there's something to download
|
||||
if (empty($this->bulkEmails) || !is_array($this->bulkEmails)) {
|
||||
if (empty($this->bulkEmails) || ! is_array($this->bulkEmails)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = 'bulk_gmails_' . now()->format('Ymd_His') . '.txt';
|
||||
$filename = 'bulk_gmails_'.now()->format('Ymd_His').'.txt';
|
||||
$content = implode(PHP_EOL, $this->bulkEmails);
|
||||
|
||||
return response()->streamDownload(function () use ($content) {
|
||||
@@ -66,11 +68,11 @@ class BulkGmail extends Component
|
||||
$lastPos = 0;
|
||||
|
||||
foreach ($combo as $pos) {
|
||||
$dotted .= substr($uname, $lastPos, $pos - $lastPos) . '.';
|
||||
$dotted .= substr($uname, $lastPos, $pos - $lastPos).'.';
|
||||
$lastPos = $pos;
|
||||
}
|
||||
$dotted .= substr($uname, $lastPos);
|
||||
$results[] = $dotted . '@gmail.com';
|
||||
$results[] = $dotted.'@gmail.com';
|
||||
|
||||
if (count($results) >= $quantity) {
|
||||
return $results;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Livewire\Dashboard;
|
||||
|
||||
use Stripe\StripeClient;
|
||||
use Log;
|
||||
use App\Models\UsageLog;
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
@@ -11,13 +9,19 @@ use DB;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Livewire\Component;
|
||||
use Log;
|
||||
use Stripe\StripeClient;
|
||||
|
||||
class Dashboard extends Component
|
||||
{
|
||||
public $message;
|
||||
|
||||
public $usageLog;
|
||||
|
||||
public $subscription;
|
||||
|
||||
public $plans;
|
||||
|
||||
public $showStripeBilling = false;
|
||||
|
||||
public function paymentStatus(Request $request)
|
||||
@@ -26,6 +30,7 @@ class Dashboard extends Component
|
||||
$currentUrl = $request->fullUrl();
|
||||
if ($status == 'success') {
|
||||
$this->syncSubscription();
|
||||
|
||||
return redirect()->route('dashboard')->with('status', 'success');
|
||||
} elseif ($status == 'cancel') {
|
||||
return redirect()->route('dashboard')->with('status', 'cancel');
|
||||
@@ -39,13 +44,13 @@ class Dashboard extends Component
|
||||
$userId = $user->id;
|
||||
if ($user->subscribed()) {
|
||||
$subscription = $user->subscriptions()
|
||||
//->where(['stripe_status' => 'active'])
|
||||
// ->where(['stripe_status' => 'active'])
|
||||
->orderByDesc('updated_at')
|
||||
->first();
|
||||
if ($subscription !== null) {
|
||||
$subscriptionId = $subscription->stripe_id;
|
||||
$cacheKey = "stripe_check_executed_user_{$userId}_{$subscriptionId}";
|
||||
if (!Cache::has($cacheKey)) {
|
||||
if (! Cache::has($cacheKey)) {
|
||||
try {
|
||||
$stripe = new StripeClient(config('cashier.secret'));
|
||||
$subscriptionData = $stripe->subscriptions->retrieve($subscriptionId, []);
|
||||
@@ -60,11 +65,11 @@ class Dashboard extends Component
|
||||
if ($cancel_at_period_end) {
|
||||
$final_ends_at = Carbon::createFromTimestamp($cancel_at)->toDateTimeString();
|
||||
} else {
|
||||
if ($cancel_at === null && $canceled_at !== null && $status === "canceled" && $cancel_at_period_end === false) {
|
||||
//$final_ends_at = Carbon::createFromTimestamp($canceled_at)->toDateTimeString();
|
||||
if ($cancel_at === null && $canceled_at !== null && $status === 'canceled' && $cancel_at_period_end === false) {
|
||||
// $final_ends_at = Carbon::createFromTimestamp($canceled_at)->toDateTimeString();
|
||||
$final_ends_at = Carbon::now()->subDays(2)->toDateTimeString();
|
||||
$redirect = true;
|
||||
} elseif($status === "active" && $cancel_at !== null) {
|
||||
} elseif ($status === 'active' && $cancel_at !== null) {
|
||||
$final_ends_at = Carbon::createFromTimestamp($cancel_at)->toDateTimeString();
|
||||
} else {
|
||||
$final_ends_at = null;
|
||||
@@ -88,6 +93,7 @@ class Dashboard extends Component
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $redirect;
|
||||
}
|
||||
|
||||
@@ -98,7 +104,7 @@ class Dashboard extends Component
|
||||
if ($user->hasStripeId()) {
|
||||
$stripe = new StripeClient(config('cashier.secret'));
|
||||
$subscriptions = $stripe->subscriptions->all(['limit' => 1]);
|
||||
if (!$subscriptions->isEmpty()) {
|
||||
if (! $subscriptions->isEmpty()) {
|
||||
$data = $subscriptions->data[0];
|
||||
$items = $subscriptions->data[0]->items->data[0];
|
||||
|
||||
@@ -110,7 +116,7 @@ class Dashboard extends Component
|
||||
$stripe_price = $items->price->id;
|
||||
$stripe_product = $items->price->product;
|
||||
$ends_at = $items->current_period_end;
|
||||
$subscriptionItemId = $items->id;
|
||||
$subscriptionItemId = $items->id;
|
||||
if ($cancel_at_period_end) {
|
||||
$final_ends_at = Carbon::createFromTimestamp($ends_at)->toDateTimeString();
|
||||
} else {
|
||||
@@ -118,7 +124,7 @@ class Dashboard extends Component
|
||||
}
|
||||
|
||||
try {
|
||||
if ($status === "active") {
|
||||
if ($status === 'active') {
|
||||
$subscriptionsTable = DB::table('subscriptions')->where(['stripe_id' => $subscriptionId])->first();
|
||||
if ($subscriptionsTable == null) {
|
||||
$subscriptionsTable = DB::table('subscriptions')->insert([
|
||||
@@ -158,9 +164,9 @@ class Dashboard extends Component
|
||||
|
||||
public function mount(Request $request)
|
||||
{
|
||||
if($this->checkForSubscriptionStatus()) {
|
||||
if ($this->checkForSubscriptionStatus()) {
|
||||
return redirect()->route('dashboard');
|
||||
};
|
||||
}
|
||||
try {
|
||||
$status = $request->session()->get('status');
|
||||
if (isset($status)) {
|
||||
@@ -176,7 +182,7 @@ class Dashboard extends Component
|
||||
}
|
||||
|
||||
$plans = config('app.plans', []);
|
||||
if (!empty($plans) && isset($plans[0]) && is_array($plans[0]) && isset($plans[0]['product_id']) && auth()->user()->subscribedToProduct($plans[0]['product_id'])) {
|
||||
if (! empty($plans) && isset($plans[0]) && is_array($plans[0]) && isset($plans[0]['product_id']) && auth()->user()->subscribedToProduct($plans[0]['product_id'])) {
|
||||
try {
|
||||
$result = auth()->user()->subscriptions()->where(['stripe_status' => 'active'])->orderByDesc('updated_at')->first();
|
||||
if ($result != null) {
|
||||
|
||||
@@ -2,44 +2,62 @@
|
||||
|
||||
namespace App\Livewire\Dashboard\Mailbox;
|
||||
|
||||
use Exception;
|
||||
use App\ColorPicker;
|
||||
use App\Models\Log;
|
||||
use App\Models\Premium;
|
||||
use App\Models\PremiumEmail;
|
||||
use App\Models\UsageLog;
|
||||
use App\Models\ZEmail;
|
||||
use Artisan;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Livewire\Component;
|
||||
use Session;
|
||||
|
||||
class Inbox extends Component
|
||||
{
|
||||
use ColorPicker;
|
||||
|
||||
public $messages = [];
|
||||
|
||||
public $deleted = [];
|
||||
|
||||
public $error = '';
|
||||
|
||||
public $email;
|
||||
|
||||
public $initial = false;
|
||||
|
||||
public $type;
|
||||
|
||||
public $overflow = false;
|
||||
|
||||
public $messageId;
|
||||
|
||||
public $list = false;
|
||||
|
||||
public $emails;
|
||||
|
||||
public $mailboxHistory;
|
||||
|
||||
public $emailsHistory;
|
||||
public $username, $domain, $domains, $action;
|
||||
|
||||
public $username;
|
||||
|
||||
public $domain;
|
||||
|
||||
public $domains;
|
||||
|
||||
public $action;
|
||||
|
||||
public $email_limit = 20;
|
||||
|
||||
public bool $premium = true;
|
||||
|
||||
private $isSubscribed;
|
||||
|
||||
protected $listeners = ['updateEmail' => 'syncEmail', 'getEmail' => 'generateEmail', 'fetchMessages' => 'fetch', 'setMessageId' => 'setMessageId'];
|
||||
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->premium = Session::get('isInboxTypePremium', true);
|
||||
@@ -64,7 +82,7 @@ class Inbox extends Component
|
||||
|
||||
$subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']);
|
||||
Session::put('isSubscribed', $subscriptionCheck);
|
||||
if($subscriptionCheck) {
|
||||
if ($subscriptionCheck) {
|
||||
try {
|
||||
$result = auth()->user()->subscriptions()->where(['stripe_status' => 'active'])->orderByDesc('updated_at')->first();
|
||||
$userPriceID = $result['items'][0]['stripe_price'];
|
||||
@@ -116,7 +134,7 @@ class Inbox extends Component
|
||||
} else {
|
||||
$domains = json_decode(config('app.settings.configuration_settings'))->domains ?? [];
|
||||
}
|
||||
if (!in_array($domain, $domains)) {
|
||||
if (! in_array($domain, $domains)) {
|
||||
return $this->showAlert('error', __('This mailbox can not be recovered.'));
|
||||
}
|
||||
}
|
||||
@@ -150,24 +168,25 @@ class Inbox extends Component
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
public function create() {
|
||||
if (!$this->username) {
|
||||
public function create()
|
||||
{
|
||||
if (! $this->username) {
|
||||
return $this->showAlert('error', __('Please enter Username'));
|
||||
}
|
||||
$this->checkDomainInUsername();
|
||||
if (strlen($this->username) < json_decode(config('app.settings.configuration_settings'))->custom_username_length_min || strlen($this->username) > json_decode(config('app.settings.configuration_settings'))->custom_username_length_max) {
|
||||
return $this->showAlert('error', __('Username length cannot be less than') . ' ' . json_decode(config('app.settings.configuration_settings'))->custom_username_length_min . ' ' . __('and greater than') . ' ' . json_decode(config('app.settings.configuration_settings'))->custom_username_length_max);
|
||||
return $this->showAlert('error', __('Username length cannot be less than').' '.json_decode(config('app.settings.configuration_settings'))->custom_username_length_min.' '.__('and greater than').' '.json_decode(config('app.settings.configuration_settings'))->custom_username_length_max);
|
||||
}
|
||||
if (!$this->domain) {
|
||||
if (! $this->domain) {
|
||||
return $this->showAlert('error', __('Please Select a Domain'));
|
||||
}
|
||||
if (in_array($this->username, json_decode(config('app.settings.configuration_settings'))->forbidden_ids)) {
|
||||
return $this->showAlert('error', __('Username not allowed'));
|
||||
}
|
||||
if (!$this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of MAX ') . $this->email_limit . __(' temp mail'));
|
||||
if (! $this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of MAX ').$this->email_limit.__(' temp mail'));
|
||||
}
|
||||
if (!$this->checkUsedEmail()) {
|
||||
if (! $this->checkUsedEmail()) {
|
||||
return $this->showAlert('error', __('Sorry! That email is already been used by someone else. Please try a different email address.'));
|
||||
}
|
||||
if ($this->premium) {
|
||||
@@ -175,42 +194,51 @@ class Inbox extends Component
|
||||
} else {
|
||||
$this->email = ZEmail::createCustomEmail($this->username, $this->domain);
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
|
||||
}
|
||||
public function random() {
|
||||
|
||||
if (!$this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ') . $this->email_limit . __(' temp mail addresses.'));
|
||||
public function random()
|
||||
{
|
||||
|
||||
if (! $this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').$this->email_limit.__(' temp mail addresses.'));
|
||||
}
|
||||
if ($this->premium) {
|
||||
$this->email = Premium::generateRandomEmail();
|
||||
} else {
|
||||
$this->email = ZEmail::generateRandomEmail();
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
}
|
||||
public function gmail() {
|
||||
if (!$this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ') . $this->email_limit . __(' temp mail addresses.'));
|
||||
|
||||
public function gmail()
|
||||
{
|
||||
if (! $this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').$this->email_limit.__(' temp mail addresses.'));
|
||||
}
|
||||
if ($this->premium) {
|
||||
$this->email = Premium::generateRandomGmail();
|
||||
} else {
|
||||
$this->email = ZEmail::generateRandomGmail();
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
}
|
||||
|
||||
public function outlook() {
|
||||
if (!$this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ') . $this->email_limit . __(' temp mail addresses.'));
|
||||
public function outlook()
|
||||
{
|
||||
if (! $this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').$this->email_limit.__(' temp mail addresses.'));
|
||||
}
|
||||
if ($this->premium) {
|
||||
$this->email = Premium::generateRandomOutlook();
|
||||
} else {
|
||||
$this->email = ZEmail::generateRandomOutlook();
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
}
|
||||
|
||||
@@ -230,18 +258,21 @@ class Inbox extends Component
|
||||
if (count($logs) >= $this->email_limit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function checkUsedEmail(): bool
|
||||
{
|
||||
if (json_decode(config('app.settings.configuration_settings'))->disable_used_email) {
|
||||
$check = Log::where('email', $this->user . '@' . $this->domain)->where('ip', '<>', request()->ip())->count();
|
||||
$check = Log::where('email', $this->user.'@'.$this->domain)->where('ip', '<>', request()->ip())->count();
|
||||
if ($check > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -268,7 +299,7 @@ class Inbox extends Component
|
||||
} else {
|
||||
$domains = json_decode(config('app.settings.configuration_settings'))->domains ?? [];
|
||||
}
|
||||
if (!in_array($domain, $domains)) {
|
||||
if (! in_array($domain, $domains)) {
|
||||
$key = array_search($this->email, $this->emails);
|
||||
if ($this->premium) {
|
||||
Premium::removeEmail($this->email);
|
||||
@@ -290,7 +321,6 @@ class Inbox extends Component
|
||||
|
||||
/* Mailbox */
|
||||
|
||||
|
||||
public function fetch(): void
|
||||
{
|
||||
try {
|
||||
@@ -300,33 +330,33 @@ class Inbox extends Component
|
||||
}
|
||||
$responses = [];
|
||||
if ($this->premium) {
|
||||
if (config('app.beta_feature') || !json_decode(config('app.settings.imap_settings'))->premium_cc_check) {
|
||||
if (config('app.beta_feature') || ! json_decode(config('app.settings.imap_settings'))->premium_cc_check) {
|
||||
$responses = [
|
||||
'to' => Premium::getMessages($this->email, 'to', $this->deleted),
|
||||
'cc' => [
|
||||
'data' => [],
|
||||
'notifications' => []
|
||||
]
|
||||
'notifications' => [],
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$responses = [
|
||||
'to' => Premium::getMessages($this->email, 'to', $this->deleted),
|
||||
'cc' => Premium::getMessages($this->email, 'cc', $this->deleted)
|
||||
'cc' => Premium::getMessages($this->email, 'cc', $this->deleted),
|
||||
];
|
||||
}
|
||||
} else {
|
||||
if (config('app.beta_feature') || !json_decode(config('app.settings.imap_settings'))->cc_check) {
|
||||
if (config('app.beta_feature') || ! json_decode(config('app.settings.imap_settings'))->cc_check) {
|
||||
$responses = [
|
||||
'to' => ZEmail::getMessages($this->email, 'to', $this->deleted),
|
||||
'cc' => [
|
||||
'data' => [],
|
||||
'notifications' => []
|
||||
]
|
||||
'notifications' => [],
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$responses = [
|
||||
'to' => ZEmail::getMessages($this->email, 'to', $this->deleted),
|
||||
'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted)
|
||||
'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -336,7 +366,7 @@ class Inbox extends Component
|
||||
$notifications = array_merge($responses['to']['notifications'], $responses['cc']['notifications']);
|
||||
|
||||
if (count($notifications)) {
|
||||
if (!$this->overflow && count($this->messages) == $count) {
|
||||
if (! $this->overflow && count($this->messages) == $count) {
|
||||
$this->overflow = true;
|
||||
}
|
||||
} else {
|
||||
@@ -367,16 +397,17 @@ class Inbox extends Component
|
||||
$this->initial = true;
|
||||
}
|
||||
|
||||
public function delete($messageId) {
|
||||
public function delete($messageId)
|
||||
{
|
||||
|
||||
try {
|
||||
$this->deleted[] = $messageId;
|
||||
foreach ($this->messages as $key => $message) {
|
||||
if ($message['id'] == $messageId) {
|
||||
if ($this->premium) {
|
||||
$directory = public_path('tmp/premium/attachments/') . $messageId;
|
||||
$directory = public_path('tmp/premium/attachments/').$messageId;
|
||||
} else {
|
||||
$directory = public_path('tmp/attachments/') . $messageId;
|
||||
$directory = public_path('tmp/attachments/').$messageId;
|
||||
}
|
||||
$this->rrmdir($directory);
|
||||
unset($this->messages[$key]);
|
||||
@@ -384,7 +415,7 @@ class Inbox extends Component
|
||||
}
|
||||
|
||||
} catch (
|
||||
Exception $exception
|
||||
Exception $exception
|
||||
) {
|
||||
\Illuminate\Support\Facades\Log::error($exception->getMessage());
|
||||
}
|
||||
@@ -393,7 +424,7 @@ class Inbox extends Component
|
||||
|
||||
public function toggleMode()
|
||||
{
|
||||
$this->premium = !$this->premium;
|
||||
$this->premium = ! $this->premium;
|
||||
Session::put('isInboxTypePremium', $this->premium);
|
||||
if ($this->premium) {
|
||||
$this->domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
@@ -432,11 +463,12 @@ class Inbox extends Component
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != "." && $object != "..") {
|
||||
if (is_dir($dir . DIRECTORY_SEPARATOR . $object) && !is_link($dir . "/" . $object))
|
||||
$this->rrmdir($dir . DIRECTORY_SEPARATOR . $object);
|
||||
else
|
||||
unlink($dir . DIRECTORY_SEPARATOR . $object);
|
||||
if ($object != '.' && $object != '..') {
|
||||
if (is_dir($dir.DIRECTORY_SEPARATOR.$object) && ! is_link($dir.'/'.$object)) {
|
||||
$this->rrmdir($dir.DIRECTORY_SEPARATOR.$object);
|
||||
} else {
|
||||
unlink($dir.DIRECTORY_SEPARATOR.$object);
|
||||
}
|
||||
}
|
||||
}
|
||||
rmdir($dir);
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
|
||||
namespace App\Livewire\Dashboard;
|
||||
|
||||
use Exception;
|
||||
use Log;
|
||||
use App\Models\ActivationKey;
|
||||
use App\Models\Plan;
|
||||
use Exception;
|
||||
use Livewire\Component;
|
||||
use Log;
|
||||
|
||||
class Pricing extends Component
|
||||
{
|
||||
public $plans;
|
||||
|
||||
public $activation_key;
|
||||
|
||||
public function mount(): void
|
||||
@@ -66,12 +67,12 @@ class Pricing extends Component
|
||||
$user->updateStripeCustomer([
|
||||
'address' => [
|
||||
'postal_code' => '10001',
|
||||
'country' => 'US',
|
||||
'country' => 'US',
|
||||
],
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
]);
|
||||
$user->creditBalance($plan->price * 100, 'Premium Top-up for plan: ' . $plan->name);
|
||||
$user->creditBalance($plan->price * 100, 'Premium Top-up for plan: '.$plan->name);
|
||||
$balance = $user->balance();
|
||||
$user->newSubscription('default', $plan->pricing_id)->create();
|
||||
|
||||
@@ -81,12 +82,15 @@ class Pricing extends Component
|
||||
$ends_at = now()->addYear();
|
||||
}
|
||||
$user->subscription('default')->cancelAt($ends_at);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.dashboard.pricing');
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Livewire\Dashboard;
|
||||
|
||||
use Exception;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketResponse;
|
||||
use Exception;
|
||||
use Livewire\Component;
|
||||
use Request;
|
||||
use Str;
|
||||
@@ -12,11 +12,17 @@ use Str;
|
||||
class Support extends Component
|
||||
{
|
||||
public $tickets = [];
|
||||
|
||||
public $subject;
|
||||
|
||||
public $message;
|
||||
|
||||
public $response;
|
||||
|
||||
public $list = false;
|
||||
|
||||
public $open = 0;
|
||||
|
||||
public $closed = 0;
|
||||
|
||||
public function store()
|
||||
@@ -37,15 +43,14 @@ class Support extends Component
|
||||
]);
|
||||
$this->dispatch('showAlert', ['type' => 'success', 'message' => 'Your ticket has been created successfully!']);
|
||||
$this->dispatch('closeModal');
|
||||
$this->reset(['subject','message']);
|
||||
$this->reset(['subject', 'message']);
|
||||
$this->tickets = Ticket::with('responses')
|
||||
->where('user_id', auth()->id())
|
||||
->get();
|
||||
->where('user_id', auth()->id())
|
||||
->get();
|
||||
} catch (Exception $exception) {
|
||||
$this->dispatch('showAlert', ['type' => 'error', 'message' => 'Something went wrong!']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function reply($ticket_id)
|
||||
@@ -56,14 +61,16 @@ class Support extends Component
|
||||
|
||||
try {
|
||||
|
||||
if (!is_numeric($ticket_id)) {
|
||||
if (! is_numeric($ticket_id)) {
|
||||
$this->dispatch('showAlert', ['type' => 'error', 'message' => 'Invalid ticket ID.']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$ticket = Ticket::find($ticket_id);
|
||||
if (!$ticket) {
|
||||
if (! $ticket) {
|
||||
$this->dispatch('showAlert', ['type' => 'error', 'message' => 'Ticket not found.']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -91,13 +98,15 @@ class Support extends Component
|
||||
|
||||
public function close($ticket_id)
|
||||
{
|
||||
if (!is_numeric($ticket_id)) {
|
||||
if (! is_numeric($ticket_id)) {
|
||||
$this->dispatch('showAlert', ['type' => 'error', 'message' => 'Invalid ticket ID.']);
|
||||
|
||||
return;
|
||||
}
|
||||
$ticket = Ticket::find($ticket_id);
|
||||
if (!$ticket) {
|
||||
if (! $ticket) {
|
||||
$this->dispatch('showAlert', ['type' => 'error', 'message' => 'Ticket not found.']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -113,8 +122,8 @@ class Support extends Component
|
||||
public function mount()
|
||||
{
|
||||
$this->tickets = Ticket::with('responses')
|
||||
->where('user_id', auth()->id())
|
||||
->get();
|
||||
->where('user_id', auth()->id())
|
||||
->get();
|
||||
$this->updateTicketCounts();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user