chore: code refactor via rector
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Livewire\Actions;
|
||||
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
@@ -10,7 +12,7 @@ class Logout
|
||||
/**
|
||||
* Log the current user out of the application.
|
||||
*/
|
||||
public function __invoke()
|
||||
public function __invoke(): Redirector|RedirectResponse
|
||||
{
|
||||
Auth::guard('web')->logout();
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use App\Models\ZEmail;
|
||||
use Livewire\Component;
|
||||
use Session;
|
||||
|
||||
class AddOn extends Component
|
||||
{
|
||||
@@ -27,11 +29,12 @@ class AddOn extends Component
|
||||
$email = ZEmail::getEmail();
|
||||
$messages = ZEmail::getMessages($email);
|
||||
if (count($messages['data']) > 0) {
|
||||
return redirect()->route('mailbox');
|
||||
return to_route('mailbox');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function mount()
|
||||
public function mount(): void
|
||||
{
|
||||
$this->faqs = json_decode(file_get_contents(public_path('addOnFAQs.json')), true) ?? [];
|
||||
$route = request()->route()->getName();
|
||||
@@ -45,16 +48,14 @@ class AddOn extends Component
|
||||
$this->faqSchema = [
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'FAQPage',
|
||||
'mainEntity' => collect($this->faqs)->map(function ($faq) {
|
||||
return [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
];
|
||||
})->toArray(),
|
||||
'mainEntity' => collect($this->faqs)->map(fn(array $faq): array => [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
])->all(),
|
||||
];
|
||||
} elseif ($route == 'disposable-gmail') {
|
||||
$this->title = 'Disposable Gmail Email | Free Temporary Gmail Inbox Online';
|
||||
@@ -65,16 +66,14 @@ class AddOn extends Component
|
||||
$this->faqSchema = [
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'FAQPage',
|
||||
'mainEntity' => collect($this->faqs)->map(function ($faq) {
|
||||
return [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
];
|
||||
})->toArray(),
|
||||
'mainEntity' => collect($this->faqs)->map(fn(array $faq): array => [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
])->all(),
|
||||
];
|
||||
|
||||
} elseif ($route == 'disposable-outlook') {
|
||||
@@ -86,16 +85,14 @@ class AddOn extends Component
|
||||
$this->faqSchema = [
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'FAQPage',
|
||||
'mainEntity' => collect($this->faqs)->map(function ($faq) {
|
||||
return [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
];
|
||||
})->toArray(),
|
||||
'mainEntity' => collect($this->faqs)->map(fn(array $faq): array => [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
])->all(),
|
||||
];
|
||||
} elseif ($route == 'disposable-yahoo') {
|
||||
$this->title = 'Disposable Yahoo Mail | Free Temporary Yahoo Inbox';
|
||||
@@ -106,16 +103,14 @@ class AddOn extends Component
|
||||
$this->faqSchema = [
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'FAQPage',
|
||||
'mainEntity' => collect($this->faqs)->map(function ($faq) {
|
||||
return [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
];
|
||||
})->toArray(),
|
||||
'mainEntity' => collect($this->faqs)->map(fn(array $faq): array => [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
])->all(),
|
||||
];
|
||||
} elseif ($route == 'gmailnator') {
|
||||
$this->title = 'Gmailnator - Free Temporary Gmail Email Address Generator';
|
||||
@@ -126,16 +121,14 @@ class AddOn extends Component
|
||||
$this->faqSchema = [
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'FAQPage',
|
||||
'mainEntity' => collect($this->faqs)->map(function ($faq) {
|
||||
return [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
];
|
||||
})->toArray(),
|
||||
'mainEntity' => collect($this->faqs)->map(fn(array $faq): array => [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
])->all(),
|
||||
];
|
||||
} elseif ($route == 'emailnator') {
|
||||
$this->title = 'Emailnator - Free Disposable Temporary Email Service';
|
||||
@@ -146,16 +139,14 @@ class AddOn extends Component
|
||||
$this->faqSchema = [
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'FAQPage',
|
||||
'mainEntity' => collect($this->faqs)->map(function ($faq) {
|
||||
return [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
];
|
||||
})->toArray(),
|
||||
'mainEntity' => collect($this->faqs)->map(fn(array $faq): array => [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
])->all(),
|
||||
];
|
||||
} elseif ($route == 'temp-gmail') {
|
||||
$this->title = 'Temp Gmail | Free Temporary Gmail Inbox for Instant Use';
|
||||
@@ -166,22 +157,20 @@ class AddOn extends Component
|
||||
$this->faqSchema = [
|
||||
'@context' => 'https://schema.org',
|
||||
'@type' => 'FAQPage',
|
||||
'mainEntity' => collect($this->faqs)->map(function ($faq) {
|
||||
return [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
];
|
||||
})->toArray(),
|
||||
'mainEntity' => collect($this->faqs)->map(fn(array $faq): array => [
|
||||
'@type' => 'Question',
|
||||
'name' => $faq['title'],
|
||||
'acceptedAnswer' => [
|
||||
'@type' => 'Answer',
|
||||
'text' => $faq['content'],
|
||||
],
|
||||
])->all(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function render()
|
||||
public function render(): Factory|View
|
||||
{
|
||||
return view('livewire.add-on');
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Register extends Component
|
||||
|
||||
$validated['password'] = Hash::make($validated['password']);
|
||||
|
||||
event(new Registered(($user = User::create($validated))));
|
||||
event(new Registered(($user = User::query()->create($validated))));
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class ResetPassword extends Component
|
||||
// database. Otherwise we will parse the error and return the response.
|
||||
$status = Password::reset(
|
||||
$this->only('email', 'password', 'password_confirmation', 'token'),
|
||||
function ($user) {
|
||||
function ($user): void {
|
||||
$user->forceFill([
|
||||
'password' => Hash::make($this->password),
|
||||
'remember_token' => Str::random(60),
|
||||
|
||||
@@ -11,10 +11,10 @@ class Blog extends Component
|
||||
|
||||
public $category;
|
||||
|
||||
public function mount($slug)
|
||||
public function mount($slug): void
|
||||
{
|
||||
$this->postDetail = \App\Models\Blog::where('slug', $slug)->firstOrFail();
|
||||
$this->category = Category::where('id', $this->postDetail->category_id)->first();
|
||||
$this->postDetail = \App\Models\Blog::query()->where('slug', $slug)->firstOrFail();
|
||||
$this->category = Category::query()->where('id', $this->postDetail->category_id)->first();
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Livewire\Dashboard;
|
||||
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Livewire\Component;
|
||||
use Session;
|
||||
|
||||
class Bulk extends Component
|
||||
{
|
||||
@@ -11,15 +11,13 @@ class Bulk extends Component
|
||||
|
||||
public $bulkCount = 1;
|
||||
|
||||
private $isSubscribed = false;
|
||||
|
||||
public function mount()
|
||||
public function mount(): void
|
||||
{
|
||||
$subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']);
|
||||
Session::put('isSubscribed', $subscriptionCheck);
|
||||
}
|
||||
|
||||
public function generateBulk()
|
||||
public function generateBulk(): void
|
||||
{
|
||||
$this->validate([
|
||||
'bulkCount' => 'required|integer|min:1|max:500',
|
||||
@@ -44,7 +42,7 @@ class Bulk extends Component
|
||||
$filename = 'bulk_emails_'.now()->format('Ymd_His').'.txt';
|
||||
$content = implode(PHP_EOL, $this->bulkEmails);
|
||||
|
||||
return response()->streamDownload(function () use ($content) {
|
||||
return response()->streamDownload(function () use ($content): void {
|
||||
echo $content;
|
||||
}, $filename);
|
||||
}
|
||||
@@ -54,11 +52,11 @@ class Bulk extends Component
|
||||
$domain = $this->getRandomDomain();
|
||||
if ($domain == 'gmail.com' || $domain == 'googlemail.com') {
|
||||
$uname = $this->getRandomGmailUser();
|
||||
$uname_len = strlen($uname);
|
||||
$uname_len = strlen((string) $uname);
|
||||
$len_power = $uname_len - 1;
|
||||
$combination = pow(2, $len_power);
|
||||
$combination = 2 ** $len_power;
|
||||
$rand_comb = mt_rand(1, $combination);
|
||||
$formatted = implode(' ', str_split($uname));
|
||||
$formatted = implode(' ', str_split((string) $uname));
|
||||
$uname_exp = explode(' ', $formatted);
|
||||
|
||||
$bin = intval('');
|
||||
@@ -70,7 +68,7 @@ class Bulk extends Component
|
||||
$email = '';
|
||||
for ($i = 0; $i < $len_power; $i++) {
|
||||
$email .= $uname_exp[$i];
|
||||
if ($bin[$i]) {
|
||||
if ($bin[$i] !== '' && $bin[$i] !== '0') {
|
||||
$email .= '.';
|
||||
}
|
||||
}
|
||||
@@ -83,15 +81,14 @@ class Bulk extends Component
|
||||
}
|
||||
|
||||
return $email;
|
||||
} else {
|
||||
return $this->generateRandomUsername().'@'.$domain;
|
||||
}
|
||||
return $this->generateRandomUsername().'@'.$domain;
|
||||
}
|
||||
|
||||
private function generateRandomUsername(): string
|
||||
{
|
||||
$start = json_decode(config('app.settings.configuration_settings'))->random_username_length_min ?? 0;
|
||||
$end = json_decode(config('app.settings.configuration_settings'))->random_username_length_max ?? 0;
|
||||
$start = json_decode((string) config('app.settings.configuration_settings'))->random_username_length_min ?? 0;
|
||||
$end = json_decode((string) config('app.settings.configuration_settings'))->random_username_length_max ?? 0;
|
||||
if ($start == 0 && $end == 0) {
|
||||
return $this->generatePronounceableWord();
|
||||
}
|
||||
@@ -101,25 +98,25 @@ class Bulk extends Component
|
||||
|
||||
private function generatedRandomBetweenLength($start, $end): string
|
||||
{
|
||||
$length = rand($start, $end);
|
||||
$length = random_int($start, $end);
|
||||
|
||||
return $this->generateRandomString($length);
|
||||
}
|
||||
|
||||
private function getRandomDomain()
|
||||
{
|
||||
$domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
$domains = json_decode((string) config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
$count = count($domains);
|
||||
|
||||
return $count > 0 ? $domains[rand(1, $count) - 1] : '';
|
||||
return $count > 0 ? $domains[random_int(1, $count) - 1] : '';
|
||||
}
|
||||
|
||||
private function getRandomGmailUser()
|
||||
{
|
||||
$gmailusername = json_decode(config('app.settings.configuration_settings'))->premium_gmailUsernames ?? [];
|
||||
$gmailusername = json_decode((string) config('app.settings.configuration_settings'))->premium_gmailUsernames ?? [];
|
||||
$count = count($gmailusername);
|
||||
|
||||
return $count > 0 ? $gmailusername[rand(1, $count) - 1] : '';
|
||||
return $count > 0 ? $gmailusername[random_int(1, $count) - 1] : '';
|
||||
}
|
||||
|
||||
private function generatePronounceableWord(): string
|
||||
@@ -129,21 +126,21 @@ class Bulk extends Component
|
||||
$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)];
|
||||
$random .= $c[random_int(0, strlen($c) - 1)];
|
||||
$random .= $v[random_int(0, strlen($v) - 1)];
|
||||
$random .= $a[random_int(0, strlen($a) - 1)];
|
||||
}
|
||||
|
||||
return $random;
|
||||
}
|
||||
|
||||
private function generateRandomString($length = 10): string
|
||||
private function generateRandomString(int $length = 10): string
|
||||
{
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
$randomString .= $characters[random_int(0, $charactersLength - 1)];
|
||||
}
|
||||
|
||||
return $randomString;
|
||||
@@ -153,8 +150,7 @@ class Bulk extends Component
|
||||
{
|
||||
if (Session::get('isSubscribed')) {
|
||||
return view('livewire.dashboard.bulk')->layout('components.layouts.dashboard');
|
||||
} else {
|
||||
return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard');
|
||||
}
|
||||
return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Livewire\Dashboard;
|
||||
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Livewire\Component;
|
||||
use Session;
|
||||
|
||||
class BulkGmail extends Component
|
||||
{
|
||||
@@ -13,7 +13,7 @@ class BulkGmail extends Component
|
||||
|
||||
public $bulkEmails = [];
|
||||
|
||||
public function mount()
|
||||
public function mount(): void
|
||||
{
|
||||
$subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']);
|
||||
Session::put('isSubscribed', $subscriptionCheck);
|
||||
@@ -34,7 +34,7 @@ class BulkGmail extends Component
|
||||
$this->bulkEmails = [];
|
||||
}
|
||||
|
||||
$this->bulkEmails = $this->generateDotVariants(explode('@', $this->email)[0], $this->quantity);
|
||||
$this->bulkEmails = $this->generateDotVariants(explode('@', (string) $this->email)[0], $this->quantity);
|
||||
}
|
||||
|
||||
public function downloadBulk()
|
||||
@@ -47,12 +47,15 @@ class BulkGmail extends Component
|
||||
$filename = 'bulk_gmails_'.now()->format('Ymd_His').'.txt';
|
||||
$content = implode(PHP_EOL, $this->bulkEmails);
|
||||
|
||||
return response()->streamDownload(function () use ($content) {
|
||||
return response()->streamDownload(function () use ($content): void {
|
||||
echo $content;
|
||||
}, $filename);
|
||||
}
|
||||
|
||||
private function generateDotVariants($uname, $quantity)
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function generateDotVariants(string $uname, int $quantity): array
|
||||
{
|
||||
$length = strlen($uname);
|
||||
$positions = range(1, $length - 1);
|
||||
@@ -89,7 +92,7 @@ class BulkGmail extends Component
|
||||
return [[]];
|
||||
}
|
||||
|
||||
if (empty($items)) {
|
||||
if ($items === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -102,19 +105,14 @@ class BulkGmail extends Component
|
||||
$combinations[] = $c;
|
||||
}
|
||||
|
||||
foreach ($this->combinations($tail, $size) as $c) {
|
||||
$combinations[] = $c;
|
||||
}
|
||||
|
||||
return $combinations;
|
||||
return $this->combinations($tail, $size);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (Session::get('isSubscribed')) {
|
||||
return view('livewire.dashboard.bulk-gmail')->layout('components.layouts.dashboard');
|
||||
} else {
|
||||
return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard');
|
||||
}
|
||||
return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Livewire\Dashboard;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Models\UsageLog;
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Livewire\Component;
|
||||
use Log;
|
||||
use Stripe\StripeClient;
|
||||
|
||||
class Dashboard extends Component
|
||||
@@ -27,13 +27,13 @@ class Dashboard extends Component
|
||||
public function paymentStatus(Request $request)
|
||||
{
|
||||
$status = $request->route('status');
|
||||
$currentUrl = $request->fullUrl();
|
||||
$request->fullUrl();
|
||||
if ($status == 'success') {
|
||||
$this->syncSubscription();
|
||||
|
||||
return redirect()->route('dashboard')->with('status', 'success');
|
||||
} elseif ($status == 'cancel') {
|
||||
return redirect()->route('dashboard')->with('status', 'cancel');
|
||||
return to_route('dashboard')->with('status', 'success');
|
||||
}
|
||||
if ($status == 'cancel') {
|
||||
return to_route('dashboard')->with('status', 'cancel');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,17 +63,15 @@ class Dashboard extends Component
|
||||
$canceled_at = $subscriptionData->canceled_at;
|
||||
$status = $subscriptionData->status;
|
||||
if ($cancel_at_period_end) {
|
||||
$final_ends_at = Carbon::createFromTimestamp($cancel_at)->toDateTimeString();
|
||||
$final_ends_at = Date::createFromTimestamp($cancel_at)->toDateTimeString();
|
||||
} elseif ($cancel_at === null && $canceled_at !== null && $status === 'canceled' && $cancel_at_period_end === false) {
|
||||
// $final_ends_at = Carbon::createFromTimestamp($canceled_at)->toDateTimeString();
|
||||
$final_ends_at = Date::now()->subDays(2)->toDateTimeString();
|
||||
$redirect = true;
|
||||
} elseif ($status === 'active' && $cancel_at !== null) {
|
||||
$final_ends_at = Date::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();
|
||||
$final_ends_at = Carbon::now()->subDays(2)->toDateTimeString();
|
||||
$redirect = true;
|
||||
} elseif ($status === 'active' && $cancel_at !== null) {
|
||||
$final_ends_at = Carbon::createFromTimestamp($cancel_at)->toDateTimeString();
|
||||
} else {
|
||||
$final_ends_at = null;
|
||||
}
|
||||
$final_ends_at = null;
|
||||
}
|
||||
|
||||
DB::table('subscriptions')
|
||||
@@ -81,7 +79,7 @@ class Dashboard extends Component
|
||||
->update([
|
||||
'stripe_status' => $status,
|
||||
'ends_at' => $final_ends_at,
|
||||
'updated_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => Date::now()->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -117,11 +115,7 @@ class Dashboard extends Component
|
||||
$stripe_product = $items->price->product;
|
||||
$ends_at = $items->current_period_end;
|
||||
$subscriptionItemId = $items->id;
|
||||
if ($cancel_at_period_end) {
|
||||
$final_ends_at = Carbon::createFromTimestamp($ends_at)->toDateTimeString();
|
||||
} else {
|
||||
$final_ends_at = null;
|
||||
}
|
||||
$final_ends_at = $cancel_at_period_end ? Date::createFromTimestamp($ends_at)->toDateTimeString() : null;
|
||||
|
||||
try {
|
||||
if ($status === 'active') {
|
||||
@@ -135,8 +129,8 @@ class Dashboard extends Component
|
||||
'stripe_price' => $stripe_price,
|
||||
'quantity' => $quantity,
|
||||
'ends_at' => $final_ends_at,
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => Carbon::now()->toDateTimeString(),
|
||||
'created_at' => Date::now()->toDateTimeString(),
|
||||
'updated_at' => Date::now()->toDateTimeString(),
|
||||
]);
|
||||
|
||||
$subscriptionsTable = DB::table('subscriptions')->where(['stripe_id' => $subscriptionId])->first();
|
||||
@@ -149,8 +143,8 @@ class Dashboard extends Component
|
||||
'stripe_product' => $stripe_product,
|
||||
'stripe_price' => $stripe_price,
|
||||
'quantity' => $quantity,
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => Carbon::now()->toDateTimeString(),
|
||||
'created_at' => Date::now()->toDateTimeString(),
|
||||
'updated_at' => Date::now()->toDateTimeString(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -165,7 +159,7 @@ class Dashboard extends Component
|
||||
public function mount(Request $request)
|
||||
{
|
||||
if ($this->checkForSubscriptionStatus()) {
|
||||
return redirect()->route('dashboard');
|
||||
return to_route('dashboard');
|
||||
}
|
||||
try {
|
||||
$status = $request->session()->get('status');
|
||||
@@ -177,7 +171,7 @@ class Dashboard extends Component
|
||||
}
|
||||
$request->session()->forget('status');
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
} catch (Exception) {
|
||||
|
||||
}
|
||||
|
||||
@@ -207,7 +201,7 @@ class Dashboard extends Component
|
||||
}
|
||||
}
|
||||
|
||||
$usageLog = UsageLog::where('user_id', auth()->user()->id)->first();
|
||||
$usageLog = UsageLog::query()->where('user_id', auth()->user()->id)->first();
|
||||
$this->usageLog = [
|
||||
'emails_created_count' => $usageLog->emails_created_count ?? 0,
|
||||
'emails_received_count' => $usageLog->emails_received_count ?? 0,
|
||||
|
||||
@@ -2,17 +2,19 @@
|
||||
|
||||
namespace App\Livewire\Dashboard\Mailbox;
|
||||
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use App\ColorPicker;
|
||||
use App\Models\Log;
|
||||
use App\Models\Premium;
|
||||
use App\Models\PremiumEmail;
|
||||
use App\Models\UsageLog;
|
||||
use App\Models\ZEmail;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
use Session;
|
||||
|
||||
class Inbox extends Component
|
||||
{
|
||||
@@ -63,14 +65,14 @@ class Inbox extends Component
|
||||
$this->premium = Session::get('isInboxTypePremium', true);
|
||||
|
||||
if ($this->premium) {
|
||||
$this->domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
$this->domains = json_decode((string) config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
$this->email = Premium::getEmail();
|
||||
$this->emails = Premium::getEmails();
|
||||
$this->initial = false;
|
||||
$this->checkMultipleEmails();
|
||||
$this->validateDomainInEmail();
|
||||
} else {
|
||||
$this->domains = json_decode(config('app.settings.configuration_settings'))->domains ?? [];
|
||||
$this->domains = json_decode((string) config('app.settings.configuration_settings'))->domains ?? [];
|
||||
$this->email = ZEmail::getEmail();
|
||||
$this->emails = ZEmail::getEmails();
|
||||
$this->initial = false;
|
||||
@@ -97,12 +99,12 @@ class Inbox extends Component
|
||||
$this->email_limit = $mailboxLimit;
|
||||
|
||||
} catch (Exception $e) {
|
||||
\Log::error($e->getMessage());
|
||||
\Illuminate\Support\Facades\Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->premium) {
|
||||
$mailboxHistory = UsageLog::where(['user_id' => auth()->user()->id])->first();
|
||||
$mailboxHistory = UsageLog::query()->where(['user_id' => auth()->user()->id])->first();
|
||||
$this->mailboxHistory = $mailboxHistory->emails_created_history ?? [];
|
||||
} else {
|
||||
$this->mailboxHistory = ZEmail::getEmails() ?? [];
|
||||
@@ -112,27 +114,23 @@ class Inbox extends Component
|
||||
|
||||
private function checkMultipleEmails(): void
|
||||
{
|
||||
if (count($this->emails) == 0) {
|
||||
if (count($this->emails) === 0) {
|
||||
$this->emails = [$this->email];
|
||||
}
|
||||
if (count($this->emails) > 1) {
|
||||
$this->list = true;
|
||||
} else {
|
||||
$this->list = false;
|
||||
}
|
||||
$this->list = count($this->emails) > 1;
|
||||
}
|
||||
|
||||
public function switchEmail($email)
|
||||
{
|
||||
try {
|
||||
if ($email != null) {
|
||||
$data = explode('@', $email);
|
||||
$data = explode('@', (string) $email);
|
||||
if (isset($data[1])) {
|
||||
$domain = $data[1];
|
||||
if ($this->premium) {
|
||||
$domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
$domains = json_decode((string) config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
} else {
|
||||
$domains = json_decode(config('app.settings.configuration_settings'))->domains ?? [];
|
||||
$domains = json_decode((string) config('app.settings.configuration_settings'))->domains ?? [];
|
||||
}
|
||||
if (! in_array($domain, $domains)) {
|
||||
return $this->showAlert('error', __('This mailbox can not be recovered.'));
|
||||
@@ -140,17 +138,17 @@ class Inbox extends Component
|
||||
}
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
\Log::error($exception->getMessage());
|
||||
\Illuminate\Support\Facades\Log::error($exception->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->route('switchP', ['email' => $email]);
|
||||
return to_route('switchP', ['email' => $email]);
|
||||
}
|
||||
|
||||
public function syncEmail(): void
|
||||
{
|
||||
$this->email = Premium::getEmail();
|
||||
$this->emails = Premium::getEmails();
|
||||
if (count($this->emails) == 0) {
|
||||
if (count($this->emails) === 0) {
|
||||
$this->dispatch('getEmail');
|
||||
}
|
||||
$this->checkMultipleEmails();
|
||||
@@ -174,13 +172,13 @@ class Inbox extends Component
|
||||
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);
|
||||
if (strlen((string) $this->username) < json_decode((string) config('app.settings.configuration_settings'))->custom_username_length_min || strlen((string) $this->username) > json_decode((string) config('app.settings.configuration_settings'))->custom_username_length_max) {
|
||||
return $this->showAlert('error', __('Username length cannot be less than').' '.json_decode((string) config('app.settings.configuration_settings'))->custom_username_length_min.' '.__('and greater than').' '.json_decode((string) config('app.settings.configuration_settings'))->custom_username_length_max);
|
||||
}
|
||||
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)) {
|
||||
if (in_array($this->username, json_decode((string) config('app.settings.configuration_settings'))->forbidden_ids)) {
|
||||
return $this->showAlert('error', __('Username not allowed'));
|
||||
}
|
||||
if (! $this->checkEmailLimit()) {
|
||||
@@ -195,7 +193,7 @@ class Inbox extends Component
|
||||
$this->email = ZEmail::createCustomEmail($this->username, $this->domain);
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
return to_route('dashboard.premium');
|
||||
|
||||
}
|
||||
|
||||
@@ -205,13 +203,9 @@ class Inbox extends Component
|
||||
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();
|
||||
}
|
||||
$this->email = $this->premium ? Premium::generateRandomEmail() : ZEmail::generateRandomEmail();
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
return to_route('dashboard.premium');
|
||||
}
|
||||
|
||||
public function gmail()
|
||||
@@ -219,13 +213,9 @@ class Inbox extends Component
|
||||
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();
|
||||
}
|
||||
$this->email = $this->premium ? Premium::generateRandomGmail() : ZEmail::generateRandomGmail();
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
return to_route('dashboard.premium');
|
||||
}
|
||||
|
||||
public function outlook()
|
||||
@@ -239,38 +229,30 @@ class Inbox extends Component
|
||||
$this->email = ZEmail::generateRandomOutlook();
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
return to_route('dashboard.premium');
|
||||
}
|
||||
|
||||
public function deleteEmail()
|
||||
public function deleteEmail(): Redirector|RedirectResponse
|
||||
{
|
||||
return redirect()->route('deleteP', ['email' => $this->email]);
|
||||
return to_route('deleteP', ['email' => $this->email]);
|
||||
}
|
||||
|
||||
private function showAlert($type, $message): void
|
||||
private function showAlert(string $type, $message): void
|
||||
{
|
||||
$this->dispatch('showAlert', ['type' => $type, 'message' => $message]);
|
||||
}
|
||||
|
||||
private function checkEmailLimit(): bool
|
||||
{
|
||||
$logs = Log::select('ip', 'email')->where('user_id', auth()->user()->id)->where('created_at', '>', Carbon::now()->subDay())->groupBy('email')->groupBy('ip')->get();
|
||||
if (count($logs) >= $this->email_limit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
$logs = Log::query()->select('ip', 'email')->where('user_id', auth()->user()->id)->where('created_at', '>', Date::now()->subDay())->groupBy('email')->groupBy('ip')->get();
|
||||
return count($logs) < $this->email_limit;
|
||||
}
|
||||
|
||||
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();
|
||||
if ($check > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
if (json_decode((string) config('app.settings.configuration_settings'))->disable_used_email) {
|
||||
$check = Log::query()->where('email', $this->user.'@'.$this->domain)->where('ip', '<>', request()->ip())->count();
|
||||
return $check <= 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -278,7 +260,7 @@ class Inbox extends Component
|
||||
|
||||
private function checkDomainInUsername(): void
|
||||
{
|
||||
$parts = explode('@', $this->username);
|
||||
$parts = explode('@', (string) $this->username);
|
||||
if (isset($parts[1])) {
|
||||
if (in_array($parts[1], $this->domains)) {
|
||||
$this->domain = $parts[1];
|
||||
@@ -291,13 +273,13 @@ class Inbox extends Component
|
||||
{
|
||||
try {
|
||||
if ($this->email != null) {
|
||||
$data = explode('@', $this->email);
|
||||
$data = explode('@', (string) $this->email);
|
||||
if (isset($data[1])) {
|
||||
$domain = $data[1];
|
||||
if ($this->premium) {
|
||||
$domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
$domains = json_decode((string) config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
} else {
|
||||
$domains = json_decode(config('app.settings.configuration_settings'))->domains ?? [];
|
||||
$domains = json_decode((string) config('app.settings.configuration_settings'))->domains ?? [];
|
||||
}
|
||||
if (! in_array($domain, $domains)) {
|
||||
$key = array_search($this->email, $this->emails);
|
||||
@@ -306,16 +288,12 @@ class Inbox extends Component
|
||||
} else {
|
||||
ZEmail::removeEmail($this->email);
|
||||
}
|
||||
if ($key == 0 && count($this->emails) == 1 && json_decode(config('app.settings.configuration_settings'))->after_last_email_delete == 'redirect_to_homepage') {
|
||||
redirect()->route('dashboard.premium');
|
||||
} else {
|
||||
redirect()->route('dashboard.premium');
|
||||
}
|
||||
to_route('dashboard.premium');
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
\Log::error($exception->getMessage());
|
||||
\Illuminate\Support\Facades\Log::error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +308,7 @@ 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((string) config('app.settings.imap_settings'))->premium_cc_check) {
|
||||
$responses = [
|
||||
'to' => Premium::getMessages($this->email, 'to', $this->deleted),
|
||||
'cc' => [
|
||||
@@ -344,21 +322,19 @@ class Inbox extends Component
|
||||
'cc' => Premium::getMessages($this->email, 'cc', $this->deleted),
|
||||
];
|
||||
}
|
||||
} elseif (config('app.beta_feature') || ! json_decode((string) config('app.settings.imap_settings'))->cc_check) {
|
||||
$responses = [
|
||||
'to' => ZEmail::getMessages($this->email, 'to', $this->deleted),
|
||||
'cc' => [
|
||||
'data' => [],
|
||||
'notifications' => [],
|
||||
],
|
||||
];
|
||||
} else {
|
||||
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' => [],
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$responses = [
|
||||
'to' => ZEmail::getMessages($this->email, 'to', $this->deleted),
|
||||
'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted),
|
||||
];
|
||||
}
|
||||
$responses = [
|
||||
'to' => ZEmail::getMessages($this->email, 'to', $this->deleted),
|
||||
'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted),
|
||||
];
|
||||
}
|
||||
|
||||
$this->deleted = [];
|
||||
@@ -366,7 +342,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 {
|
||||
@@ -397,7 +373,7 @@ class Inbox extends Component
|
||||
$this->initial = true;
|
||||
}
|
||||
|
||||
public function delete($messageId)
|
||||
public function delete(string $messageId): void
|
||||
{
|
||||
|
||||
try {
|
||||
@@ -422,23 +398,23 @@ class Inbox extends Component
|
||||
|
||||
}
|
||||
|
||||
public function toggleMode()
|
||||
public function toggleMode(): void
|
||||
{
|
||||
$this->premium = ! $this->premium;
|
||||
Session::put('isInboxTypePremium', $this->premium);
|
||||
if ($this->premium) {
|
||||
$this->domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
$this->domains = json_decode((string) config('app.settings.configuration_settings'))->premium_domains ?? [];
|
||||
$this->email = Premium::getEmail();
|
||||
$this->emails = Premium::getEmails();
|
||||
$this->initial = false;
|
||||
$this->checkMultipleEmails();
|
||||
$this->validateDomainInEmail();
|
||||
$mailboxHistory = UsageLog::where(['user_id' => auth()->user()->id])->first();
|
||||
$mailboxHistory = UsageLog::query()->where(['user_id' => auth()->user()->id])->first();
|
||||
$this->mailboxHistory = $mailboxHistory->emails_created_history ?? [];
|
||||
$this->messages = [];
|
||||
|
||||
} else {
|
||||
$this->domains = json_decode(config('app.settings.configuration_settings'))->domains ?? [];
|
||||
$this->domains = json_decode((string) config('app.settings.configuration_settings'))->domains ?? [];
|
||||
$this->email = ZEmail::getEmail();
|
||||
$this->emails = ZEmail::getEmails();
|
||||
$this->initial = false;
|
||||
@@ -453,17 +429,16 @@ class Inbox extends Component
|
||||
{
|
||||
if (Session::get('isSubscribed')) {
|
||||
return view('livewire.dashboard.mailbox.inbox')->layout('components.layouts.dashboard');
|
||||
} else {
|
||||
return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard');
|
||||
}
|
||||
return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard');
|
||||
}
|
||||
|
||||
private function rrmdir($dir): void
|
||||
private function rrmdir(string $dir): void
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != '.' && $object != '..') {
|
||||
if ($object !== '.' && $object !== '..') {
|
||||
if (is_dir($dir.DIRECTORY_SEPARATOR.$object) && ! is_link($dir.'/'.$object)) {
|
||||
$this->rrmdir($dir.DIRECTORY_SEPARATOR.$object);
|
||||
} else {
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Livewire\Dashboard;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use App\Models\ActivationKey;
|
||||
use App\Models\Plan;
|
||||
use Exception;
|
||||
use Livewire\Component;
|
||||
use Log;
|
||||
|
||||
class Pricing extends Component
|
||||
{
|
||||
@@ -34,8 +36,8 @@ class Pricing extends Component
|
||||
'activation_key.max' => 'The activation key must not exceed 30 characters.',
|
||||
]);
|
||||
|
||||
$trimmedKey = trim($this->activation_key);
|
||||
$activation = ActivationKey::where('activation_key', $trimmedKey)
|
||||
$trimmedKey = trim((string) $this->activation_key);
|
||||
$activation = ActivationKey::query()->where('activation_key', $trimmedKey)
|
||||
->where('is_activated', false)
|
||||
->first();
|
||||
|
||||
@@ -43,7 +45,7 @@ class Pricing extends Component
|
||||
if ($activation->price_id !== null) {
|
||||
$result = $this->addSubscription($activation->price_id);
|
||||
}
|
||||
if ($result === true) {
|
||||
if ($result) {
|
||||
$activation->is_activated = true;
|
||||
$activation->user_id = auth()->id();
|
||||
$activation->save();
|
||||
@@ -61,7 +63,7 @@ class Pricing extends Component
|
||||
private function addSubscription($price_id): bool
|
||||
{
|
||||
try {
|
||||
$plan = Plan::where('pricing_id', $price_id)->firstOrFail();
|
||||
$plan = Plan::query()->where('pricing_id', $price_id)->firstOrFail();
|
||||
$user = auth()->user();
|
||||
$user->createOrGetStripeCustomer();
|
||||
$user->updateStripeCustomer([
|
||||
@@ -76,11 +78,7 @@ class Pricing extends Component
|
||||
$balance = $user->balance();
|
||||
$user->newSubscription('default', $plan->pricing_id)->create();
|
||||
|
||||
if ($plan->monthly_billing == 1) {
|
||||
$ends_at = now()->addMonth();
|
||||
} else {
|
||||
$ends_at = now()->addYear();
|
||||
}
|
||||
$ends_at = $plan->monthly_billing == 1 ? now()->addMonth() : now()->addYear();
|
||||
$user->subscription('default')->cancelAt($ends_at);
|
||||
|
||||
return true;
|
||||
@@ -91,7 +89,7 @@ class Pricing extends Component
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
public function render(): Factory|View
|
||||
{
|
||||
return view('livewire.dashboard.pricing');
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Livewire\Dashboard;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketResponse;
|
||||
use Exception;
|
||||
use Livewire\Component;
|
||||
use Request;
|
||||
use Str;
|
||||
|
||||
class Support extends Component
|
||||
{
|
||||
@@ -25,7 +25,7 @@ class Support extends Component
|
||||
|
||||
public $closed = 0;
|
||||
|
||||
public function store()
|
||||
public function store(): void
|
||||
{
|
||||
$this->validate([
|
||||
'subject' => 'required|string|max:255',
|
||||
@@ -33,7 +33,7 @@ class Support extends Component
|
||||
]);
|
||||
|
||||
try {
|
||||
$ticket = Ticket::create([
|
||||
$ticket = Ticket::query()->create([
|
||||
'user_id' => auth()->id(),
|
||||
'ticket_id' => strtoupper(Str::random(6)),
|
||||
'subject' => $this->subject,
|
||||
@@ -47,13 +47,13 @@ class Support extends Component
|
||||
$this->tickets = Ticket::with('responses')
|
||||
->where('user_id', auth()->id())
|
||||
->get();
|
||||
} catch (Exception $exception) {
|
||||
} catch (Exception) {
|
||||
$this->dispatch('showAlert', ['type' => 'error', 'message' => 'Something went wrong!']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function reply($ticket_id)
|
||||
public function reply($ticket_id): void
|
||||
{
|
||||
$this->validate([
|
||||
'response' => 'required|string',
|
||||
@@ -67,14 +67,14 @@ class Support extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$ticket = Ticket::find($ticket_id);
|
||||
$ticket = Ticket::query()->find($ticket_id);
|
||||
if (! $ticket) {
|
||||
$this->dispatch('showAlert', ['type' => 'error', 'message' => 'Ticket not found.']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
TicketResponse::create([
|
||||
TicketResponse::query()->create([
|
||||
'ticket_id' => $ticket_id,
|
||||
'user_id' => auth()->id(),
|
||||
'response' => $this->response,
|
||||
@@ -90,20 +90,20 @@ class Support extends Component
|
||||
->where('user_id', auth()->id())
|
||||
->get();
|
||||
|
||||
} catch (Exception $exception) {
|
||||
} catch (Exception) {
|
||||
session()->flash('error', 'Something went wrong!');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function close($ticket_id)
|
||||
public function close($ticket_id): void
|
||||
{
|
||||
if (! is_numeric($ticket_id)) {
|
||||
$this->dispatch('showAlert', ['type' => 'error', 'message' => 'Invalid ticket ID.']);
|
||||
|
||||
return;
|
||||
}
|
||||
$ticket = Ticket::find($ticket_id);
|
||||
$ticket = Ticket::query()->find($ticket_id);
|
||||
if (! $ticket) {
|
||||
$this->dispatch('showAlert', ['type' => 'error', 'message' => 'Ticket not found.']);
|
||||
|
||||
@@ -119,7 +119,7 @@ class Support extends Component
|
||||
$this->dispatch('showAlert', ['type' => 'error', 'message' => 'This ticket has been closed!']);
|
||||
}
|
||||
|
||||
public function mount()
|
||||
public function mount(): void
|
||||
{
|
||||
$this->tickets = Ticket::with('responses')
|
||||
->where('user_id', auth()->id())
|
||||
@@ -127,15 +127,11 @@ class Support extends Component
|
||||
$this->updateTicketCounts();
|
||||
}
|
||||
|
||||
public function updateTicketCounts()
|
||||
public function updateTicketCounts(): void
|
||||
{
|
||||
$this->open = $this->tickets->filter(function ($ticket) {
|
||||
return in_array($ticket->status, ['open', 'pending']);
|
||||
})->count();
|
||||
$this->open = $this->tickets->filter(fn($ticket): bool => in_array($ticket->status, ['open', 'pending']))->count();
|
||||
|
||||
$this->closed = $this->tickets->filter(function ($ticket) {
|
||||
return $ticket->status === 'closed';
|
||||
})->count();
|
||||
$this->closed = $this->tickets->filter(fn($ticket): bool => $ticket->status === 'closed')->count();
|
||||
}
|
||||
|
||||
protected function getClientIp()
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
|
||||
namespace App\Livewire\Frontend;
|
||||
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use App\Models\Log;
|
||||
use App\Models\ZEmail;
|
||||
use Carbon\Carbon;
|
||||
use Livewire\Component;
|
||||
|
||||
class Action extends Component
|
||||
@@ -23,9 +27,9 @@ class Action extends Component
|
||||
|
||||
public $initial;
|
||||
|
||||
public function mount()
|
||||
public function mount(): void
|
||||
{
|
||||
$this->domains = json_decode(config('app.settings.configuration_settings'))->domains ?? [];
|
||||
$this->domains = json_decode((string) config('app.settings.configuration_settings'))->domains ?? [];
|
||||
$this->email = ZEmail::getEmail();
|
||||
$this->emails = ZEmail::getEmails();
|
||||
$this->validateDomainInEmail();
|
||||
@@ -37,17 +41,17 @@ class Action extends Component
|
||||
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);
|
||||
if (strlen((string) $this->username) < json_decode((string) config('app.settings.configuration_settings'))->custom_username_length_min || strlen((string) $this->username) > json_decode((string) config('app.settings.configuration_settings'))->custom_username_length_max) {
|
||||
return $this->showAlert('error', __('Username length cannot be less than').' '.json_decode((string) config('app.settings.configuration_settings'))->custom_username_length_min.' '.__('and greater than').' '.json_decode((string) config('app.settings.configuration_settings'))->custom_username_length_max);
|
||||
}
|
||||
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)) {
|
||||
if (in_array($this->username, json_decode((string) 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 ').json_decode(config('app.settings.configuration_settings'))->email_limit.__(' temp mail'));
|
||||
return $this->showAlert('error', __('You have reached daily limit of MAX ').json_decode((string) config('app.settings.configuration_settings'))->email_limit.__(' temp mail'));
|
||||
}
|
||||
if (! $this->checkUsedEmail()) {
|
||||
return $this->showAlert('error', __('Sorry! That email is already been used by someone else. Please try a different email address.'));
|
||||
@@ -55,49 +59,49 @@ class Action extends Component
|
||||
|
||||
$this->email = ZEmail::createCustomEmail($this->username, $this->domain);
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
return to_route('mailbox');
|
||||
|
||||
}
|
||||
|
||||
public function random()
|
||||
{
|
||||
if (! $this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode(config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.'));
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode((string) config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.'));
|
||||
}
|
||||
$this->email = ZEmail::generateRandomEmail();
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
return to_route('mailbox');
|
||||
}
|
||||
|
||||
public function gmail()
|
||||
{
|
||||
if (! $this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode(config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.'));
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode((string) config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.'));
|
||||
}
|
||||
$this->email = ZEmail::generateRandomGmail();
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
return to_route('mailbox');
|
||||
}
|
||||
|
||||
public function outlook()
|
||||
{
|
||||
if (! $this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode(config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.'));
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode((string) config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.'));
|
||||
}
|
||||
$this->email = ZEmail::generateRandomOutlook();
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
return to_route('mailbox');
|
||||
}
|
||||
|
||||
public function deleteEmail()
|
||||
public function deleteEmail(): Redirector|RedirectResponse
|
||||
{
|
||||
return redirect()->route('delete', ['email' => $this->email]);
|
||||
return to_route('delete', ['email' => $this->email]);
|
||||
}
|
||||
|
||||
private function showAlert($type, $message): void
|
||||
private function showAlert(string $type, $message): void
|
||||
{
|
||||
$check = json_decode(config('app.settings.configuration_settings'))->email_limit;
|
||||
if (strpos($message, $check) !== false) {
|
||||
$check = json_decode((string) config('app.settings.configuration_settings'))->email_limit;
|
||||
if (str_contains((string) $message, (string) $check)) {
|
||||
$this->dispatch('promotePremium');
|
||||
}
|
||||
$this->dispatch('showAlert', ['type' => $type, 'message' => $message]);
|
||||
@@ -105,31 +109,23 @@ class Action extends Component
|
||||
|
||||
private function checkEmailLimit(): bool
|
||||
{
|
||||
$logs = Log::select('ip', 'email')->where('ip', request()->ip())->where('created_at', '>', Carbon::now()->subDay())->groupBy('email')->groupBy('ip')->get();
|
||||
if (count($logs) >= json_decode(config('app.settings.configuration_settings'))->email_limit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
$logs = Log::query()->select('ip', 'email')->where('ip', request()->ip())->where('created_at', '>', Date::now()->subDay())->groupBy('email')->groupBy('ip')->get();
|
||||
return count($logs) < json_decode((string) config('app.settings.configuration_settings'))->email_limit;
|
||||
}
|
||||
|
||||
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();
|
||||
if ($check > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
if (json_decode((string) config('app.settings.configuration_settings'))->disable_used_email) {
|
||||
$check = Log::query()->where('email', $this->user.'@'.$this->domain)->where('ip', '<>', request()->ip())->count();
|
||||
return $check <= 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function checkDomainInUsername()
|
||||
private function checkDomainInUsername(): void
|
||||
{
|
||||
$parts = explode('@', $this->username);
|
||||
$parts = explode('@', (string) $this->username);
|
||||
if (isset($parts[1])) {
|
||||
if (in_array($parts[1], $this->domains)) {
|
||||
$this->domain = $parts[1];
|
||||
@@ -140,23 +136,23 @@ class Action extends Component
|
||||
|
||||
private function validateDomainInEmail(): void
|
||||
{
|
||||
$data = explode('@', $this->email);
|
||||
$data = explode('@', (string) $this->email);
|
||||
if (isset($data[1])) {
|
||||
$domain = $data[1];
|
||||
$domains = json_decode(config('app.settings.configuration_settings'))->domains ?? [];
|
||||
$domains = json_decode((string) config('app.settings.configuration_settings'))->domains ?? [];
|
||||
if (! in_array($domain, $domains)) {
|
||||
$key = array_search($this->email, $this->emails);
|
||||
ZEmail::removeEmail($this->email);
|
||||
if ($key == 0 && count($this->emails) == 1 && json_decode(config('app.settings.configuration_settings'))->after_last_email_delete == 'redirect_to_homepage') {
|
||||
redirect()->route('home');
|
||||
if ($key == 0 && count($this->emails) === 1 && json_decode((string) config('app.settings.configuration_settings'))->after_last_email_delete == 'redirect_to_homepage') {
|
||||
to_route('home');
|
||||
} else {
|
||||
redirect()->route('mailbox');
|
||||
to_route('mailbox');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
public function render(): Factory|View
|
||||
{
|
||||
return view('livewire.frontend.action');
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Livewire\Frontend;
|
||||
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use App\Models\ZEmail;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -29,26 +31,22 @@ class Email extends Component
|
||||
|
||||
private function checkMultipleEmails(): void
|
||||
{
|
||||
if (count($this->emails) == 0) {
|
||||
if (count($this->emails) === 0) {
|
||||
$this->emails = [$this->email];
|
||||
}
|
||||
if (count($this->emails) > 1) {
|
||||
$this->list = true;
|
||||
} else {
|
||||
$this->list = false;
|
||||
}
|
||||
$this->list = count($this->emails) > 1;
|
||||
}
|
||||
|
||||
public function switchEmail($email)
|
||||
public function switchEmail($email): Redirector|RedirectResponse
|
||||
{
|
||||
return redirect()->route('switch', ['email' => $email]);
|
||||
return to_route('switch', ['email' => $email]);
|
||||
}
|
||||
|
||||
public function syncEmail(): void
|
||||
{
|
||||
$this->email = ZEmail::getEmail();
|
||||
$this->emails = ZEmail::getEmails();
|
||||
if (count($this->emails) == 0) {
|
||||
if (count($this->emails) === 0) {
|
||||
$this->dispatch('getEmail');
|
||||
}
|
||||
$this->checkMultipleEmails();
|
||||
|
||||
@@ -38,8 +38,9 @@ class Mailbox extends Component
|
||||
$this->email = ZEmail::getEmail();
|
||||
$this->initial = false;
|
||||
if (! ZEmail::getEmail()) {
|
||||
return redirect()->route('home');
|
||||
return to_route('home');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function syncEmail($email): void
|
||||
@@ -57,7 +58,7 @@ class Mailbox extends Component
|
||||
$this->messages = [];
|
||||
}
|
||||
$responses = [];
|
||||
if (config('app.beta_feature') || ! json_decode(config('app.settings.imap_settings'))->cc_check) {
|
||||
if (config('app.beta_feature') || ! json_decode((string) config('app.settings.imap_settings'))->cc_check) {
|
||||
$responses = [
|
||||
'to' => ZEmail::getMessages($this->email, 'to', $this->deleted),
|
||||
'cc' => [
|
||||
@@ -77,7 +78,7 @@ class Mailbox 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 {
|
||||
@@ -99,15 +100,15 @@ class Mailbox extends Component
|
||||
$this->initial = true;
|
||||
}
|
||||
|
||||
public function delete($messageId)
|
||||
public function delete(string $messageId): void
|
||||
{
|
||||
|
||||
try {
|
||||
if (config('app.beta_feature')) {
|
||||
Message::find($messageId)->delete();
|
||||
Message::query()->find($messageId)->delete();
|
||||
}
|
||||
if (config('app.fetch_from_db')) {
|
||||
Email::where(['message_id' => $messageId])->delete();
|
||||
Email::query()->where(['message_id' => $messageId])->delete();
|
||||
}
|
||||
$this->deleted[] = $messageId;
|
||||
foreach ($this->messages as $key => $message) {
|
||||
@@ -131,12 +132,12 @@ class Mailbox extends Component
|
||||
return view('livewire.frontend.mailbox')->with(['messages' => $this->messages, 'email' => $this->email, 'initial' => $this->initial, 'error' => $this->error]);
|
||||
}
|
||||
|
||||
private function rrmdir($dir): void
|
||||
private function rrmdir(string $dir): void
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != '.' && $object != '..') {
|
||||
if ($object !== '.' && $object !== '..') {
|
||||
if (is_dir($dir.DIRECTORY_SEPARATOR.$object) && ! is_link($dir.'/'.$object)) {
|
||||
$this->rrmdir($dir.DIRECTORY_SEPARATOR.$object);
|
||||
} else {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use App\Models\ZEmail;
|
||||
use Livewire\Component;
|
||||
|
||||
@@ -14,11 +16,12 @@ class Home extends Component
|
||||
$email = ZEmail::getEmail();
|
||||
$messages = ZEmail::getMessages($email);
|
||||
if (count($messages['data']) > 0) {
|
||||
return redirect()->route('mailbox');
|
||||
return to_route('mailbox');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function render()
|
||||
public function render(): Factory|View
|
||||
{
|
||||
return view('livewire.home');
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ListBlog extends Component
|
||||
{
|
||||
public function render()
|
||||
public function render(): Factory|View
|
||||
{
|
||||
return view('livewire.list-blog');
|
||||
}
|
||||
|
||||
@@ -2,24 +2,24 @@
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class Page extends Component
|
||||
{
|
||||
public $slug;
|
||||
|
||||
public function mount($slug)
|
||||
public function mount($slug): void
|
||||
{
|
||||
$this->slug = $slug;
|
||||
}
|
||||
|
||||
public function render()
|
||||
public function render(): Factory|View
|
||||
{
|
||||
$page = \App\Models\Page::where('slug', $this->slug)->firstOrFail();
|
||||
$page = \App\Models\Page::query()->where('slug', $this->slug)->firstOrFail();
|
||||
|
||||
if ($page->is_published == false) {
|
||||
abort(404);
|
||||
}
|
||||
abort_if($page->is_published == false, 404);
|
||||
|
||||
return view('livewire.page', [
|
||||
'page' => $page,
|
||||
|
||||
Reference in New Issue
Block a user