Repository: zgabievi/pingcrm-svelte Branch: master Commit: 4bc6d9883123 Files: 136 Total size: 220.4 KB Directory structure: gitextract_loyfmr9_/ ├── .editorconfig ├── .eslintrc.js ├── .gitattributes ├── .gitignore ├── .prettierrc ├── LICENSE ├── Procfile ├── app/ │ ├── Account.php │ ├── Console/ │ │ └── Kernel.php │ ├── Contact.php │ ├── Exceptions/ │ │ └── Handler.php │ ├── Http/ │ │ ├── Controllers/ │ │ │ ├── Auth/ │ │ │ │ ├── ForgotPasswordController.php │ │ │ │ ├── LoginController.php │ │ │ │ ├── RegisterController.php │ │ │ │ ├── ResetPasswordController.php │ │ │ │ └── VerificationController.php │ │ │ ├── ContactsController.php │ │ │ ├── Controller.php │ │ │ ├── DashboardController.php │ │ │ ├── ImagesController.php │ │ │ ├── OrganizationsController.php │ │ │ ├── ReportsController.php │ │ │ └── UsersController.php │ │ ├── Kernel.php │ │ └── Middleware/ │ │ ├── Authenticate.php │ │ ├── CheckForMaintenanceMode.php │ │ ├── EncryptCookies.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustProxies.php │ │ └── VerifyCsrfToken.php │ ├── Model.php │ ├── Organization.php │ ├── Providers/ │ │ ├── AppServiceProvider.php │ │ ├── AuthServiceProvider.php │ │ ├── BroadcastServiceProvider.php │ │ ├── EventServiceProvider.php │ │ └── RouteServiceProvider.php │ └── User.php ├── artisan ├── bootstrap/ │ ├── app.php │ └── cache/ │ └── .gitignore ├── composer.json ├── config/ │ ├── app.php │ ├── auth.php │ ├── broadcasting.php │ ├── cache.php │ ├── database.php │ ├── filesystems.php │ ├── hashing.php │ ├── logging.php │ ├── mail.php │ ├── queue.php │ ├── sentry.php │ ├── services.php │ ├── session.php │ └── view.php ├── database/ │ ├── .gitignore │ ├── factories/ │ │ ├── ContactFactory.php │ │ ├── OrganizationFactory.php │ │ └── UserFactory.php │ ├── migrations/ │ │ ├── 2019_03_05_000000_create_accounts_table.php │ │ ├── 2019_03_05_000000_create_contacts_table.php │ │ ├── 2019_03_05_000000_create_organizations_table.php │ │ ├── 2019_03_05_000000_create_password_resets_table.php │ │ └── 2019_03_05_000000_create_users_table.php │ └── seeds/ │ └── DatabaseSeeder.php ├── jsconfig.json ├── package.json ├── phpunit.xml ├── public/ │ ├── .htaccess │ ├── index.php │ ├── robots.txt │ └── web.config ├── readme.md ├── resources/ │ ├── css/ │ │ ├── app.css │ │ ├── buttons.css │ │ ├── form.css │ │ ├── nprogress.css │ │ └── reset.css │ ├── js/ │ │ ├── Pages/ │ │ │ ├── Auth/ │ │ │ │ └── Login.svelte │ │ │ ├── Contacts/ │ │ │ │ ├── Create.svelte │ │ │ │ ├── Edit.svelte │ │ │ │ └── Index.svelte │ │ │ ├── Dashboard/ │ │ │ │ └── Index.svelte │ │ │ ├── Error.svelte │ │ │ ├── Organizations/ │ │ │ │ ├── Create.svelte │ │ │ │ ├── Edit.svelte │ │ │ │ └── Index.svelte │ │ │ ├── Reports/ │ │ │ │ └── Index.svelte │ │ │ └── Users/ │ │ │ ├── Create.svelte │ │ │ ├── Edit.svelte │ │ │ └── Index.svelte │ │ ├── Shared/ │ │ │ ├── BottomHeader.svelte │ │ │ ├── DeleteButton.svelte │ │ │ ├── FileInput.svelte │ │ │ ├── FlashMessages.svelte │ │ │ ├── Helmet.svelte │ │ │ ├── Icon.svelte │ │ │ ├── Layout.svelte │ │ │ ├── LoadingButton.svelte │ │ │ ├── Logo.svelte │ │ │ ├── MainMenu.svelte │ │ │ ├── MainMenuItem.svelte │ │ │ ├── Pagination.svelte │ │ │ ├── SearchFilter.svelte │ │ │ ├── SelectInput.svelte │ │ │ ├── TextInput.svelte │ │ │ ├── TopHeader.svelte │ │ │ └── TrashedMessage.svelte │ │ ├── app.js │ │ └── utils.js │ ├── lang/ │ │ └── en/ │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php │ └── views/ │ └── app.blade.php ├── routes/ │ ├── api.php │ ├── channels.php │ ├── console.php │ └── web.php ├── server.php ├── storage/ │ ├── app/ │ │ └── .gitignore │ ├── debugbar/ │ │ └── .gitignore │ ├── framework/ │ │ ├── .gitignore │ │ ├── cache/ │ │ │ └── .gitignore │ │ ├── sessions/ │ │ │ └── .gitignore │ │ ├── testing/ │ │ │ └── .gitignore │ │ └── views/ │ │ └── .gitignore │ └── logs/ │ └── .gitignore ├── tailwind.config.js ├── tests/ │ ├── CreatesApplication.php │ ├── Feature/ │ │ ├── ContactsTest.php │ │ └── OrganizationsTest.php │ └── TestCase.php └── webpack.mix.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space indent_size = 4 trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false [*.yml] indent_size = 2 ================================================ FILE: .eslintrc.js ================================================ module.exports = { extends: ['eslint:recommended'], parser: 'babel-eslint', parserOptions: { sourceType: 'module', ecmaFeatures: { jsx: true } }, rules: { 'no-console': 'off', 'no-undef': 'off', 'svelte3/named-blocks': 'off' } }; ================================================ FILE: .gitattributes ================================================ * text=auto *.css linguist-vendored *.scss linguist-vendored *.js linguist-vendored CHANGELOG.md export-ignore ================================================ FILE: .gitignore ================================================ /node_modules /public/css /public/hot /public/js /public/mix-manifest.json /public/storage /storage/*.key /database/*.sqlite /vendor .DS_Store .env .php_cs.dist .phpunit.result.cache Homestead.json Homestead.yaml npm-debug.log yarn-error.log .idea ================================================ FILE: .prettierrc ================================================ { "printWidth": 80, "singleQuote": true, "tabWidth": 2 } ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) Jonathan Reinink Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: Procfile ================================================ web: vendor/bin/heroku-php-apache2 public/ ================================================ FILE: app/Account.php ================================================ hasMany(User::class); } public function organizations() { return $this->hasMany(Organization::class); } public function contacts() { return $this->hasMany(Contact::class); } } ================================================ FILE: app/Console/Kernel.php ================================================ command('inspire') // ->hourly(); } /** * Register the commands for the application. * * @return void */ protected function commands() { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } } ================================================ FILE: app/Contact.php ================================================ belongsTo(Organization::class); } public function getNameAttribute() { return $this->first_name.' '.$this->last_name; } public function scopeOrderByName($query) { $query->orderBy('last_name')->orderBy('first_name'); } public function scopeFilter($query, array $filters) { $query->when($filters['search'] ?? null, function ($query, $search) { $query->where(function ($query) use ($search) { $query->where('first_name', 'like', '%'.$search.'%') ->orWhere('last_name', 'like', '%'.$search.'%') ->orWhere('email', 'like', '%'.$search.'%') ->orWhereHas('organization', function ($query) use ($search) { $query->where('name', 'like', '%'.$search.'%'); }); }); })->when($filters['trashed'] ?? null, function ($query, $trashed) { if ($trashed === 'with') { $query->withTrashed(); } elseif ($trashed === 'only') { $query->onlyTrashed(); } }); } } ================================================ FILE: app/Exceptions/Handler.php ================================================ bound('sentry') && $this->shouldReport($exception)) { app('sentry')->captureException($exception); } parent::report($exception); } /** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Throwable $exception * @return \Illuminate\Http\Response */ public function render($request, Throwable $exception) { $response = parent::render($request, $exception); if ( (App::environment('production')) && $request->header('X-Inertia') && in_array($response->status(), [500, 503, 404, 403]) ) { return Inertia::render('Error', ['status' => $response->status()]) ->toResponse($request) ->setStatusCode($response->status()); } return $response; } } ================================================ FILE: app/Http/Controllers/Auth/ForgotPasswordController.php ================================================ middleware('guest'); } } ================================================ FILE: app/Http/Controllers/Auth/LoginController.php ================================================ middleware('guest'); } /** * Get a validator for an incoming registration request. * * @param array $data * @return \Illuminate\Contracts\Validation\Validator */ protected function validator(array $data) { return Validator::make($data, [ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => ['required', 'string', 'min:8', 'confirmed'], ]); } /** * Create a new user instance after a valid registration. * * @param array $data * @return \App\User */ protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => Hash::make($data['password']), ]); } } ================================================ FILE: app/Http/Controllers/Auth/ResetPasswordController.php ================================================ middleware('guest'); } } ================================================ FILE: app/Http/Controllers/Auth/VerificationController.php ================================================ middleware('auth'); $this->middleware('signed')->only('verify'); $this->middleware('throttle:6,1')->only('verify', 'resend'); } } ================================================ FILE: app/Http/Controllers/ContactsController.php ================================================ Request::all('search', 'trashed'), 'contacts' => Auth::user()->account->contacts() ->with('organization') ->orderByName() ->filter(Request::only('search', 'trashed')) ->paginate() ->transform(function ($contact) { return [ 'id' => $contact->id, 'name' => $contact->name, 'phone' => $contact->phone, 'city' => $contact->city, 'deleted_at' => $contact->deleted_at, 'organization' => $contact->organization ? $contact->organization->only('name') : null, ]; }), ]); } public function create() { return Inertia::render('Contacts/Create', [ 'organizations' => Auth::user()->account ->organizations() ->orderBy('name') ->get() ->map ->only('id', 'name'), ]); } public function store() { Auth::user()->account->contacts()->create( Request::validate([ 'first_name' => ['required', 'max:50'], 'last_name' => ['required', 'max:50'], 'organization_id' => ['nullable', Rule::exists('organizations', 'id')->where(function ($query) { $query->where('account_id', Auth::user()->account_id); })], 'email' => ['nullable', 'max:50', 'email'], 'phone' => ['nullable', 'max:50'], 'address' => ['nullable', 'max:150'], 'city' => ['nullable', 'max:50'], 'region' => ['nullable', 'max:50'], 'country' => ['nullable', 'max:2'], 'postal_code' => ['nullable', 'max:25'], ]) ); return Redirect::route('contacts')->with('success', 'Contact created.'); } public function edit(Contact $contact) { return Inertia::render('Contacts/Edit', [ 'contact' => [ 'id' => $contact->id, 'first_name' => $contact->first_name, 'last_name' => $contact->last_name, 'organization_id' => $contact->organization_id, 'email' => $contact->email, 'phone' => $contact->phone, 'address' => $contact->address, 'city' => $contact->city, 'region' => $contact->region, 'country' => $contact->country, 'postal_code' => $contact->postal_code, 'deleted_at' => $contact->deleted_at, ], 'organizations' => Auth::user()->account->organizations() ->orderBy('name') ->get() ->map ->only('id', 'name'), ]); } public function update(Contact $contact) { $contact->update( Request::validate([ 'first_name' => ['required', 'max:50'], 'last_name' => ['required', 'max:50'], 'organization_id' => ['nullable', Rule::exists('organizations', 'id')->where(function ($query) { $query->where('account_id', Auth::user()->account_id); })], 'email' => ['nullable', 'max:50', 'email'], 'phone' => ['nullable', 'max:50'], 'address' => ['nullable', 'max:150'], 'city' => ['nullable', 'max:50'], 'region' => ['nullable', 'max:50'], 'country' => ['nullable', 'max:2'], 'postal_code' => ['nullable', 'max:25'], ]) ); return Redirect::back()->with('success', 'Contact updated.'); } public function destroy(Contact $contact) { $contact->delete(); return Redirect::back()->with('success', 'Contact deleted.'); } public function restore(Contact $contact) { $contact->restore(); return Redirect::back()->with('success', 'Contact restored.'); } } ================================================ FILE: app/Http/Controllers/Controller.php ================================================ fromRequest()->response(); } } ================================================ FILE: app/Http/Controllers/OrganizationsController.php ================================================ Request::all('search', 'trashed'), 'organizations' => Auth::user()->account->organizations() ->orderBy('name') ->filter(Request::only('search', 'trashed')) ->paginate() ->only('id', 'name', 'phone', 'city', 'deleted_at'), ]); } public function create() { return Inertia::render('Organizations/Create'); } public function store() { Auth::user()->account->organizations()->create( Request::validate([ 'name' => ['required', 'max:100'], 'email' => ['nullable', 'max:50', 'email'], 'phone' => ['nullable', 'max:50'], 'address' => ['nullable', 'max:150'], 'city' => ['nullable', 'max:50'], 'region' => ['nullable', 'max:50'], 'country' => ['nullable', 'max:2'], 'postal_code' => ['nullable', 'max:25'], ]) ); return Redirect::route('organizations')->with('success', 'Organization created.'); } public function edit(Organization $organization) { return Inertia::render('Organizations/Edit', [ 'organization' => [ 'id' => $organization->id, 'name' => $organization->name, 'email' => $organization->email, 'phone' => $organization->phone, 'address' => $organization->address, 'city' => $organization->city, 'region' => $organization->region, 'country' => $organization->country, 'postal_code' => $organization->postal_code, 'deleted_at' => $organization->deleted_at, 'contacts' => $organization->contacts()->orderByName()->get()->map->only('id', 'name', 'city', 'phone'), ], ]); } public function update(Organization $organization) { $organization->update( Request::validate([ 'name' => ['required', 'max:100'], 'email' => ['nullable', 'max:50', 'email'], 'phone' => ['nullable', 'max:50'], 'address' => ['nullable', 'max:150'], 'city' => ['nullable', 'max:50'], 'region' => ['nullable', 'max:50'], 'country' => ['nullable', 'max:2'], 'postal_code' => ['nullable', 'max:25'], ]) ); return Redirect::back()->with('success', 'Organization updated.'); } public function destroy(Organization $organization) { $organization->delete(); return Redirect::back()->with('success', 'Organization deleted.'); } public function restore(Organization $organization) { $organization->restore(); return Redirect::back()->with('success', 'Organization restored.'); } } ================================================ FILE: app/Http/Controllers/ReportsController.php ================================================ Request::all('search', 'role', 'trashed'), 'users' => Auth::user()->account->users() ->orderByName() ->filter(Request::only('search', 'role', 'trashed')) ->paginate() ->transform(function ($user) { return [ 'id' => $user->id, 'name' => $user->name, 'email' => $user->email, 'owner' => $user->owner, 'photo' => $user->photoUrl(['w' => 40, 'h' => 40, 'fit' => 'crop']), 'deleted_at' => $user->deleted_at, ]; }), ]); } public function create() { return Inertia::render('Users/Create'); } public function store() { Request::validate([ 'first_name' => ['required', 'max:50'], 'last_name' => ['required', 'max:50'], 'email' => ['required', 'max:50', 'email', Rule::unique('users')], 'password' => ['nullable'], 'owner' => ['required', 'boolean'], 'photo' => ['nullable', 'image'], ]); Auth::user()->account->users()->create([ 'first_name' => Request::get('first_name'), 'last_name' => Request::get('last_name'), 'email' => Request::get('email'), 'password' => Request::get('password'), 'owner' => Request::get('owner'), 'photo_path' => Request::file('photo') ? Request::file('photo')->store('users') : null, ]); return Redirect::route('users')->with('success', 'User created.'); } public function edit(User $user) { return Inertia::render('Users/Edit', [ 'user' => [ 'id' => $user->id, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'email' => $user->email, 'owner' => $user->owner, 'photo' => $user->photoUrl(['w' => 60, 'h' => 60, 'fit' => 'crop']), 'deleted_at' => $user->deleted_at, ], ]); } public function update(User $user) { if (App::environment('production') && $user->isDemoUser()) { return Redirect::back()->with('error', 'Updating the demo user is not allowed.'); } Request::validate([ 'first_name' => ['required', 'max:50'], 'last_name' => ['required', 'max:50'], 'email' => ['required', 'max:50', 'email', Rule::unique('users')->ignore($user->id)], 'password' => ['nullable'], 'owner' => ['required', 'boolean'], 'photo' => ['nullable', 'image'], ]); $user->update(Request::only('first_name', 'last_name', 'email', 'owner')); if (Request::file('photo')) { $user->update(['photo_path' => Request::file('photo')->store('users')]); } if (Request::get('password')) { $user->update(['password' => Request::get('password')]); } return Redirect::back()->with('success', 'User updated.'); } public function destroy(User $user) { if (App::environment('production') && $user->isDemoUser()) { return Redirect::back()->with('error', 'Deleting the demo user is not allowed.'); } $user->delete(); return Redirect::back()->with('success', 'User deleted.'); } public function restore(User $user) { $user->restore(); return Redirect::back()->with('success', 'User restored.'); } } ================================================ FILE: app/Http/Kernel.php ================================================ [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, ], 'api' => [ 'throttle:60,1', 'bindings', ], ]; /** * The application's route middleware. * * These middleware may be assigned to groups or used individually. * * @var array */ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'remember' => \Reinink\RememberQueryStrings::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, ]; /** * The priority-sorted list of middleware. * * This forces non-global middleware to always be in the given order. * * @var array */ protected $middlewarePriority = [ \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\Authenticate::class, \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Auth\Middleware\Authorize::class, ]; } ================================================ FILE: app/Http/Middleware/Authenticate.php ================================================ expectsJson()) { return route('login'); } } } ================================================ FILE: app/Http/Middleware/CheckForMaintenanceMode.php ================================================ check()) { return redirect('/'); } return $next($request); } } ================================================ FILE: app/Http/Middleware/TrimStrings.php ================================================ where($this->getRouteKeyName(), $value)->withTrashed()->first() : parent::resolveRouteBinding($value, $field); } } ================================================ FILE: app/Organization.php ================================================ hasMany(Contact::class); } public function scopeFilter($query, array $filters) { $query->when($filters['search'] ?? null, function ($query, $search) { $query->where('name', 'like', '%'.$search.'%'); })->when($filters['trashed'] ?? null, function ($query, $trashed) { if ($trashed === 'with') { $query->withTrashed(); } elseif ($trashed === 'only') { $query->onlyTrashed(); } }); } } ================================================ FILE: app/Providers/AppServiceProvider.php ================================================ registerInertia(); $this->registerGlide(); $this->registerLengthAwarePaginator(); } public function registerInertia() { Inertia::version(function () { return md5_file(public_path('mix-manifest.json')); }); Inertia::share([ 'auth' => function () { return [ 'user' => Auth::user() ? [ 'id' => Auth::user()->id, 'first_name' => Auth::user()->first_name, 'last_name' => Auth::user()->last_name, 'email' => Auth::user()->email, 'role' => Auth::user()->role, 'account' => [ 'id' => Auth::user()->account->id, 'name' => Auth::user()->account->name, ], ] : null, ]; }, 'flash' => function () { return [ 'success' => Session::get('success'), 'error' => Session::get('error'), ]; }, 'errors' => function () { return Session::get('errors') ? Session::get('errors')->getBag('default')->getMessages() : (object) []; }, ]); } protected function registerGlide() { $this->app->bind(Server::class, function ($app) { return Server::create([ 'source' => Storage::getDriver(), 'cache' => Storage::getDriver(), 'cache_folder' => '.glide-cache', 'base_url' => 'img', ]); }); } protected function registerLengthAwarePaginator() { $this->app->bind(LengthAwarePaginator::class, function ($app, $values) { return new class (...array_values($values)) extends LengthAwarePaginator { public function only(...$attributes) { return $this->transform(function ($item) use ($attributes) { return $item->only($attributes); }); } public function transform($callback) { $this->items->transform($callback); return $this; } public function toArray() { return [ 'data' => $this->items->toArray(), 'links' => $this->links(), ]; } public function links($view = null, $data = []) { $this->appends(Request::all()); $window = UrlWindow::make($this); $elements = array_filter([ $window['first'], is_array($window['slider']) ? '...' : null, $window['slider'], is_array($window['last']) ? '...' : null, $window['last'], ]); return Collection::make($elements)->flatMap(function ($item) { if (is_array($item)) { return Collection::make($item)->map(function ($url, $page) { return [ 'url' => $url, 'label' => $page, 'active' => $this->currentPage() === $page, ]; }); } else { return [ [ 'url' => null, 'label' => '...', 'active' => false, ], ]; } })->prepend([ 'url' => $this->previousPageUrl(), 'label' => 'Previous', 'active' => false, ])->push([ 'url' => $this->nextPageUrl(), 'label' => 'Next', 'active' => false, ]); } }; }); } } ================================================ FILE: app/Providers/AuthServiceProvider.php ================================================ 'App\Policies\ModelPolicy', ]; /** * Register any authentication / authorization services. * * @return void */ public function boot() { $this->registerPolicies(); // } } ================================================ FILE: app/Providers/BroadcastServiceProvider.php ================================================ [ SendEmailVerificationNotification::class, ], ]; /** * Register any events for your application. * * @return void */ public function boot() { parent::boot(); // } } ================================================ FILE: app/Providers/RouteServiceProvider.php ================================================ mapApiRoutes(); $this->mapWebRoutes(); // } /** * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. * * @return void */ protected function mapWebRoutes() { Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); } /** * Define the "api" routes for the application. * * These routes are typically stateless. * * @return void */ protected function mapApiRoutes() { Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); } } ================================================ FILE: app/User.php ================================================ 'boolean', ]; public function account() { return $this->belongsTo(Account::class); } public function getNameAttribute() { return $this->first_name.' '.$this->last_name; } public function setPasswordAttribute($password) { $this->attributes['password'] = Hash::needsRehash($password) ? Hash::make($password) : $password; } public function photoUrl(array $attributes) { if ($this->photo_path) { return URL::to(App::make(Server::class)->fromPath($this->photo_path, $attributes)); } } public function isDemoUser() { return $this->email === 'johndoe@example.com'; } public function scopeOrderByName($query) { $query->orderBy('last_name')->orderBy('first_name'); } public function scopeWhereRole($query, $role) { switch ($role) { case 'user': return $query->where('owner', false); case 'owner': return $query->where('owner', true); } } public function scopeFilter($query, array $filters) { $query->when($filters['search'] ?? null, function ($query, $search) { $query->where(function ($query) use ($search) { $query->where('first_name', 'like', '%'.$search.'%') ->orWhere('last_name', 'like', '%'.$search.'%') ->orWhere('email', 'like', '%'.$search.'%'); }); })->when($filters['role'] ?? null, function ($query, $role) { $query->whereRole($role); })->when($filters['trashed'] ?? null, function ($query, $trashed) { if ($trashed === 'with') { $query->withTrashed(); } elseif ($trashed === 'only') { $query->onlyTrashed(); } }); } } ================================================ FILE: artisan ================================================ #!/usr/bin/env php make(Illuminate\Contracts\Console\Kernel::class); $status = $kernel->handle( $input = new Symfony\Component\Console\Input\ArgvInput, new Symfony\Component\Console\Output\ConsoleOutput ); /* |-------------------------------------------------------------------------- | Shutdown The Application |-------------------------------------------------------------------------- | | Once Artisan has finished running, we will fire off the shutdown events | so that any final work may be done by the application before we shut | down the process. This is the last thing to happen to the request. | */ $kernel->terminate($input, $status); exit($status); ================================================ FILE: bootstrap/app.php ================================================ singleton( Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class ); $app->singleton( Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class ); $app->singleton( Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class ); /* |-------------------------------------------------------------------------- | Return The Application |-------------------------------------------------------------------------- | | This script returns the application instance. The instance is given to | the calling script so we can separate the building of the instances | from the actual running of the application and sending responses. | */ return $app; ================================================ FILE: bootstrap/cache/.gitignore ================================================ * !.gitignore ================================================ FILE: composer.json ================================================ { "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": [ "framework", "laravel" ], "license": "MIT", "type": "project", "require": { "php": "^7.2", "ext-exif": "*", "ext-gd": "*", "beyondcode/laravel-dump-server": "^1.0", "facade/ignition": "^2.0", "fideloper/proxy": "^4.0", "fzaninotto/faker": "^1.4", "inertiajs/inertia-laravel": "^0.1", "laravel/framework": "^7.0", "laravel/tinker": "^2.0", "league/glide": "2.0.x-dev", "mockery/mockery": "^1.0", "nunomaduro/collision": "^4.1", "phpunit/phpunit": "^8.5", "reinink/remember-query-strings": "^0.1.0", "sentry/sentry-laravel": "^1.5", "tightenco/ziggy": "^0.8.0", "wewowweb/laravel-svelte-preset": "^0.1.4" }, "autoload": { "classmap": [ "database/seeds", "database/factories" ], "psr-4": { "App\\": "app/" } }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "extra": { "laravel": { "dont-discover": [] } }, "scripts": { "compile": [ "npm run prod", "@php artisan migrate:fresh", "@php artisan db:seed" ], "reseed": [ "@php artisan migrate:fresh", "@php artisan db:seed" ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate" ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover" ] }, "config": { "preferred-install": "dist", "sort-packages": true, "optimize-autoloader": true }, "minimum-stability": "dev", "prefer-stable": true } ================================================ FILE: config/app.php ================================================ env('APP_NAME', 'Laravel'), /* |-------------------------------------------------------------------------- | Application Environment |-------------------------------------------------------------------------- | | This value determines the "environment" your application is currently | running in. This may determine how you prefer to configure various | services the application utilizes. Set this in your ".env" file. | */ 'env' => env('APP_ENV', 'production'), /* |-------------------------------------------------------------------------- | Application Debug Mode |-------------------------------------------------------------------------- | | When your application is in debug mode, detailed error messages with | stack traces will be shown on every error that occurs within your | application. If disabled, a simple generic error page is shown. | */ 'debug' => env('APP_DEBUG', false), /* |-------------------------------------------------------------------------- | Application URL |-------------------------------------------------------------------------- | | This URL is used by the console to properly generate URLs when using | the Artisan command line tool. You should set this to the root of | your application so that it is used when running Artisan tasks. | */ 'url' => env('APP_URL', 'http://localhost'), 'asset_url' => env('ASSET_URL', null), /* |-------------------------------------------------------------------------- | Application Timezone |-------------------------------------------------------------------------- | | Here you may specify the default timezone for your application, which | will be used by the PHP date and date-time functions. We have gone | ahead and set this to a sensible default for you out of the box. | */ 'timezone' => 'UTC', /* |-------------------------------------------------------------------------- | Application Locale Configuration |-------------------------------------------------------------------------- | | The application locale determines the default locale that will be used | by the translation service provider. You are free to set this value | to any of the locales which will be supported by the application. | */ 'locale' => 'en', /* |-------------------------------------------------------------------------- | Application Fallback Locale |-------------------------------------------------------------------------- | | The fallback locale determines the locale to use when the current one | is not available. You may change the value to correspond to any of | the language folders that are provided through your application. | */ 'fallback_locale' => 'en', /* |-------------------------------------------------------------------------- | Faker Locale |-------------------------------------------------------------------------- | | This locale will be used by the Faker PHP library when generating fake | data for your database seeds. For example, this will be used to get | localized telephone numbers, street address information and more. | */ 'faker_locale' => 'en_US', /* |-------------------------------------------------------------------------- | Encryption Key |-------------------------------------------------------------------------- | | This key is used by the Illuminate encrypter service and should be set | to a random, 32 character string, otherwise these encrypted strings | will not be safe. Please do this before deploying an application! | */ 'key' => env('APP_KEY'), 'cipher' => 'AES-256-CBC', /* |-------------------------------------------------------------------------- | Autoloaded Service Providers |-------------------------------------------------------------------------- | | The service providers listed here will be automatically loaded on the | request to your application. Feel free to add your own services to | this array to grant expanded functionality to your applications. | */ 'providers' => [ /* * Laravel Framework Service Providers... */ Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, Illuminate\Notifications\NotificationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class, Illuminate\Redis\RedisServiceProvider::class, Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, Illuminate\Session\SessionServiceProvider::class, Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, /* * Package Service Providers... */ /* * Application Service Providers... */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, ], /* |-------------------------------------------------------------------------- | Class Aliases |-------------------------------------------------------------------------- | | This array of class aliases will be registered when this application | is started. However, feel free to register as many as you wish as | the aliases are "lazy" loaded so they don't hinder performance. | */ 'aliases' => [ 'App' => Illuminate\Support\Facades\App::class, 'Arr' => Illuminate\Support\Arr::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 'Bus' => Illuminate\Support\Facades\Bus::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Crypt' => Illuminate\Support\Facades\Crypt::class, 'DB' => Illuminate\Support\Facades\DB::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Event' => Illuminate\Support\Facades\Event::class, 'File' => Illuminate\Support\Facades\File::class, 'Gate' => Illuminate\Support\Facades\Gate::class, 'Hash' => Illuminate\Support\Facades\Hash::class, 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, 'Notification' => Illuminate\Support\Facades\Notification::class, 'Password' => Illuminate\Support\Facades\Password::class, 'Queue' => Illuminate\Support\Facades\Queue::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class, 'Redis' => Illuminate\Support\Facades\Redis::class, 'Request' => Illuminate\Support\Facades\Request::class, 'Response' => Illuminate\Support\Facades\Response::class, 'Route' => Illuminate\Support\Facades\Route::class, 'Schema' => Illuminate\Support\Facades\Schema::class, 'Session' => Illuminate\Support\Facades\Session::class, 'Storage' => Illuminate\Support\Facades\Storage::class, 'Str' => Illuminate\Support\Str::class, 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, ], ]; ================================================ FILE: config/auth.php ================================================ [ 'guard' => 'web', 'passwords' => 'users', ], /* |-------------------------------------------------------------------------- | Authentication Guards |-------------------------------------------------------------------------- | | Next, you may define every authentication guard for your application. | Of course, a great default configuration has been defined for you | here which uses session storage and the Eloquent user provider. | | All authentication drivers have a user provider. This defines how the | users are actually retrieved out of your database or other storage | mechanisms used by this application to persist your user's data. | | Supported: "session", "token" | */ 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'api' => [ 'driver' => 'token', 'provider' => 'users', 'hash' => false, ], ], /* |-------------------------------------------------------------------------- | User Providers |-------------------------------------------------------------------------- | | All authentication drivers have a user provider. This defines how the | users are actually retrieved out of your database or other storage | mechanisms used by this application to persist your user's data. | | If you have multiple user tables or models you may configure multiple | sources which represent each model / table. These sources may then | be assigned to any extra authentication guards you have defined. | | Supported: "database", "eloquent" | */ 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\User::class, ], // 'users' => [ // 'driver' => 'database', // 'table' => 'users', // ], ], /* |-------------------------------------------------------------------------- | Resetting Passwords |-------------------------------------------------------------------------- | | You may specify multiple password reset configurations if you have more | than one user table or model in the application and you want to have | separate password reset settings based on the specific user types. | | The expire time is the number of minutes that the reset token should be | considered valid. This security feature keeps tokens short-lived so | they have less time to be guessed. You may change this as needed. | */ 'passwords' => [ 'users' => [ 'provider' => 'users', 'table' => 'password_resets', 'expire' => 60, 'throttle' => 60, ], ], /* |-------------------------------------------------------------------------- | Password Confirmation Timeout |-------------------------------------------------------------------------- | | Here you may define the amount of seconds before a password confirmation | times out and the user is prompted to re-enter their password via the | confirmation screen. By default, the timeout lasts for three hours. | */ 'password_timeout' => 10800, ]; ================================================ FILE: config/broadcasting.php ================================================ env('BROADCAST_DRIVER', 'null'), /* |-------------------------------------------------------------------------- | Broadcast Connections |-------------------------------------------------------------------------- | | Here you may define all of the broadcast connections that will be used | to broadcast events to other systems or over websockets. Samples of | each available type of connection are provided inside this array. | */ 'connections' => [ 'pusher' => [ 'driver' => 'pusher', 'key' => env('PUSHER_APP_KEY'), 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ 'cluster' => env('PUSHER_APP_CLUSTER'), 'useTLS' => true, ], ], 'redis' => [ 'driver' => 'redis', 'connection' => 'default', ], 'log' => [ 'driver' => 'log', ], 'null' => [ 'driver' => 'null', ], ], ]; ================================================ FILE: config/cache.php ================================================ env('CACHE_DRIVER', 'file'), /* |-------------------------------------------------------------------------- | Cache Stores |-------------------------------------------------------------------------- | | Here you may define all of the cache "stores" for your application as | well as their drivers. You may even define multiple stores for the | same cache driver to group types of items stored in your caches. | */ 'stores' => [ 'apc' => [ 'driver' => 'apc', ], 'array' => [ 'driver' => 'array', ], 'database' => [ 'driver' => 'database', 'table' => 'cache', 'connection' => null, ], 'file' => [ 'driver' => 'file', 'path' => storage_path('framework/cache/data'), ], 'memcached' => [ 'driver' => 'memcached', 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 'sasl' => [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], 'options' => [ // Memcached::OPT_CONNECT_TIMEOUT => 2000, ], 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 'port' => env('MEMCACHED_PORT', 11211), 'weight' => 100, ], ], ], 'redis' => [ 'driver' => 'redis', 'connection' => 'cache', ], 'dynamodb' => [ 'driver' => 'dynamodb', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 'endpoint' => env('DYNAMODB_ENDPOINT'), ], ], /* |-------------------------------------------------------------------------- | Cache Key Prefix |-------------------------------------------------------------------------- | | When utilizing a RAM based store such as APC or Memcached, there might | be other applications utilizing the same cache. So, we'll specify a | value to get prefixed to all our keys so we can avoid collisions. | */ 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), ]; ================================================ FILE: config/database.php ================================================ env('DB_CONNECTION', 'mysql'), /* |-------------------------------------------------------------------------- | Database Connections |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | | All database work in Laravel is done through the PHP PDO facilities | so make sure you have the driver for your particular database of | choice installed on your machine before you begin development. | */ 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'url' => env('DATABASE_URL'), 'database' => env('DB_DATABASE', database_path('database.sqlite')), 'prefix' => '', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), ], 'mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], 'pgsql' => [ 'driver' => 'pgsql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '5432'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, 'schema' => 'public', 'sslmode' => 'prefer', ], 'sqlsrv' => [ 'driver' => 'sqlsrv', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '1433'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, ], ], /* |-------------------------------------------------------------------------- | Migration Repository Table |-------------------------------------------------------------------------- | | This table keeps track of all the migrations that have already run for | your application. Using this information, we can determine which of | the migrations on disk haven't actually been run in the database. | */ 'migrations' => 'migrations', /* |-------------------------------------------------------------------------- | Redis Databases |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also | provides a richer body of commands than a typical key-value system | such as APC or Memcached. Laravel makes it easy to dig right in. | */ 'redis' => [ 'client' => env('REDIS_CLIENT', 'phpredis'), 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), ], 'default' => [ 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), 'database' => env('REDIS_DB', 0), ], 'cache' => [ 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), 'database' => env('REDIS_CACHE_DB', 1), ], ], ]; ================================================ FILE: config/filesystems.php ================================================ env('FILESYSTEM_DRIVER', 'local'), /* |-------------------------------------------------------------------------- | Default Cloud Filesystem Disk |-------------------------------------------------------------------------- | | Many applications store files both locally and in the cloud. For this | reason, you may specify a default "cloud" driver here. This driver | will be bound as the Cloud disk implementation in the container. | */ 'cloud' => env('FILESYSTEM_CLOUD', 's3'), /* |-------------------------------------------------------------------------- | Filesystem Disks |-------------------------------------------------------------------------- | | Here you may configure as many filesystem "disks" as you wish, and you | may even configure multiple disks of the same driver. Defaults have | been setup for each driver as an example of the required options. | | Supported Drivers: "local", "ftp", "sftp", "s3" | */ 'disks' => [ 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), ], 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), 'url' => env('APP_URL').'/storage', 'visibility' => 'public', ], 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION'), 'bucket' => env('AWS_BUCKET'), 'url' => env('AWS_URL'), ], ], ]; ================================================ FILE: config/hashing.php ================================================ 'bcrypt', /* |-------------------------------------------------------------------------- | Bcrypt Options |-------------------------------------------------------------------------- | | Here you may specify the configuration options that should be used when | passwords are hashed using the Bcrypt algorithm. This will allow you | to control the amount of time it takes to hash the given password. | */ 'bcrypt' => [ 'rounds' => env('BCRYPT_ROUNDS', 10), ], /* |-------------------------------------------------------------------------- | Argon Options |-------------------------------------------------------------------------- | | Here you may specify the configuration options that should be used when | passwords are hashed using the Argon algorithm. These will allow you | to control the amount of time it takes to hash the given password. | */ 'argon' => [ 'memory' => 1024, 'threads' => 2, 'time' => 2, ], ]; ================================================ FILE: config/logging.php ================================================ env('LOG_CHANNEL', 'stack'), /* |-------------------------------------------------------------------------- | Log Channels |-------------------------------------------------------------------------- | | Here you may configure the log channels for your application. Out of | the box, Laravel uses the Monolog PHP logging library. This gives | you a variety of powerful log handlers / formatters to utilize. | | Available Drivers: "single", "daily", "slack", "syslog", | "errorlog", "monolog", | "custom", "stack" | */ 'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['single'], 'ignore_exceptions' => false, ], 'single' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => 'debug', ], 'daily' => [ 'driver' => 'daily', 'path' => storage_path('logs/laravel.log'), 'level' => 'debug', 'days' => 14, ], 'slack' => [ 'driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Laravel Log', 'emoji' => ':boom:', 'level' => 'critical', ], 'papertrail' => [ 'driver' => 'monolog', 'level' => 'debug', 'handler' => SyslogUdpHandler::class, 'handler_with' => [ 'host' => env('PAPERTRAIL_URL'), 'port' => env('PAPERTRAIL_PORT'), ], ], 'stderr' => [ 'driver' => 'monolog', 'handler' => StreamHandler::class, 'formatter' => env('LOG_STDERR_FORMATTER'), 'with' => [ 'stream' => 'php://stderr', ], ], 'syslog' => [ 'driver' => 'syslog', 'level' => 'debug', ], 'errorlog' => [ 'driver' => 'errorlog', 'level' => 'debug', ], 'null' => [ 'driver' => 'monolog', 'handler' => NullHandler::class, ], 'emergency' => [ 'path' => storage_path('logs/laravel.log'), ], ], ]; ================================================ FILE: config/mail.php ================================================ env('MAIL_DRIVER', 'smtp'), /* |-------------------------------------------------------------------------- | SMTP Host Address |-------------------------------------------------------------------------- | | Here you may provide the host address of the SMTP server used by your | applications. A default option is provided that is compatible with | the Mailgun mail service which will provide reliable deliveries. | */ 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), /* |-------------------------------------------------------------------------- | SMTP Host Port |-------------------------------------------------------------------------- | | This is the SMTP port used by your application to deliver e-mails to | users of the application. Like the host we have set this value to | stay compatible with the Mailgun e-mail application by default. | */ 'port' => env('MAIL_PORT', 587), /* |-------------------------------------------------------------------------- | Global "From" Address |-------------------------------------------------------------------------- | | You may wish for all e-mails sent by your application to be sent from | the same address. Here, you may specify a name and address that is | used globally for all e-mails that are sent by your application. | */ 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 'name' => env('MAIL_FROM_NAME', 'Example'), ], /* |-------------------------------------------------------------------------- | E-Mail Encryption Protocol |-------------------------------------------------------------------------- | | Here you may specify the encryption protocol that should be used when | the application send e-mail messages. A sensible default using the | transport layer security protocol should provide great security. | */ 'encryption' => env('MAIL_ENCRYPTION', 'tls'), /* |-------------------------------------------------------------------------- | SMTP Server Username |-------------------------------------------------------------------------- | | If your SMTP server requires a username for authentication, you should | set it here. This will get used to authenticate with your server on | connection. You may also set the "password" value below this one. | */ 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), /* |-------------------------------------------------------------------------- | Sendmail System Path |-------------------------------------------------------------------------- | | When using the "sendmail" driver to send e-mails, we will need to know | the path to where Sendmail lives on this server. A default path has | been provided here, which will work well on most of your systems. | */ 'sendmail' => '/usr/sbin/sendmail -bs', /* |-------------------------------------------------------------------------- | Markdown Mail Settings |-------------------------------------------------------------------------- | | If you are using Markdown based email rendering, you may configure your | theme and component paths here, allowing you to customize the design | of the emails. Or, you may simply stick with the Laravel defaults! | */ 'markdown' => [ 'theme' => 'default', 'paths' => [ resource_path('views/vendor/mail'), ], ], /* |-------------------------------------------------------------------------- | Log Channel |-------------------------------------------------------------------------- | | If you are using the "log" driver, you may specify the logging channel | if you prefer to keep mail messages separate from other log entries | for simpler reading. Otherwise, the default channel will be used. | */ 'log_channel' => env('MAIL_LOG_CHANNEL'), ]; ================================================ FILE: config/queue.php ================================================ env('QUEUE_CONNECTION', 'sync'), /* |-------------------------------------------------------------------------- | Queue Connections |-------------------------------------------------------------------------- | | Here you may configure the connection information for each server that | is used by your application. A default configuration has been added | for each back-end shipped with Laravel. You are free to add more. | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" | */ 'connections' => [ 'sync' => [ 'driver' => 'sync', ], 'database' => [ 'driver' => 'database', 'table' => 'jobs', 'queue' => 'default', 'retry_after' => 90, ], 'beanstalkd' => [ 'driver' => 'beanstalkd', 'host' => 'localhost', 'queue' => 'default', 'retry_after' => 90, 'block_for' => 0, ], 'sqs' => [ 'driver' => 'sqs', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 'queue' => env('SQS_QUEUE', 'your-queue-name'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], 'redis' => [ 'driver' => 'redis', 'connection' => 'default', 'queue' => env('REDIS_QUEUE', 'default'), 'retry_after' => 90, 'block_for' => null, ], ], /* |-------------------------------------------------------------------------- | Failed Queue Jobs |-------------------------------------------------------------------------- | | These options configure the behavior of failed queue job logging so you | can control which database and table are used to store the jobs that | have failed. You may change them to any database / table you wish. | */ 'failed' => [ 'driver' => env('QUEUE_FAILED_DRIVER', 'database'), 'database' => env('DB_CONNECTION', 'mysql'), 'table' => 'failed_jobs', ], ]; ================================================ FILE: config/sentry.php ================================================ env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), // capture release as git sha // 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')), 'breadcrumbs' => [ // Capture Laravel logs in breadcrumbs 'logs' => true, // Capture SQL queries in breadcrumbs 'sql_queries' => true, // Capture bindings on SQL queries logged in breadcrumbs 'sql_bindings' => true, // Capture queue job information in breadcrumbs 'queue_info' => true, ], ]; ================================================ FILE: config/services.php ================================================ [ 'domain' => env('MAILGUN_DOMAIN'), 'secret' => env('MAILGUN_SECRET'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), ], 'postmark' => [ 'token' => env('POSTMARK_TOKEN'), ], 'ses' => [ 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], ]; ================================================ FILE: config/session.php ================================================ env('SESSION_DRIVER', 'cookie'), /* |-------------------------------------------------------------------------- | Session Lifetime |-------------------------------------------------------------------------- | | Here you may specify the number of minutes that you wish the session | to be allowed to remain idle before it expires. If you want them | to immediately expire on the browser closing, set that option. | */ 'lifetime' => env('SESSION_LIFETIME', 120), 'expire_on_close' => false, /* |-------------------------------------------------------------------------- | Session Encryption |-------------------------------------------------------------------------- | | This option allows you to easily specify that all of your session data | should be encrypted before it is stored. All encryption will be run | automatically by Laravel and you can use the Session like normal. | */ 'encrypt' => false, /* |-------------------------------------------------------------------------- | Session File Location |-------------------------------------------------------------------------- | | When using the native session driver, we need a location where session | files may be stored. A default has been set for you but a different | location may be specified. This is only needed for file sessions. | */ 'files' => storage_path('framework/sessions'), /* |-------------------------------------------------------------------------- | Session Database Connection |-------------------------------------------------------------------------- | | When using the "database" or "redis" session drivers, you may specify a | connection that should be used to manage these sessions. This should | correspond to a connection in your database configuration options. | */ 'connection' => env('SESSION_CONNECTION', null), /* |-------------------------------------------------------------------------- | Session Database Table |-------------------------------------------------------------------------- | | When using the "database" session driver, you may specify the table we | should use to manage the sessions. Of course, a sensible default is | provided for you; however, you are free to change this as needed. | */ 'table' => 'sessions', /* |-------------------------------------------------------------------------- | Session Cache Store |-------------------------------------------------------------------------- | | When using the "apc", "memcached", or "dynamodb" session drivers you may | list a cache store that should be used for these sessions. This value | must match with one of the application's configured cache "stores". | */ 'store' => env('SESSION_STORE', null), /* |-------------------------------------------------------------------------- | Session Sweeping Lottery |-------------------------------------------------------------------------- | | Some session drivers must manually sweep their storage location to get | rid of old sessions from storage. Here are the chances that it will | happen on a given request. By default, the odds are 2 out of 100. | */ 'lottery' => [2, 100], /* |-------------------------------------------------------------------------- | Session Cookie Name |-------------------------------------------------------------------------- | | Here you may change the name of the cookie used to identify a session | instance by ID. The name specified here will get used every time a | new session cookie is created by the framework for every driver. | */ 'cookie' => env( 'SESSION_COOKIE', Str::slug(env('APP_NAME', 'laravel'), '_').'_session' ), /* |-------------------------------------------------------------------------- | Session Cookie Path |-------------------------------------------------------------------------- | | The session cookie path determines the path for which the cookie will | be regarded as available. Typically, this will be the root path of | your application but you are free to change this when necessary. | */ 'path' => '/', /* |-------------------------------------------------------------------------- | Session Cookie Domain |-------------------------------------------------------------------------- | | Here you may change the domain of the cookie used to identify a session | in your application. This will determine which domains the cookie is | available to in your application. A sensible default has been set. | */ 'domain' => env('SESSION_DOMAIN', null), /* |-------------------------------------------------------------------------- | HTTPS Only Cookies |-------------------------------------------------------------------------- | | By setting this option to true, session cookies will only be sent back | to the server if the browser has a HTTPS connection. This will keep | the cookie from being sent to you if it can not be done securely. | */ 'secure' => env('SESSION_SECURE_COOKIE', null), /* |-------------------------------------------------------------------------- | HTTP Access Only |-------------------------------------------------------------------------- | | Setting this value to true will prevent JavaScript from accessing the | value of the cookie and the cookie will only be accessible through | the HTTP protocol. You are free to modify this option if needed. | */ 'http_only' => true, /* |-------------------------------------------------------------------------- | Same-Site Cookies |-------------------------------------------------------------------------- | | This option determines how your cookies behave when cross-site requests | take place, and can be used to mitigate CSRF attacks. By default, we | do not enable this as other CSRF protection services are in place. | | Supported: "lax", "strict", "none" | */ 'same_site' => null, ]; ================================================ FILE: config/view.php ================================================ [ resource_path('views'), ], /* |-------------------------------------------------------------------------- | Compiled View Path |-------------------------------------------------------------------------- | | This option determines where all the compiled Blade templates will be | stored for your application. Typically, this is within the storage | directory. However, as usual, you are free to change this value. | */ 'compiled' => env( 'VIEW_COMPILED_PATH', realpath(storage_path('framework/views')) ), ]; ================================================ FILE: database/.gitignore ================================================ *.sqlite ================================================ FILE: database/factories/ContactFactory.php ================================================ define(App\Contact::class, function (Faker $faker) { return [ 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => $faker->unique()->safeEmail, 'phone' => $faker->tollFreePhoneNumber, 'address' => $faker->streetAddress, 'city' => $faker->city, 'region' => $faker->state, 'country' => 'US', 'postal_code' => $faker->postcode, ]; }); ================================================ FILE: database/factories/OrganizationFactory.php ================================================ define(App\Organization::class, function (Faker $faker) { return [ 'name' => $faker->company, 'email' => $faker->companyEmail, 'phone' => $faker->tollFreePhoneNumber, 'address' => $faker->streetAddress, 'city' => $faker->city, 'region' => $faker->state, 'country' => 'US', 'postal_code' => $faker->postcode, ]; }); ================================================ FILE: database/factories/UserFactory.php ================================================ define(App\User::class, function (Faker $faker) { return [ 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => $faker->unique()->safeEmail, 'password' => 'secret', 'remember_token' => Str::random(10), 'owner' => false, ]; }); ================================================ FILE: database/migrations/2019_03_05_000000_create_accounts_table.php ================================================ increments('id'); $table->string('name', 50); $table->timestamps(); }); } } ================================================ FILE: database/migrations/2019_03_05_000000_create_contacts_table.php ================================================ increments('id'); $table->integer('account_id')->index(); $table->integer('organization_id')->nullable()->index(); $table->string('first_name', 25); $table->string('last_name', 25); $table->string('email', 50)->nullable(); $table->string('phone', 50)->nullable(); $table->string('address', 150)->nullable(); $table->string('city', 50)->nullable(); $table->string('region', 50)->nullable(); $table->string('country', 2)->nullable(); $table->string('postal_code', 25)->nullable(); $table->timestamps(); $table->softDeletes(); }); } } ================================================ FILE: database/migrations/2019_03_05_000000_create_organizations_table.php ================================================ increments('id'); $table->integer('account_id')->index(); $table->string('name', 100); $table->string('email', 50)->nullable(); $table->string('phone', 50)->nullable(); $table->string('address', 150)->nullable(); $table->string('city', 50)->nullable(); $table->string('region', 50)->nullable(); $table->string('country', 2)->nullable(); $table->string('postal_code', 25)->nullable(); $table->timestamps(); $table->softDeletes(); }); } } ================================================ FILE: database/migrations/2019_03_05_000000_create_password_resets_table.php ================================================ string('email')->index(); $table->string('token'); $table->timestamp('created_at')->nullable(); }); } } ================================================ FILE: database/migrations/2019_03_05_000000_create_users_table.php ================================================ increments('id'); $table->integer('account_id')->index(); $table->string('first_name', 25); $table->string('last_name', 25); $table->string('email', 50)->unique(); $table->string('password')->nullable(); $table->boolean('owner')->default(false); $table->string('photo_path', 100)->nullable(); $table->rememberToken(); $table->timestamps(); $table->softDeletes(); }); } } ================================================ FILE: database/seeds/DatabaseSeeder.php ================================================ 'Acme Corporation']); factory(User::class)->create([ 'account_id' => $account->id, 'first_name' => 'John', 'last_name' => 'Doe', 'email' => 'johndoe@example.com', 'owner' => true, ]); factory(User::class, 5)->create(['account_id' => $account->id]); $organizations = factory(Organization::class, 100) ->create(['account_id' => $account->id]); factory(Contact::class, 100) ->create(['account_id' => $account->id]) ->each(function ($contact) use ($organizations) { $contact->update(['organization_id' => $organizations->random()->id]); }); } } ================================================ FILE: jsconfig.json ================================================ { "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["./resources/js/*"] } } } ================================================ FILE: package.json ================================================ { "private": true, "scripts": { "dev": "npm run development", "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "watch": "npm run development -- --watch", "watch-poll": "npm run watch -- --watch-poll", "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", "prod": "npm run production", "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" }, "dependencies": { "@fullhuman/postcss-purgecss": "^1.3.0", "@inertiajs/inertia": "^0.1.7", "@inertiajs/inertia-svelte": "^0.1.0", "@sentry/browser": "^5.15.0", "axios": "^0.19.2", "classnames": "^2.2.6", "cross-env": "^6.0.3", "eslint": "^6.8.0", "laravel-mix": "^5.0.4", "laravel-mix-svelte": "^0.1.3", "lodash": "^4.17.15", "postcss-import": "^12.0.1", "postcss-nesting": "^7.0.1", "resolve-url-loader": "^3.1.1", "tailwindcss": "^1.2.0" }, "devDependencies": { "babel-eslint": "^10.1.0", "eslint-plugin-svelte3": "^2.7.3", "svelte": "^3.20.1", "svelte-loader": "^2.13.6", "vue-template-compiler": "^2.6.11" } } ================================================ FILE: phpunit.xml ================================================ ./tests/Unit ./tests/Feature ./app ================================================ FILE: public/.htaccess ================================================ Options -MultiViews -Indexes RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] ================================================ FILE: public/index.php ================================================ */ define('LARAVEL_START', microtime(true)); /* |-------------------------------------------------------------------------- | Register The Auto Loader |-------------------------------------------------------------------------- | | Composer provides a convenient, automatically generated class loader for | our application. We just need to utilize it! We'll simply require it | into the script here so that we don't have to worry about manual | loading any of our classes later on. It feels great to relax. | */ require __DIR__.'/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- | Turn On The Lights |-------------------------------------------------------------------------- | | We need to illuminate PHP development, so let us turn on the lights. | This bootstraps the framework and gets it ready for use, then it | will load up this application so that we can run it and send | the responses back to the browser and delight our users. | */ $app = require_once __DIR__.'/../bootstrap/app.php'; /* |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | | Once we have the application, we can handle the incoming request | through the kernel, and send the associated response back to | the client's browser allowing them to enjoy the creative | and wonderful application we have prepared for them. | */ $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); $response = $kernel->handle( $request = Illuminate\Http\Request::capture() ); $response->send(); $kernel->terminate($request, $response); ================================================ FILE: public/robots.txt ================================================ User-agent: * Disallow: ================================================ FILE: public/web.config ================================================ ================================================ FILE: readme.md ================================================ # Ping CRM Svelte A demo application to illustrate how [Inertia.js](https://inertiajs.com/) works with [Laravel](https://laravel.com/) and [Svelte](https://svelte.dev/). > This is a port of the original [Ping CRM](https://github.com/inertiajs/pingcrm) written in Laravel and Vue. ![](https://raw.githubusercontent.com/zgabievi/pingcrm-svelte/master/screenshot.png) ## Installation Clone the repo locally: ```sh git clone https://github.com/zgabievi/pingcrm-svelte.git cd pingcrm-svelte ``` Install PHP dependencies: ```sh composer install ``` Install NPM dependencies: ```sh npm install ``` Build assets: ```sh npm run dev ``` Setup configuration: ```sh cp .env.example .env ``` Generate application key: ```sh php artisan key:generate ``` Create an SQLite database. You can also use another database (MySQL, Postgres), simply update your configuration accordingly. ```sh touch database/database.sqlite ``` Run database migrations: ```sh php artisan migrate ``` Run database seeder: ```sh php artisan db:seed ``` Run artisan server: ```sh php artisan serve ``` You're ready to go! [Visit Ping CRM](http://127.0.0.1:8000/) in your browser, and login with: - **Username:** johndoe@example.com - **Password:** secret ## Running tests To run the Ping CRM tests, run: ``` phpunit ``` ## Credits - Original work by Jonathan Reinink (@reinink) and contributors - Port to Ruby on Rails by Georg Ledermann (@ledermann) - Port to React by Lado Lomidze (@landish) - Port to Svelte by Zura Gabievi (@zgabievi) ================================================ FILE: resources/css/app.css ================================================ /* Reset */ @import 'reset'; @import 'tailwindcss/base'; @import 'tailwindcss/components'; /* Components */ @import 'buttons'; @import 'form'; @import 'nprogress'; /* Utilities */ @import 'tailwindcss/utilities'; ================================================ FILE: resources/css/buttons.css ================================================ .btn-indigo { @apply px-6 py-3 rounded bg-indigo-700 text-white text-sm font-bold whitespace-no-wrap; &:hover, &:focus { @apply bg-orange-500; } } .btn-spinner, .btn-spinner:after { border-radius: 50%; width: 1.5em; height: 1.5em; } .btn-spinner { font-size: 10px; position: relative; text-indent: -9999em; border-top: 0.2em solid white; border-right: 0.2em solid white; border-bottom: 0.2em solid white; border-left: 0.2em solid transparent; transform: translateZ(0); animation: spinning 1s infinite linear; } @keyframes spinning { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } ================================================ FILE: resources/css/form.css ================================================ .form-label { @apply .mb-2 .block .text-gray-800 .select-none; } .form-input, .form-textarea, .form-select { @apply .p-2 .leading-normal .block .w-full .border .text-gray-800 .bg-white .font-sans .rounded .text-left .appearance-none .relative; &:focus-within, &:focus, &.focus { @apply .border-indigo-500; box-shadow: 0 0 0 1px theme('colors.indigo.500'); } &::placeholder { @apply .text-gray-600 .opacity-100; } } .form-select { @apply .pr-6; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAABGdBTUEAALGPC/xhBQAAAQtJREFUOBG1lEEOgjAQRalbGj2OG9caOACn4ALGtfEuHACiazceR1PWOH/CNA3aMiTaBDpt/7zPdBKy7M/DCL9pGkvxxVp7KsvyJftL5rZt1865M+Ucq6pyyF3hNcI7Cuu+728QYn/JQA5yKaempxuZmQngOwEaYx55nu+1lQh8GIatMGi+01NwBcEmhxBqK4nAPZJ78K0KKFAJmR3oPp8+Iwgob0Oa6+TLoeCvRx+mTUYf/FVBGTPRwDkfLxnaSrRwcH0FWhNOmrkWYbE2XEicqgSa1J0LQ+aPCuQgZiLnwewbGuz5MGoAhcIkCQcjaTBjMgtXGURMVHC1wcQEy0J+Zlj8bKAnY1/UzDe2dbAVqfXn6wAAAABJRU5ErkJggg=='); background-size: 0.7rem; background-repeat: no-repeat; background-position: right 0.7rem center; &::-ms-expand { @apply .opacity-0; } } .form-error { @apply .text-red-500 .mt-2 .text-sm; } .form-input.error, .form-textarea.error, .form-select.error { @apply .border-red-400; &:focus { box-shadow: 0 0 0 1px theme('colors.red.400'); } } ================================================ FILE: resources/css/nprogress.css ================================================ /* Make clicks pass-through */ #nprogress { pointer-events: none; } #nprogress .bar { background: theme('colors.indigo.500'); position: fixed; z-index: 1031; top: 0; left: 0; width: 100%; height: 2px; } /* Fancy blur effect */ #nprogress .peg { display: block; position: absolute; right: 0px; width: 100px; height: 100%; box-shadow: 0 0 10px theme('colors.indigo.500'), 0 0 5px theme('colors.indigo.500'); opacity: 1; -webkit-transform: rotate(3deg) translate(0px, -4px); -ms-transform: rotate(3deg) translate(0px, -4px); transform: rotate(3deg) translate(0px, -4px); } /* Remove these to get rid of the spinner */ #nprogress .spinner { display: block; position: fixed; z-index: 1031; top: 15px; right: 15px; } #nprogress .spinner-icon { width: 18px; height: 18px; box-sizing: border-box; border: solid 2px transparent; border-top-color: theme('colors.indigo.500'); border-left-color: theme('colors.indigo.500'); border-radius: 50%; -webkit-animation: nprogress-spinner 400ms linear infinite; animation: nprogress-spinner 400ms linear infinite; } .nprogress-custom-parent { overflow: hidden; position: relative; } .nprogress-custom-parent #nprogress .spinner, .nprogress-custom-parent #nprogress .bar { position: absolute; } @-webkit-keyframes nprogress-spinner { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); } } @keyframes nprogress-spinner { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } ================================================ FILE: resources/css/reset.css ================================================ html { line-height: 1.15; } input, select, textarea, button, div, a { &:focus, &:active { outline: none; } } ================================================ FILE: resources/js/Pages/Auth/Login.svelte ================================================

Welcome Back!

================================================ FILE: resources/js/Pages/Contacts/Create.svelte ================================================

Contacts / Create

{#each organizations as {id, name} (id)} {/each}
Create Contact
================================================ FILE: resources/js/Pages/Contacts/Edit.svelte ================================================

Contacts / {values.first_name} {values.last_name}

{#if contact.deleted_at} This contact has been deleted. {/if}
{#each organizations as { id, name } (id)} {/each}
{#if !contact.deleted_at} Delete Contact {/if} Update Contact
================================================ FILE: resources/js/Pages/Contacts/Index.svelte ================================================

Contacts

Create
{#if !data || data.length === 0} {:else} {#each data as { id, name, city, phone, organization, deleted_at } (id)} {/each} {/if}
Name Organization City Phone
No contacts found.
{name} {#if deleted_at} {/if} {organization && organization.name} {city} {phone}
================================================ FILE: resources/js/Pages/Dashboard/Index.svelte ================================================

Dashboard

Hey there! Welcome to Ping CRM, a demo app designed to help illustrate how Inertia.js works with Svelte .

500 error 404 error
================================================ FILE: resources/js/Pages/Error.svelte ================================================

{title}

{description}

================================================ FILE: resources/js/Pages/Organizations/Create.svelte ================================================

Organizations / Create

Create Organization
================================================ FILE: resources/js/Pages/Organizations/Edit.svelte ================================================

Organizations / {values.name}

{#if organization.deleted_at} This organization has been deleted. {/if}
{#if !organization.deleted_at} Delete Organization {/if} Update Organization

Contacts

{#if !organization.contacts || organization.contacts.length === 0} {:else} {#each organization.contacts as { id, name, phone, city, deleted_at } (id)} {/each} {/if}
Name City Phone
No contacts found.
{name} {#if deleted_at} {/if} {city} {phone}
================================================ FILE: resources/js/Pages/Organizations/Index.svelte ================================================

Organizations

Create
{#if !data || data.length === 0} {:else} {#each data as { id, name, city, phone, deleted_at } (id)} {/each} {/if}
Name City Phone
No organizations found.
{name} {#if deleted_at} {/if} {city} {phone}
================================================ FILE: resources/js/Pages/Reports/Index.svelte ================================================

Reports

================================================ FILE: resources/js/Pages/Users/Create.svelte ================================================

Users / Create

Create User
================================================ FILE: resources/js/Pages/Users/Edit.svelte ================================================

Users / {values.first_name} {values.last_name}

{#if user.photo} {user.name} {/if}
{#if user.deleted_at} This contact has been deleted. {/if}
{#if !user.deleted_at} Delete User {/if} Update User
================================================ FILE: resources/js/Pages/Users/Index.svelte ================================================

Users

Create
{#if !data || data.length === 0} {:else} {#each data as { id, name, photo, email, owner, deleted_at } (id)} {/each} {/if}
Name Email Role
No users found.
{#if photo} {name} {/if} {name} {#if deleted_at} {/if} {email} {owner ? 'Owner' : 'User'}
================================================ FILE: resources/js/Shared/BottomHeader.svelte ================================================
{auth.user.account.name}
menuOpened = true} >
{auth.user.first_name}
My Profile Manage Users Logout
menuOpened = false} class="bg-black opacity-25 fixed inset-0 z-10" />
================================================ FILE: resources/js/Shared/DeleteButton.svelte ================================================ ================================================ FILE: resources/js/Shared/FileInput.svelte ================================================
{#if label} {/if}
{#if file}
{file.name} ({filesize(file.size)})
{:else}
{/if}
{#if errors && errors.length > 0}
{errors[0]}
{/if}
================================================ FILE: resources/js/Shared/FlashMessages.svelte ================================================
{#if flash.success && visible}
{flash.success}
{/if} {#if (flash.error || numOfErrors > 0) && visible}
{flash.error && flash.error} {numOfErrors === 1 && 'There is one form error'} {numOfErrors > 1 && `There are ${numOfErrors} form errors.`}
{/if}
================================================ FILE: resources/js/Shared/Helmet.svelte ================================================ {title ? `${title} | Ping CRM` : 'Ping CRM'} ================================================ FILE: resources/js/Shared/Icon.svelte ================================================ {#if name === 'apple'} {:else if name === 'book'} {:else if name === 'cheveron-down'} {:else if name === 'cheveron-right'} {:else if name === 'dashboard'} {:else if name === 'location'} {:else if name === 'office'} {:else if name === 'printer'} {:else if name === 'shopping-cart'} {:else if name === 'store-front'} {:else if name === 'trash'} {:else if name === 'users'} {/if} ================================================ FILE: resources/js/Shared/Layout.svelte ================================================
================================================ FILE: resources/js/Shared/LoadingButton.svelte ================================================ ================================================ FILE: resources/js/Shared/Logo.svelte ================================================ ================================================ FILE: resources/js/Shared/MainMenu.svelte ================================================
================================================ FILE: resources/js/Shared/MainMenuItem.svelte ================================================
{text}
================================================ FILE: resources/js/Shared/Pagination.svelte ================================================ {#if links && links.length !== 3}
{#each links as { active, label, url } (label)} {#if url === null}
{label}
{:else} {label} {/if} {/each}
{/if} ================================================ FILE: resources/js/Shared/SearchFilter.svelte ================================================
opened = false} class="bg-black opacity-25 fixed inset-0 z-20" />
{#if filters.hasOwnProperty('role')} {/if}
================================================ FILE: resources/js/Shared/SelectInput.svelte ================================================
{#if label} {/if} {#if errors && errors.length}
{errors[0]}
{/if}
================================================ FILE: resources/js/Shared/TextInput.svelte ================================================
{#if label} {/if} {#if errors && errors.length}
{errors[0]}
{/if}
================================================ FILE: resources/js/Shared/TopHeader.svelte ================================================
menuOpened = true} class="fill-current text-white w-6 h-6 cursor-pointer" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" >
menuOpened = false} class="bg-black opacity-25 fixed inset-0 z-10" />
================================================ FILE: resources/js/Shared/TrashedMessage.svelte ================================================
================================================ FILE: resources/js/app.js ================================================ import { InertiaApp } from '@inertiajs/inertia-svelte'; import * as Sentry from '@sentry/browser'; Sentry.init({ dsn: process.env.MIX_SENTRY_LARAVEL_DSN }); const app = document.getElementById('app'); new InertiaApp({ target: app, props: { initialPage: JSON.parse(app.dataset.page), resolveComponent: name => import(`./Pages/${name}.svelte`).then(module => module.default) } }); ================================================ FILE: resources/js/utils.js ================================================ export function filesize(size) { const i = Math.floor(Math.log(size) / Math.log(1024)); return ( (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i] ); } // Transforms key/value pairs to FormData() object export function toFormData(values = {}, method = 'POST') { const formData = new FormData(); for (const field of Object.keys(values)) { formData.append(field, values[field]); } // NOTE: When working with Laravel PUT/PATCH requests and FormData // you SHOULD send POST request and fake the PUT request like this. // More info: http://stackoverflow.com/q/50691938 if (method.toUpperCase() === 'PUT') { formData.append('_method', 'PUT'); } return formData; } ================================================ FILE: resources/lang/en/auth.php ================================================ 'These credentials do not match our records.', 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', ]; ================================================ FILE: resources/lang/en/pagination.php ================================================ '« Previous', 'next' => 'Next »', ]; ================================================ FILE: resources/lang/en/passwords.php ================================================ 'Passwords must be at least eight characters and match the confirmation.', 'reset' => 'Your password has been reset!', 'sent' => 'We have e-mailed your password reset link!', 'token' => 'This password reset token is invalid.', 'user' => "We can't find a user with that e-mail address.", ]; ================================================ FILE: resources/lang/en/validation.php ================================================ 'The :attribute must be accepted.', 'active_url' => 'The :attribute is not a valid URL.', 'after' => 'The :attribute must be a date after :date.', 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 'alpha' => 'The :attribute may only contain letters.', 'alpha_dash' => 'The :attribute may only contain letters, numbers, dashes and underscores.', 'alpha_num' => 'The :attribute may only contain letters and numbers.', 'array' => 'The :attribute must be an array.', 'before' => 'The :attribute must be a date before :date.', 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 'between' => [ 'numeric' => 'The :attribute must be between :min and :max.', 'file' => 'The :attribute must be between :min and :max kilobytes.', 'string' => 'The :attribute must be between :min and :max characters.', 'array' => 'The :attribute must have between :min and :max items.', ], 'boolean' => 'The :attribute field must be true or false.', 'confirmed' => 'The :attribute confirmation does not match.', 'date' => 'The :attribute is not a valid date.', 'date_equals' => 'The :attribute must be a date equal to :date.', 'date_format' => 'The :attribute does not match the format :format.', 'different' => 'The :attribute and :other must be different.', 'digits' => 'The :attribute must be :digits digits.', 'digits_between' => 'The :attribute must be between :min and :max digits.', 'dimensions' => 'The :attribute has invalid image dimensions.', 'distinct' => 'The :attribute field has a duplicate value.', 'email' => 'The :attribute must be a valid email address.', 'exists' => 'The selected :attribute is invalid.', 'file' => 'The :attribute must be a file.', 'filled' => 'The :attribute field must have a value.', 'gt' => [ 'numeric' => 'The :attribute must be greater than :value.', 'file' => 'The :attribute must be greater than :value kilobytes.', 'string' => 'The :attribute must be greater than :value characters.', 'array' => 'The :attribute must have more than :value items.', ], 'gte' => [ 'numeric' => 'The :attribute must be greater than or equal :value.', 'file' => 'The :attribute must be greater than or equal :value kilobytes.', 'string' => 'The :attribute must be greater than or equal :value characters.', 'array' => 'The :attribute must have :value items or more.', ], 'image' => 'The :attribute must be an image.', 'in' => 'The selected :attribute is invalid.', 'in_array' => 'The :attribute field does not exist in :other.', 'integer' => 'The :attribute must be an integer.', 'ip' => 'The :attribute must be a valid IP address.', 'ipv4' => 'The :attribute must be a valid IPv4 address.', 'ipv6' => 'The :attribute must be a valid IPv6 address.', 'json' => 'The :attribute must be a valid JSON string.', 'lt' => [ 'numeric' => 'The :attribute must be less than :value.', 'file' => 'The :attribute must be less than :value kilobytes.', 'string' => 'The :attribute must be less than :value characters.', 'array' => 'The :attribute must have less than :value items.', ], 'lte' => [ 'numeric' => 'The :attribute must be less than or equal :value.', 'file' => 'The :attribute must be less than or equal :value kilobytes.', 'string' => 'The :attribute must be less than or equal :value characters.', 'array' => 'The :attribute must not have more than :value items.', ], 'max' => [ 'numeric' => 'The :attribute may not be greater than :max.', 'file' => 'The :attribute may not be greater than :max kilobytes.', 'string' => 'The :attribute may not be greater than :max characters.', 'array' => 'The :attribute may not have more than :max items.', ], 'mimes' => 'The :attribute must be a file of type: :values.', 'mimetypes' => 'The :attribute must be a file of type: :values.', 'min' => [ 'numeric' => 'The :attribute must be at least :min.', 'file' => 'The :attribute must be at least :min kilobytes.', 'string' => 'The :attribute must be at least :min characters.', 'array' => 'The :attribute must have at least :min items.', ], 'not_in' => 'The selected :attribute is invalid.', 'not_regex' => 'The :attribute format is invalid.', 'numeric' => 'The :attribute must be a number.', 'present' => 'The :attribute field must be present.', 'regex' => 'The :attribute format is invalid.', 'required' => 'The :attribute field is required.', 'required_if' => 'The :attribute field is required when :other is :value.', 'required_unless' => 'The :attribute field is required unless :other is in :values.', 'required_with' => 'The :attribute field is required when :values is present.', 'required_with_all' => 'The :attribute field is required when :values are present.', 'required_without' => 'The :attribute field is required when :values is not present.', 'required_without_all' => 'The :attribute field is required when none of :values are present.', 'same' => 'The :attribute and :other must match.', 'size' => [ 'numeric' => 'The :attribute must be :size.', 'file' => 'The :attribute must be :size kilobytes.', 'string' => 'The :attribute must be :size characters.', 'array' => 'The :attribute must contain :size items.', ], 'starts_with' => 'The :attribute must start with one of the following: :values', 'string' => 'The :attribute must be a string.', 'timezone' => 'The :attribute must be a valid zone.', 'unique' => 'The :attribute has already been taken.', 'uploaded' => 'The :attribute failed to upload.', 'url' => 'The :attribute format is invalid.', 'uuid' => 'The :attribute must be a valid UUID.', /* |-------------------------------------------------------------------------- | Custom Validation Language Lines |-------------------------------------------------------------------------- | | Here you may specify custom validation messages for attributes using the | convention "attribute.rule" to name the lines. This makes it quick to | specify a specific custom language line for a given attribute rule. | */ 'custom' => [ 'attribute-name' => [ 'rule-name' => 'custom-message', ], ], /* |-------------------------------------------------------------------------- | Custom Validation Attributes |-------------------------------------------------------------------------- | | The following language lines are used to swap our attribute placeholder | with something more reader friendly such as "E-Mail Address" instead | of "email". This simply helps us make our message more expressive. | */ 'attributes' => [], ]; ================================================ FILE: resources/views/app.blade.php ================================================ @routes @inertia ================================================ FILE: routes/api.php ================================================ get('/user', function (Request $request) { return $request->user(); }); ================================================ FILE: routes/channels.php ================================================ id === (int) $id; }); ================================================ FILE: routes/console.php ================================================ comment(Inspiring::quote()); })->describe('Display an inspiring quote'); ================================================ FILE: routes/web.php ================================================ name('login')->uses('Auth\LoginController@showLoginForm')->middleware('guest'); Route::post('login')->name('login.attempt')->uses('Auth\LoginController@login')->middleware('guest'); Route::post('logout')->name('logout')->uses('Auth\LoginController@logout'); // Dashboard Route::get('/')->name('dashboard')->uses('DashboardController')->middleware('auth'); // Users Route::get('users')->name('users')->uses('UsersController@index')->middleware('remember', 'auth'); Route::get('users/create')->name('users.create')->uses('UsersController@create')->middleware('auth'); Route::post('users')->name('users.store')->uses('UsersController@store')->middleware('auth'); Route::get('users/{user}/edit')->name('users.edit')->uses('UsersController@edit')->middleware('auth'); Route::put('users/{user}')->name('users.update')->uses('UsersController@update')->middleware('auth'); Route::delete('users/{user}')->name('users.destroy')->uses('UsersController@destroy')->middleware('auth'); Route::put('users/{user}/restore')->name('users.restore')->uses('UsersController@restore')->middleware('auth'); // Images Route::get('/img/{path}', 'ImagesController@show')->where('path', '.*'); // Organizations Route::get('organizations')->name('organizations')->uses('OrganizationsController@index')->middleware('remember', 'auth'); Route::get('organizations/create')->name('organizations.create')->uses('OrganizationsController@create')->middleware('auth'); Route::post('organizations')->name('organizations.store')->uses('OrganizationsController@store')->middleware('auth'); Route::get('organizations/{organization}/edit')->name('organizations.edit')->uses('OrganizationsController@edit')->middleware('auth'); Route::put('organizations/{organization}')->name('organizations.update')->uses('OrganizationsController@update')->middleware('auth'); Route::delete('organizations/{organization}')->name('organizations.destroy')->uses('OrganizationsController@destroy')->middleware('auth'); Route::put('organizations/{organization}/restore')->name('organizations.restore')->uses('OrganizationsController@restore')->middleware('auth'); // Contacts Route::get('contacts')->name('contacts')->uses('ContactsController@index')->middleware('remember', 'auth'); Route::get('contacts/create')->name('contacts.create')->uses('ContactsController@create')->middleware('auth'); Route::post('contacts')->name('contacts.store')->uses('ContactsController@store')->middleware('auth'); Route::get('contacts/{contact}/edit')->name('contacts.edit')->uses('ContactsController@edit')->middleware('auth'); Route::put('contacts/{contact}')->name('contacts.update')->uses('ContactsController@update')->middleware('auth'); Route::delete('contacts/{contact}')->name('contacts.destroy')->uses('ContactsController@destroy')->middleware('auth'); Route::put('contacts/{contact}/restore')->name('contacts.restore')->uses('ContactsController@restore')->middleware('auth'); // Reports Route::get('reports')->name('reports')->uses('ReportsController')->middleware('auth'); // 500 error Route::get('500', function () { echo $fail; }); ================================================ FILE: server.php ================================================ */ $uri = urldecode( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ); // This file allows us to emulate Apache's "mod_rewrite" functionality from the // built-in PHP web server. This provides a convenient way to test a Laravel // application without having installed a "real" web server software here. if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { return false; } require_once __DIR__.'/public/index.php'; ================================================ FILE: storage/app/.gitignore ================================================ * !public/ !.gitignore ================================================ FILE: storage/debugbar/.gitignore ================================================ * !.gitignore ================================================ FILE: storage/framework/.gitignore ================================================ config.php routes.php schedule-* compiled.php services.json events.scanned.php routes.scanned.php down ================================================ FILE: storage/framework/cache/.gitignore ================================================ * !data/ !.gitignore ================================================ FILE: storage/framework/sessions/.gitignore ================================================ * !.gitignore ================================================ FILE: storage/framework/testing/.gitignore ================================================ * !.gitignore ================================================ FILE: storage/framework/views/.gitignore ================================================ * !.gitignore ================================================ FILE: storage/logs/.gitignore ================================================ * !.gitignore ================================================ FILE: tailwind.config.js ================================================ module.exports = { theme: { extend: { boxShadow: theme => ({ outline: '0 0 0 2px ' + theme('colors.indigo.500') }), } }, variants: { backgroundColor: ['responsive', 'hover', 'focus', 'group-hover', 'focus-within'], textColor: ['responsive', 'hover', 'focus', 'group-hover', 'focus-within'], zIndex: ['responsive', 'focus'] }, plugins: [] } ================================================ FILE: tests/CreatesApplication.php ================================================ make(Kernel::class)->bootstrap(); return $app; } } ================================================ FILE: tests/Feature/ContactsTest.php ================================================ 'Acme Corporation']); $this->user = factory(User::class)->create([ 'account_id' => $account->id, 'first_name' => 'John', 'last_name' => 'Doe', 'email' => 'johndoe@example.com', 'owner' => true, ]); } public function test_can_view_contacts() { $this->user->account->contacts()->saveMany( factory(Contact::class, 5)->make() ); $this->actingAs($this->user) ->get('/contacts') ->assertStatus(200) ->assertPropCount('contacts.data', 5) ->assertPropValue('contacts.data', function ($contacts) { $this->assertEquals( ['id', 'name', 'phone', 'city', 'deleted_at', 'organization'], array_keys($contacts[0]) ); }); } public function test_can_search_for_contacts() { $this->user->account->contacts()->saveMany( factory(contact::class, 5)->make() )->first()->update([ 'first_name' => 'Greg', 'last_name' => 'Andersson' ]); $this->actingAs($this->user) ->get('/contacts?search=Greg') ->assertStatus(200) ->assertPropValue('filters.search', 'Greg') ->assertPropCount('contacts.data', 1) ->assertPropValue('contacts.data', function ($contacts) { $this->assertEquals('Greg Andersson', $contacts[0]['name']); }); } public function test_cannot_view_deleted_contacts() { $this->user->account->contacts()->saveMany( factory(contact::class, 5)->make() )->first()->delete(); $this->actingAs($this->user) ->get('/contacts') ->assertStatus(200) ->assertPropCount('contacts.data', 4); } public function test_can_filter_to_view_deleted_contacts() { $this->user->account->contacts()->saveMany( factory(contact::class, 5)->make() )->first()->delete(); $this->actingAs($this->user) ->get('/contacts?trashed=with') ->assertStatus(200) ->assertPropValue('filters.trashed', 'with') ->assertPropCount('contacts.data', 5); } } ================================================ FILE: tests/Feature/OrganizationsTest.php ================================================ 'Acme Corporation']); $this->user = factory(User::class)->create([ 'account_id' => $account->id, 'first_name' => 'John', 'last_name' => 'Doe', 'email' => 'johndoe@example.com', 'owner' => true, ]); } public function test_can_view_organizations() { $this->user->account->organizations()->saveMany( factory(Organization::class, 5)->make() ); $this->actingAs($this->user) ->get('/organizations') ->assertStatus(200) ->assertPropCount('organizations.data', 5) ->assertPropValue('organizations.data', function ($organizations) { $this->assertEquals( ['id', 'name', 'phone', 'city', 'deleted_at'], array_keys($organizations[0]) ); }); } public function test_can_search_for_organizations() { $this->user->account->organizations()->saveMany( factory(Organization::class, 5)->make() )->first()->update(['name' => 'Some Big Fancy Company Name']); $this->actingAs($this->user) ->get('/organizations?search=Some Big Fancy Company Name') ->assertStatus(200) ->assertPropValue('filters.search', 'Some Big Fancy Company Name') ->assertPropCount('organizations.data', 1) ->assertPropValue('organizations.data', function ($organizations) { $this->assertEquals('Some Big Fancy Company Name', $organizations[0]['name']); }); } public function test_cannot_view_deleted_organizations() { $this->user->account->organizations()->saveMany( factory(Organization::class, 5)->make() )->first()->delete(); $this->actingAs($this->user) ->get('/organizations') ->assertStatus(200) ->assertPropCount('organizations.data', 4); } public function test_can_filter_to_view_deleted_organizations() { $this->user->account->organizations()->saveMany( factory(Organization::class, 5)->make() )->first()->delete(); $this->actingAs($this->user) ->get('/organizations?trashed=with') ->assertStatus(200) ->assertPropValue('filters.trashed', 'with') ->assertPropCount('organizations.data', 5); } } ================================================ FILE: tests/TestCase.php ================================================ original->getData()['page']['props']), JSON_OBJECT_AS_ARRAY); if ($key) { return Arr::get($props, $key); } return $props; }); TestResponse::macro('assertHasProp', function ($key) { Assert::assertTrue(Arr::has($this->props(), $key)); return $this; }); TestResponse::macro('assertPropValue', function ($key, $value) { $this->assertHasProp($key); if (is_callable($value)) { $value($this->props($key)); } else { Assert::assertEquals($this->props($key), $value); } return $this; }); TestResponse::macro('assertPropCount', function ($key, $count) { $this->assertHasProp($key); Assert::assertCount($count, $this->props($key)); return $this; }); } } ================================================ FILE: webpack.mix.js ================================================ const cssImport = require('postcss-import'); const cssNesting = require('postcss-nesting'); const mix = require('laravel-mix'); const path = require('path'); const purgecss = require('@fullhuman/postcss-purgecss'); const tailwindcss = require('tailwindcss'); require('laravel-mix-svelte'); /* |-------------------------------------------------------------------------- | Mix Asset Management |-------------------------------------------------------------------------- | | Mix provides a clean, fluent API for defining some Webpack build steps | for your Laravel application. By default, we are compiling the Sass | file for the application as well as bundling up all the JS files. | */ mix .js('resources/js/app.js', 'public/js') .postCss('resources/css/app.css', 'public/css/app.css') .svelte({ dev: !mix.inProduction() }) .options({ postCss: [ cssImport(), cssNesting(), tailwindcss('tailwind.config.js'), ...(mix.inProduction() ? [ purgecss({ content: [ './resources/views/**/*.blade.php', './resources/js/**/*.svelte' ], defaultExtractor: content => content.match(/[\w-/:.]+(?