diff --git a/app/Factory/ClientContactFactory.php b/app/Factory/ClientContactFactory.php new file mode 100644 index 000000000000..f47e1764fdda --- /dev/null +++ b/app/Factory/ClientContactFactory.php @@ -0,0 +1,19 @@ +first_name = ""; + $client_contact->user_id = $user_id; + $client_contact->company_id = $company_id; + $client_contact->id = 0; + + return $client_contact; + } +} diff --git a/app/Factory/ClientFactory.php b/app/Factory/ClientFactory.php new file mode 100644 index 000000000000..12d4bc6cba5a --- /dev/null +++ b/app/Factory/ClientFactory.php @@ -0,0 +1,27 @@ +company_id = $company_id; + $client->user_id = $user_id; + $client->name = ''; + $client->website = ''; + $client->private_notes = ''; + $client->balance = 0; + $client->paid_to_date = 0; + $client->country_id = 4; + $client->is_deleted = 0; + + $client_contact = ClientContactFactory::create($company_id, $user_id); + $client->contacts->add($client_contact); + + return $client; + } +} diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index b961005f781e..7a4c5327702f 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -19,10 +19,7 @@ use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesMenu; use App\Utils\Traits\UserSessionAttributes; use Illuminate\Http\Request; -use Illuminate\Support\Facades\DB; -use Illuminate\Support\Facades\Log; -use Yajra\DataTables\Facades\DataTables; -use Yajra\DataTables\Html\Builder; +use App\Factory\ClientFactory; /** * Class ClientController @@ -80,16 +77,7 @@ class ClientController extends Controller */ public function create(CreateClientRequest $request) { - $client = new Client; - $client->name = ''; - $client->company_id = $this->getCurrentCompanyId(); - $client_contact = new ClientContact; - $client_contact->first_name = ""; - $client_contact->user_id = auth()->user()->id; - $client_contact->company_id = $this->getCurrentCompanyId(); - $client_contact->id = 0; - - $client->contacts->add($client_contact); + $client = ClientFactory::create($this->getCurrentCompanyId(), auth()->user()->id); $data = [ 'client' => $client, diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php new file mode 100644 index 000000000000..6d66c38d3f38 --- /dev/null +++ b/app/Providers/TelescopeServiceProvider.php @@ -0,0 +1,70 @@ +hideSensitiveRequestDetails(); + + Telescope::filter(function (IncomingEntry $entry) { + if ($this->app->isLocal()) { + return true; + } + + return $entry->isReportableException() || + $entry->isFailedJob() || + $entry->isScheduledTask() || + $entry->hasMonitoredTag(); + }); + } + + /** + * Prevent sensitive request details from being logged by Telescope. + * + * @return void + */ + protected function hideSensitiveRequestDetails() + { + if ($this->app->isLocal()) { + return; + } + + Telescope::hideRequestParameters(['_token']); + + Telescope::hideRequestHeaders([ + 'cookie', + 'x-csrf-token', + 'x-xsrf-token', + ]); + } + + /** + * Register the Telescope gate. + * + * This gate determines who can access Telescope in non-local environments. + * + * @return void + */ + protected function gate() + { + Gate::define('viewTelescope', function ($user) { + return in_array($user->email, [ + // + ]); + }); + } +}