├── .editorconfig
├── .env.example
├── .env.testing
├── .gitattributes
├── .gitignore
├── .nvmrc
├── LICENSE
├── README.md
├── app
├── Console
│ └── Kernel.php
├── Exceptions
│ └── Handler.php
├── Http
│ ├── Controllers
│ │ ├── CompanyController.php
│ │ ├── ContactController.php
│ │ ├── Controller.php
│ │ ├── DealController.php
│ │ └── LoginController.php
│ ├── Kernel.php
│ └── Middleware
│ │ ├── Authenticate.php
│ │ ├── EncryptCookies.php
│ │ ├── LoginAutomatically.php
│ │ ├── PreventRequestsDuringMaintenance.php
│ │ ├── RedirectIfAuthenticated.php
│ │ ├── TrimStrings.php
│ │ ├── TrustHosts.php
│ │ ├── TrustProxies.php
│ │ ├── ValidateSignature.php
│ │ └── VerifyCsrfToken.php
├── Imports
│ └── CompaniesImport.php
├── Models
│ ├── Company.php
│ ├── Contact.php
│ ├── Deal.php
│ ├── Organization.php
│ └── User.php
├── Providers
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── BroadcastServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
└── View
│ └── Composers
│ └── AuthComposer.php
├── artisan
├── bootstrap
├── app.php
└── cache
│ └── .gitignore
├── composer.json
├── composer.lock
├── config
├── app.php
├── auth.php
├── broadcasting.php
├── cache.php
├── cors.php
├── database.php
├── debugbar.php
├── excel.php
├── filesystems.php
├── hashing.php
├── logging.php
├── mail.php
├── queue.php
├── sanctum.php
├── scout.php
├── services.php
├── session.php
└── view.php
├── database
├── .gitignore
├── factories
│ ├── CompanyFactory.php
│ ├── ContactFactory.php
│ ├── DealFactory.php
│ ├── OrganizationFactory.php
│ └── UserFactory.php
├── migrations
│ ├── 2014_10_12_000000_create_users_table.php
│ ├── 2014_10_12_100000_create_password_reset_tokens_table.php
│ ├── 2019_08_19_000000_create_failed_jobs_table.php
│ ├── 2019_12_14_000001_create_personal_access_tokens_table.php
│ ├── 2023_06_14_085749_add_avatar_to_users_table.php
│ ├── 2023_06_14_142103_create_organizations_table.php
│ ├── 2023_06_14_142559_add_organization_to_users.php
│ ├── 2023_06_14_144622_create_companies_table.php
│ ├── 2023_06_14_150142_create_contacts_table.php
│ ├── 2023_06_14_162820_create_deals_table.php
│ └── 2023_06_20_140920_add_meilisearch_token_to_organizations.php
└── seeders
│ ├── CompanySeeder.php
│ ├── ContactSeeder.php
│ ├── DatabaseSeeder.php
│ ├── DealSeeder.php
│ ├── OrganizationSeeder.php
│ └── UserSeeder.php
├── docker-compose.yml
├── eslint.config.js
├── package.json
├── phpunit.xml
├── postcss.config.js
├── public
├── .htaccess
├── apple-touch-icon.png
├── favicon-16x16.png
├── favicon-32x32.png
├── favicon.ico
├── index.php
└── robots.txt
├── resources
├── assets
│ ├── loading-illustration.svg
│ └── meilisearch-logo.svg
├── css
│ └── app.css
├── js
│ ├── app-search.js
│ ├── app.js
│ ├── components
│ │ ├── header
│ │ │ ├── AppSearch.vue
│ │ │ ├── CompanyCard.vue
│ │ │ ├── ContactCard.vue
│ │ │ ├── DealCard.vue
│ │ │ ├── ResultCard.vue
│ │ │ ├── SearchButton.vue
│ │ │ ├── SearchModal.vue
│ │ │ ├── SearchModalLayout.vue
│ │ │ └── TopResultCard.vue
│ │ ├── tables
│ │ │ ├── CompanyList.vue
│ │ │ ├── ContactList.vue
│ │ │ ├── DealList.vue
│ │ │ ├── InstantsearchProvider.vue
│ │ │ ├── SearchBar.vue
│ │ │ ├── SearchFilterMenu.vue
│ │ │ └── SearchSortBy.vue
│ │ └── ui
│ │ │ ├── OrganizationLogo.vue
│ │ │ ├── SearchIcon.vue
│ │ │ ├── SearchInput.vue
│ │ │ ├── SearchResetButton.vue
│ │ │ ├── UserAvatar.vue
│ │ │ └── icons
│ │ │ ├── micro
│ │ │ ├── BriefcaseIcon.vue
│ │ │ ├── BuildingOfficeIcon.vue
│ │ │ ├── UserGroupIcon.vue
│ │ │ └── UserIcon.vue
│ │ │ └── mini
│ │ │ └── UserGroupIcon.vue
│ ├── env.d.ts
│ ├── table-search.js
│ └── utils.ts
└── views
│ ├── app.blade.php
│ ├── companies
│ ├── index.blade.php
│ └── show.blade.php
│ ├── components
│ ├── app-search.blade.php
│ ├── navbar.blade.php
│ ├── side-menu-item.blade.php
│ ├── side-menu.blade.php
│ └── ui
│ │ ├── avatar.blade.php
│ │ ├── company-icon.blade.php
│ │ ├── contact-icon.blade.php
│ │ ├── discord-icon.blade.php
│ │ ├── github-icon.blade.php
│ │ ├── home-icon.blade.php
│ │ ├── organization-logo.blade.php
│ │ ├── twitter-icon.blade.php
│ │ └── web-icon.blade.php
│ ├── contacts
│ ├── index.blade.php
│ └── show.blade.php
│ ├── deals
│ ├── index.blade.php
│ └── show.blade.php
│ └── layouts
│ ├── resource.blade.php
│ └── table.blade.php
├── routes
├── api.php
├── channels.php
├── console.php
└── web.php
├── storage
├── app
│ ├── .gitignore
│ ├── Fortune500.csv
│ └── public
│ │ └── .gitignore
├── debugbar
│ └── .gitignore
├── framework
│ ├── .gitignore
│ ├── cache
│ │ ├── .gitignore
│ │ └── data
│ │ │ └── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ ├── testing
│ │ └── .gitignore
│ └── views
│ │ └── .gitignore
└── logs
│ └── .gitignore
├── tailwind.config.ts
├── tests
├── CreatesApplication.php
├── Feature
│ ├── CompanyTest.php
│ ├── ContactTest.php
│ ├── DatabaseSeederTest.php
│ ├── DealTest.php
│ ├── LoginControllerTest.php
│ ├── OrganizationTest.php
│ ├── PagesTest.php
│ ├── SearchTest.php
│ └── UserTest.php
├── Pest.php
└── TestCase.php
├── tsconfig.json
├── vite.config.js
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | indent_size = 4
7 | indent_style = space
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [*.{yml,yaml}]
15 | indent_size = 2
16 |
17 | [docker-compose.yml]
18 | indent_size = 4
19 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=Laravel
2 | APP_ENV=local
3 | APP_KEY=
4 | APP_DEBUG=true
5 | APP_URL=http://localhost
6 |
7 | LOG_CHANNEL=stack
8 | LOG_DEPRECATIONS_CHANNEL=null
9 | LOG_LEVEL=debug
10 |
11 | DB_CONNECTION=mysql
12 | # Use `DB_HOST=mysql` when using Sail
13 | DB_HOST=mysql
14 | DB_PORT=3306
15 | DB_DATABASE=saas_demo
16 | DB_USERNAME=laravel
17 | DB_PASSWORD=
18 |
19 | BROADCAST_DRIVER=log
20 | CACHE_DRIVER=file
21 | FILESYSTEM_DISK=local
22 | QUEUE_CONNECTION=sync
23 | SESSION_DRIVER=file
24 | SESSION_LIFETIME=120
25 |
26 | MEMCACHED_HOST=127.0.0.1
27 |
28 | REDIS_HOST=127.0.0.1
29 | REDIS_PASSWORD=null
30 | REDIS_PORT=6379
31 |
32 | MAIL_MAILER=smtp
33 | MAIL_HOST=mailpit
34 | MAIL_PORT=1025
35 | MAIL_USERNAME=null
36 | MAIL_PASSWORD=null
37 | MAIL_ENCRYPTION=null
38 | MAIL_FROM_ADDRESS="hello@example.com"
39 | MAIL_FROM_NAME="${APP_NAME}"
40 |
41 | AWS_ACCESS_KEY_ID=
42 | AWS_SECRET_ACCESS_KEY=
43 | AWS_DEFAULT_REGION=us-east-1
44 | AWS_BUCKET=
45 | AWS_USE_PATH_STYLE_ENDPOINT=false
46 |
47 | PUSHER_APP_ID=
48 | PUSHER_APP_KEY=
49 | PUSHER_APP_SECRET=
50 | PUSHER_HOST=
51 | PUSHER_PORT=443
52 | PUSHER_SCHEME=https
53 | PUSHER_APP_CLUSTER=mt1
54 |
55 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
56 | VITE_PUSHER_HOST="${PUSHER_HOST}"
57 | VITE_PUSHER_PORT="${PUSHER_PORT}"
58 | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
59 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
60 |
61 | # ------------------------------
62 | # Seeding
63 | # ------------------------------
64 |
65 | APP_USER1_EMAIL=john.doe@acme.com
66 | APP_USER2_EMAIL=jane.doe@example.com
67 |
68 | # ------------------------------
69 | # Meilisearch
70 | # ------------------------------
71 |
72 | SCOUT_DRIVER=meilisearch
73 |
74 | # This is the URL used by Laravel to access Meilisearch
75 | MEILISEARCH_HOST=http://meilisearch:7700
76 |
77 | # This is the Master Key used by Sail to create the Meilisearch database (local only)
78 | MEILISEARCH_MASTER_KEY=
79 | # This is the Admin Key used by Laravel to access Meilisearch
80 | MEILISEARCH_KEY=
81 | # This is the UID of the Admin Key used above
82 | MEILISEARCH_KEY_UID=
83 |
84 | # ------------------------------
85 | # Vite
86 | # ------------------------------
87 |
88 | # This is the URL used by JavaScript to access Meilisearch
89 | VITE_MEILISEARCH_HOST=http://localhost:7700
90 |
--------------------------------------------------------------------------------
/.env.testing:
--------------------------------------------------------------------------------
1 | APP_KEY=base64:riw4+SwiYtZIDsKwhWAb4DPO18x6xiM/jsZXYojEyxs=
2 |
3 | APP_USER1_EMAIL=john.doe@acme.com
4 | APP_USER2_EMAIL=jane.doe@example.com
5 |
6 | DB_CONNECTION=sqlite
7 | DB_DATABASE=:memory:
8 |
9 | SCOUT_DRIVER=array
10 | MEILISEARCH_HOST=http://localhost:7701
11 | MEILISEARCH_KEY="e108dfcc42403821f4d59194463c06db2c7fad0461e4335d12870af7209aa3d9"
12 | MEILISEARCH_KEY_UID="05f5df51-87b7-4ff8-b2b7-6aa04c0f8186"
13 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto eol=lf
2 |
3 | *.blade.php diff=html
4 | *.css diff=css
5 | *.html diff=html
6 | *.md diff=markdown
7 | *.php diff=php
8 |
9 | /.github export-ignore
10 | CHANGELOG.md export-ignore
11 | .styleci.yml export-ignore
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.phpunit.cache
2 | /node_modules
3 | /public/build
4 | /public/hot
5 | /public/storage
6 | /storage/*.key
7 | /vendor
8 | .env
9 | .env.backup
10 | .env.production
11 | .phpunit.result.cache
12 | Homestead.json
13 | Homestead.yaml
14 | auth.json
15 | npm-debug.log
16 | yarn-error.log
17 | /.fleet
18 | /.idea
19 | /.vscode
20 |
21 | .DS_Store
22 |
23 | # yarn
24 | .pnp.*
25 | .yarn/*
26 |
--------------------------------------------------------------------------------
/.nvmrc:
--------------------------------------------------------------------------------
1 | v20.17.0
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 MeiliSearch
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Meilisearch SaaS demo
8 |
9 |
16 |
17 | > Meilisearch is an open-source search engine that offers fast, relevant search out of the box.
18 |
19 | ## 💪 Looking to build this yourself?
20 |
21 | Read our [Complete guide to full-text search with Laravel](https://blog.meilisearch.com/laravel-full-text-search/?utm_campaign=saas-demo&utm_source=github&utm_medium=readme)!
22 |
23 | ## ✨ Features
24 |
25 | This SaaS demo uses the following:
26 |
27 | - [Federated search](https://www.meilisearch.com/docs/reference/api/multi_search?utm_campaign=saas-demo&utm_source=github&utm_medium=readme)
28 | - [Multi-tenancy](https://www.meilisearch.com/docs/learn/security/tenant_tokens?utm_campaign=saas-demo&utm_source=github&utm_medium=readme)
29 | - [Filtering](https://www.meilisearch.com/docs/learn/fine_tuning_results/filtering?utm_campaign=saas-demo&utm_source=github&utm_medium=readme)
30 | - [Sorting](https://www.meilisearch.com/docs/learn/fine_tuning_results/sorting?utm_campaign=saas-demo&utm_source=github&utm_medium=readme)
31 |
32 | ## 🧰 Stack
33 |
34 | This project uses:
35 |
36 | - [PHP 8.2](https://www.php.net/)
37 | - [Laravel 10](https://laravel.com/)
38 | - [TailwindCSS 3](https://tailwindcss.com/) and [HyperUI](https://www.hyperui.dev/) components
39 | - [Heroicons 2](https://heroicons.com/) and social medias icons from [icons8](https://icons8.com/icons/collections/EnE9mEHAiX2D)
40 | - [Meilisearch](https://www.meilisearch.com/?utm_campaign=saas-demo&utm_source=github&utm_medium=readme) for fast, relevant search
41 |
42 | ## 🧑💻 Development
43 |
44 | This project uses [Sail](https://laravel.com/docs/10.x/sail), a local development environment based on Docker compose.
45 |
46 | > Make sure to follow the Sail documentation and prefix commands accordingly to be able to run them in Docker.
47 |
48 | ### Installation
49 |
50 | Install PHP dependencies:
51 |
52 | ```sh
53 | sail composer install
54 | ```
55 |
56 | Install Node dependencies:
57 |
58 | ```sh
59 | sail yarn
60 | ```
61 |
62 | Launch Docker services for local development:
63 |
64 | ```sh
65 | sail up
66 | ```
67 |
68 | Run JavaScript dev server:
69 |
70 | ```sh
71 | sail yarn dev
72 | ```
73 |
74 | ## 🛠️ Configuration
75 |
76 | Copy `.env.example` as `.env` and update environment variables as needed.
77 |
78 | ### Using Meilisearch with Laravel Sail
79 |
80 | When running Meilisearch through Sail, your `MEILISEARCH_HOST` should follow the `http://meilisearch:port` form (instead of `localhost:port`.) However, your front-end application expect the real URL to your Meilisearch instant.
81 |
82 | This means that when running Meilisearch locally with Sail, your `.env` file will look like:
83 |
84 | ```sh
85 | # This is the URL used by Laravel to access Meilisearch
86 | MEILISEARCH_HOST=http://meilisearch:7700
87 |
88 | # This is the URL used by JavaScript to access Meilisearch
89 | VITE_MEILISEARCH_HOST=http://localhost:7700
90 | ```
91 |
92 | > See [Sail documentation](https://laravel.com/docs/10.x/sail#meilisearch).
93 |
94 | ### Instructions
95 |
96 | Setup your Meilisearch settings by running:
97 |
98 | ```sh
99 | artisan scout:sync-index-settings
100 | ```
101 |
102 | Seed the database:
103 |
104 | ```sh
105 | artisan migrate:fresh --seed
106 | ```
107 |
108 | ## Conventions
109 |
110 | **Blade**
111 |
112 | This project uses the [Blade Formatter](https://marketplace.visualstudio.com/items?itemName=shufo.vscode-blade-formatter) VS code extension to format `.blade.php` files.
113 |
114 | **JavaScript and Vue**
115 |
116 | This project uses [ESLint](https://eslint.org/) to lint JavaScript and Vue files.
117 |
118 | An error with Eslint requires to have `resolutions` key in the `package.json` file:
119 | ```json
120 | "resolutions": {
121 | "strip-ansi": "6.0.1"
122 | },
123 | ```
124 |
--------------------------------------------------------------------------------
/app/Console/Kernel.php:
--------------------------------------------------------------------------------
1 | command('inspire')->hourly();
16 | }
17 |
18 | /**
19 | * Register the commands for the application.
20 | */
21 | protected function commands(): void
22 | {
23 | $this->load(__DIR__.'/Commands');
24 |
25 | require base_path('routes/console.php');
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | protected $dontFlash = [
16 | 'current_password',
17 | 'password',
18 | 'password_confirmation',
19 | ];
20 |
21 | /**
22 | * Register the exception handling callbacks for the application.
23 | */
24 | public function register(): void
25 | {
26 | $this->reportable(function (Throwable $e) {
27 | //
28 | });
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Http/Controllers/CompanyController.php:
--------------------------------------------------------------------------------
1 | with([
19 | 'indexName' => 'companies:name:asc',
20 | ]);
21 | }
22 |
23 | /**
24 | * Show the form for creating a new resource.
25 | */
26 | public function create()
27 | {
28 | //
29 | }
30 |
31 | /**
32 | * Store a newly created resource in storage.
33 | */
34 | public function store(Request $request)
35 | {
36 | //
37 | }
38 |
39 | /**
40 | * Display the specified resource.
41 | */
42 | public function show(Company $company)
43 | {
44 | $company->load(['contacts', 'deals']);
45 | return view('companies.show')->with([
46 | 'company' => $company,
47 | 'parentPageUrl' => route('companies.index'),
48 | ]);
49 | }
50 |
51 | /**
52 | * Show the form for editing the specified resource.
53 | */
54 | public function edit(Company $company)
55 | {
56 | //
57 | }
58 |
59 | /**
60 | * Update the specified resource in storage.
61 | */
62 | public function update(Request $request, Company $company)
63 | {
64 | //
65 | }
66 |
67 | /**
68 | * Remove the specified resource from storage.
69 | */
70 | public function destroy(Company $company)
71 | {
72 | //
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/Http/Controllers/ContactController.php:
--------------------------------------------------------------------------------
1 | with([
19 | 'indexName' => 'contacts:name:asc',
20 | ]);
21 | }
22 |
23 | /**
24 | * Show the form for creating a new resource.
25 | */
26 | public function create()
27 | {
28 | //
29 | }
30 |
31 | /**
32 | * Store a newly created resource in storage.
33 | */
34 | public function store(Request $request)
35 | {
36 | //
37 | }
38 |
39 | /**
40 | * Display the specified resource.
41 | */
42 | public function show(Contact $contact)
43 | {
44 | return view('contacts.show')->with([
45 | 'contact' => $contact,
46 | 'parentPageUrl' => route('contacts.index'),
47 | ]);
48 | }
49 |
50 | /**
51 | * Show the form for editing the specified resource.
52 | */
53 | public function edit(Contact $contact)
54 | {
55 | //
56 | }
57 |
58 | /**
59 | * Update the specified resource in storage.
60 | */
61 | public function update(Request $request, Contact $contact)
62 | {
63 | //
64 | }
65 |
66 | /**
67 | * Remove the specified resource from storage.
68 | */
69 | public function destroy(Contact $contact)
70 | {
71 | //
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | with([
16 | 'indexName' => 'deals:company_name:asc',
17 | ]);
18 | }
19 |
20 | /**
21 | * Show the form for creating a new resource.
22 | */
23 | public function create()
24 | {
25 | //
26 | }
27 |
28 | /**
29 | * Store a newly created resource in storage.
30 | */
31 | public function store(Request $request)
32 | {
33 | //
34 | }
35 |
36 | /**
37 | * Display the specified resource.
38 | */
39 | public function show(Deal $deal)
40 | {
41 | return view('deals.show')->with([
42 | 'deal' => $deal,
43 | 'parentPageUrl' => route('deals.index'),
44 | ]);
45 | }
46 |
47 | /**
48 | * Show the form for editing the specified resource.
49 | */
50 | public function edit(Deal $deal)
51 | {
52 | //
53 | }
54 |
55 | /**
56 | * Update the specified resource in storage.
57 | */
58 | public function update(Request $request, Deal $deal)
59 | {
60 | //
61 | }
62 |
63 | /**
64 | * Remove the specified resource from storage.
65 | */
66 | public function destroy(Deal $deal)
67 | {
68 | //
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/Http/Controllers/LoginController.php:
--------------------------------------------------------------------------------
1 | input('email');
15 | $user = User::findByEmail($email);
16 |
17 | if ($user) {
18 | Auth::login($user);
19 | return back();
20 | }
21 |
22 | return back()->with('error', 'Invalid credentials');
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | protected $middleware = [
17 | // \App\Http\Middleware\TrustHosts::class,
18 | \App\Http\Middleware\TrustProxies::class,
19 | \Illuminate\Http\Middleware\HandleCors::class,
20 | \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
21 | \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
22 | \App\Http\Middleware\TrimStrings::class,
23 | \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
24 | ];
25 |
26 | /**
27 | * The application's route middleware groups.
28 | *
29 | * @var array>
30 | */
31 | protected $middlewareGroups = [
32 | 'web' => [
33 | \App\Http\Middleware\EncryptCookies::class,
34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
35 | \Illuminate\Session\Middleware\StartSession::class,
36 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
37 | \App\Http\Middleware\VerifyCsrfToken::class,
38 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
39 | ],
40 |
41 | 'api' => [
42 | // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
43 | \Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
44 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
45 | ],
46 | ];
47 |
48 | /**
49 | * The application's middleware aliases.
50 | *
51 | * Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
52 | *
53 | * @var array
54 | */
55 | protected $middlewareAliases = [
56 | 'auth' => \App\Http\Middleware\Authenticate::class,
57 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
58 | 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
59 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
60 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
61 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
62 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
63 | 'signed' => \App\Http\Middleware\ValidateSignature::class,
64 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
65 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
66 | ];
67 | }
68 |
--------------------------------------------------------------------------------
/app/Http/Middleware/Authenticate.php:
--------------------------------------------------------------------------------
1 | expectsJson() ? null : route('login');
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | protected $except = [
15 | //
16 | ];
17 | }
18 |
--------------------------------------------------------------------------------
/app/Http/Middleware/LoginAutomatically.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | protected $except = [
15 | //
16 | ];
17 | }
18 |
--------------------------------------------------------------------------------
/app/Http/Middleware/RedirectIfAuthenticated.php:
--------------------------------------------------------------------------------
1 | check()) {
24 | return redirect(RouteServiceProvider::HOME);
25 | }
26 | }
27 |
28 | return $next($request);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | protected $except = [
15 | 'current_password',
16 | 'password',
17 | 'password_confirmation',
18 | ];
19 | }
20 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrustHosts.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | public function hosts(): array
15 | {
16 | return [
17 | $this->allSubdomainsOfApplicationUrl(),
18 | ];
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrustProxies.php:
--------------------------------------------------------------------------------
1 | |string|null
14 | */
15 | protected $proxies;
16 |
17 | /**
18 | * The headers that should be used to detect proxies.
19 | *
20 | * @var int
21 | */
22 | protected $headers =
23 | Request::HEADER_X_FORWARDED_FOR |
24 | Request::HEADER_X_FORWARDED_HOST |
25 | Request::HEADER_X_FORWARDED_PORT |
26 | Request::HEADER_X_FORWARDED_PROTO |
27 | Request::HEADER_X_FORWARDED_AWS_ELB;
28 | }
29 |
--------------------------------------------------------------------------------
/app/Http/Middleware/ValidateSignature.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | protected $except = [
15 | // 'fbclid',
16 | // 'utm_campaign',
17 | // 'utm_content',
18 | // 'utm_medium',
19 | // 'utm_source',
20 | // 'utm_term',
21 | ];
22 | }
23 |
--------------------------------------------------------------------------------
/app/Http/Middleware/VerifyCsrfToken.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | protected $except = [
15 | //
16 | ];
17 | }
18 |
--------------------------------------------------------------------------------
/app/Imports/CompaniesImport.php:
--------------------------------------------------------------------------------
1 | hasMany(Contact::class);
19 | }
20 |
21 | public function deals(): HasMany
22 | {
23 | return $this->hasMany(Deal::class);
24 | }
25 |
26 | public function organization(): BelongsTo
27 | {
28 | return $this->belongsTo(Organization::class);
29 | }
30 |
31 | // only transforms 'www.domain.com' to 'domain.com'
32 | public function getEmailDomain(): string
33 | {
34 | $parsedUrl = parse_url($this->url);
35 | return str_ireplace('www.', '', $parsedUrl['path']);
36 | }
37 |
38 | public function toSearchableArray(): array
39 | {
40 | $array = $this->toArray();
41 |
42 | $array['number_of_contacts'] = $this->contacts->count();
43 |
44 | return $array;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/Models/Contact.php:
--------------------------------------------------------------------------------
1 | belongsTo(Company::class);
18 | }
19 |
20 | public function toSearchableArray(): array
21 | {
22 | $array = $this->toArray();
23 |
24 | $array['organization_id'] = $this->company->organization->id;
25 |
26 | $array['company_name'] = $this->company->name;
27 | $array['company_url'] = $this->company->url;
28 |
29 | return $array;
30 | }
31 |
32 | protected static function booted()
33 | {
34 | static::saved(function (Contact $contact) {
35 | $contact->company->save();
36 | });
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/Models/Deal.php:
--------------------------------------------------------------------------------
1 | belongsTo(Organization::class);
17 | }
18 |
19 | public function company(): BelongsTo
20 | {
21 | return $this->belongsTo(Company::class);
22 | }
23 |
24 | public function contact(): BelongsTo
25 | {
26 | return $this->belongsTo(Contact::class);
27 | }
28 |
29 | public function toSearchableArray(): array
30 | {
31 | $array = $this->toArray();
32 |
33 | $array['company_name'] = $this->company->name;
34 | $array['company_url'] = $this->company->url;
35 | $array['contact_name'] = $this->contact->name;
36 | $array['contact_email'] = $this->contact->email;
37 |
38 | return $array;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/Models/Organization.php:
--------------------------------------------------------------------------------
1 | firstOrFail();
20 | }
21 |
22 | public function companies(): HasMany
23 | {
24 | return $this->hasMany(Company::class);
25 | }
26 |
27 | public function contacts(): HasManyThrough
28 | {
29 | return $this->hasManyThrough(Contact::class, Company::class);
30 | }
31 |
32 | public function deals(): HasMany
33 | {
34 | return $this->hasMany(Deal::class);
35 | }
36 |
37 | protected static function booted()
38 | {
39 | static::retrieved(function (Organization $organization) {
40 | // This will be true when running tests
41 | if (env('SCOUT_DRIVER') === 'array' && env('APP_ENV') === 'testing') {
42 | $organization->meilisearch_token = 'fake-tenant-token';
43 | return;
44 | }
45 |
46 | if ($organization->meilisearch_token) {
47 | Log::debug('Organization ' . $organization->id . ': already has a token');
48 | return;
49 | }
50 | Log::debug('Generating tenant token for organization ID: ' . $organization->id);
51 |
52 | $searchRules = (object) [
53 | '*' => (object) [
54 | 'filter' => 'organization_id = ' . $organization->id,
55 | ]
56 | ];
57 |
58 | $meiliApiKey = env('MEILISEARCH_KEY');
59 | $meiliApiKeyUid = env('MEILISEARCH_KEY_UID');
60 |
61 | Log::debug("Using MeiliSearch API key: {$meiliApiKey}");
62 | Log::debug("Using MeiliSearch API key UID: {$meiliApiKeyUid}");
63 |
64 | $token = self::generateMeiliTenantToken($meiliApiKeyUid, $searchRules, $meiliApiKey);
65 | Log::notice('Organization ' . $organization->id . ': saved token ' . $token);
66 |
67 | $organization->meilisearch_token = $token;
68 | $organization->save();
69 | });
70 | }
71 |
72 | protected static function generateMeiliTenantToken($meiliApiKeyUid, $searchRules, $meiliApiKey)
73 | {
74 | $meilisearch = resolve(EngineManager::class)->engine();
75 |
76 | return $meilisearch->generateTenantToken(
77 | $meiliApiKeyUid,
78 | $searchRules,
79 | [
80 | 'apiKey' => $meiliApiKey,
81 | 'expiresAt' => new DateTime('2030-12-31'),
82 | ]
83 | );
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/Models/User.php:
--------------------------------------------------------------------------------
1 |
19 | */
20 | protected $fillable = [
21 | 'name',
22 | 'email',
23 | 'password',
24 | ];
25 |
26 | /**
27 | * The attributes that should be hidden for serialization.
28 | *
29 | * @var array
30 | */
31 | protected $hidden = [
32 | 'password',
33 | 'remember_token',
34 | ];
35 |
36 | /**
37 | * The attributes that should be cast.
38 | *
39 | * @var array
40 | */
41 | protected $casts = [
42 | 'email_verified_at' => 'datetime',
43 | 'password' => 'hashed',
44 | ];
45 |
46 | static function findByEmail(string $email): User
47 | {
48 | return User::where('email', $email)->firstOrFail();
49 | }
50 |
51 | static function findById(int $id): User
52 | {
53 | return User::where('id', $id)->firstOrFail();
54 | }
55 |
56 | public function organization()
57 | {
58 | return $this->belongsTo(Organization::class);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | protected $policies = [
16 | //
17 | ];
18 |
19 | /**
20 | * Register any authentication / authorization services.
21 | */
22 | public function boot(): void
23 | {
24 | //
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | >
16 | */
17 | protected $listen = [
18 | Registered::class => [
19 | SendEmailVerificationNotification::class,
20 | ],
21 | ];
22 |
23 | /**
24 | * Register any events for your application.
25 | */
26 | public function boot(): void
27 | {
28 | //
29 | }
30 |
31 | /**
32 | * Determine if events and listeners should be automatically discovered.
33 | */
34 | public function shouldDiscoverEvents(): bool
35 | {
36 | return false;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | by($request->user()?->id ?: $request->ip());
29 | });
30 |
31 | $this->routes(function () {
32 | Route::middleware('api')
33 | ->prefix('api')
34 | ->group(base_path('routes/api.php'));
35 |
36 | Route::middleware('web')
37 | ->group(base_path('routes/web.php'));
38 | });
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/View/Composers/AuthComposer.php:
--------------------------------------------------------------------------------
1 | with([
24 | 'userName' => $user->name,
25 | 'userAvatarUrl' => $user->avatar_url,
26 | 'userEmail' => $user->email,
27 | 'otherUserEmail' => User::where('email', '!=', $user->email)->first()->email,
28 | 'organizationLogoUrl' => Vite::asset('resources/assets/meilisearch-logo.svg'),
29 | 'organizationName' => $user->organization->name,
30 | 'meilisearchToken' => $user->organization->meilisearch_token,
31 | ]);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
34 |
35 | $status = $kernel->handle(
36 | $input = new Symfony\Component\Console\Input\ArgvInput,
37 | new Symfony\Component\Console\Output\ConsoleOutput
38 | );
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Shutdown The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once Artisan has finished running, we will fire off the shutdown events
46 | | so that any final work may be done by the application before we shut
47 | | down the process. This is the last thing to happen to the request.
48 | |
49 | */
50 |
51 | $kernel->terminate($input, $status);
52 |
53 | exit($status);
54 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/bootstrap/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "laravel/laravel",
3 | "type": "project",
4 | "description": "The Laravel Framework.",
5 | "keywords": [
6 | "framework",
7 | "laravel"
8 | ],
9 | "license": "MIT",
10 | "require": {
11 | "php": "^8.1",
12 | "fakerphp/faker": "^1.23",
13 | "guzzlehttp/guzzle": "^7.2",
14 | "http-interop/http-factory-guzzle": "^1.2",
15 | "jeremykendall/php-domain-parser": "^6.0",
16 | "laravel/framework": "^10.10",
17 | "laravel/sanctum": "^3.2",
18 | "laravel/scout": "^10.2",
19 | "laravel/tinker": "^2.8",
20 | "maatwebsite/excel": "^3.1",
21 | "meilisearch/meilisearch-php": "^1.2"
22 | },
23 | "require-dev": {
24 | "barryvdh/laravel-debugbar": "^3.8",
25 | "laravel/pint": "^1.0",
26 | "laravel/sail": "^1.31",
27 | "mockery/mockery": "^1.4.4",
28 | "nunomaduro/collision": "^7.0",
29 | "pestphp/pest": "^2.6",
30 | "phpunit/phpunit": "^10.1",
31 | "spatie/laravel-ignition": "^2.0",
32 | "sti3bas/laravel-scout-array-driver": "^3.4"
33 | },
34 | "autoload": {
35 | "psr-4": {
36 | "App\\": "app/",
37 | "Database\\Factories\\": "database/factories/",
38 | "Database\\Seeders\\": "database/seeders/"
39 | }
40 | },
41 | "autoload-dev": {
42 | "psr-4": {
43 | "Tests\\": "tests/"
44 | }
45 | },
46 | "scripts": {
47 | "post-autoload-dump": [
48 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
49 | "@php artisan package:discover --ansi"
50 | ],
51 | "post-update-cmd": [
52 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
53 | ],
54 | "post-root-package-install": [
55 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
56 | ],
57 | "post-create-project-cmd": [
58 | "@php artisan key:generate --ansi"
59 | ]
60 | },
61 | "extra": {
62 | "laravel": {
63 | "dont-discover": []
64 | }
65 | },
66 | "config": {
67 | "optimize-autoloader": true,
68 | "preferred-install": "dist",
69 | "sort-packages": true,
70 | "allow-plugins": {
71 | "pestphp/pest-plugin": true,
72 | "php-http/discovery": true
73 | }
74 | },
75 | "minimum-stability": "stable",
76 | "prefer-stable": true
77 | }
78 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 | ],
44 |
45 | /*
46 | |--------------------------------------------------------------------------
47 | | User Providers
48 | |--------------------------------------------------------------------------
49 | |
50 | | All authentication drivers have a user provider. This defines how the
51 | | users are actually retrieved out of your database or other storage
52 | | mechanisms used by this application to persist your user's data.
53 | |
54 | | If you have multiple user tables or models you may configure multiple
55 | | sources which represent each model / table. These sources may then
56 | | be assigned to any extra authentication guards you have defined.
57 | |
58 | | Supported: "database", "eloquent"
59 | |
60 | */
61 |
62 | 'providers' => [
63 | 'users' => [
64 | 'driver' => 'eloquent',
65 | 'model' => App\Models\User::class,
66 | ],
67 |
68 | // 'users' => [
69 | // 'driver' => 'database',
70 | // 'table' => 'users',
71 | // ],
72 | ],
73 |
74 | /*
75 | |--------------------------------------------------------------------------
76 | | Resetting Passwords
77 | |--------------------------------------------------------------------------
78 | |
79 | | You may specify multiple password reset configurations if you have more
80 | | than one user table or model in the application and you want to have
81 | | separate password reset settings based on the specific user types.
82 | |
83 | | The expiry time is the number of minutes that each reset token will be
84 | | considered valid. This security feature keeps tokens short-lived so
85 | | they have less time to be guessed. You may change this as needed.
86 | |
87 | | The throttle setting is the number of seconds a user must wait before
88 | | generating more password reset tokens. This prevents the user from
89 | | quickly generating a very large amount of password reset tokens.
90 | |
91 | */
92 |
93 | 'passwords' => [
94 | 'users' => [
95 | 'provider' => 'users',
96 | 'table' => 'password_reset_tokens',
97 | 'expire' => 60,
98 | 'throttle' => 60,
99 | ],
100 | ],
101 |
102 | /*
103 | |--------------------------------------------------------------------------
104 | | Password Confirmation Timeout
105 | |--------------------------------------------------------------------------
106 | |
107 | | Here you may define the amount of seconds before a password confirmation
108 | | times out and the user is prompted to re-enter their password via the
109 | | confirmation screen. By default, the timeout lasts for three hours.
110 | |
111 | */
112 |
113 | 'password_timeout' => 10800,
114 |
115 | ];
116 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | 'cluster' => env('PUSHER_APP_CLUSTER'),
40 | 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
41 | 'port' => env('PUSHER_PORT', 443),
42 | 'scheme' => env('PUSHER_SCHEME', 'https'),
43 | 'encrypted' => true,
44 | 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
45 | ],
46 | 'client_options' => [
47 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
48 | ],
49 | ],
50 |
51 | 'ably' => [
52 | 'driver' => 'ably',
53 | 'key' => env('ABLY_KEY'),
54 | ],
55 |
56 | 'redis' => [
57 | 'driver' => 'redis',
58 | 'connection' => 'default',
59 | ],
60 |
61 | 'log' => [
62 | 'driver' => 'log',
63 | ],
64 |
65 | 'null' => [
66 | 'driver' => 'null',
67 | ],
68 |
69 | ],
70 |
71 | ];
72 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Cache Stores
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the cache "stores" for your application as
26 | | well as their drivers. You may even define multiple stores for the
27 | | same cache driver to group types of items stored in your caches.
28 | |
29 | | Supported drivers: "apc", "array", "database", "file",
30 | | "memcached", "redis", "dynamodb", "octane", "null"
31 | |
32 | */
33 |
34 | 'stores' => [
35 |
36 | 'apc' => [
37 | 'driver' => 'apc',
38 | ],
39 |
40 | 'array' => [
41 | 'driver' => 'array',
42 | 'serialize' => false,
43 | ],
44 |
45 | 'database' => [
46 | 'driver' => 'database',
47 | 'table' => 'cache',
48 | 'connection' => null,
49 | 'lock_connection' => null,
50 | ],
51 |
52 | 'file' => [
53 | 'driver' => 'file',
54 | 'path' => storage_path('framework/cache/data'),
55 | 'lock_path' => storage_path('framework/cache/data'),
56 | ],
57 |
58 | 'memcached' => [
59 | 'driver' => 'memcached',
60 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
61 | 'sasl' => [
62 | env('MEMCACHED_USERNAME'),
63 | env('MEMCACHED_PASSWORD'),
64 | ],
65 | 'options' => [
66 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
67 | ],
68 | 'servers' => [
69 | [
70 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
71 | 'port' => env('MEMCACHED_PORT', 11211),
72 | 'weight' => 100,
73 | ],
74 | ],
75 | ],
76 |
77 | 'redis' => [
78 | 'driver' => 'redis',
79 | 'connection' => 'cache',
80 | 'lock_connection' => 'default',
81 | ],
82 |
83 | 'dynamodb' => [
84 | 'driver' => 'dynamodb',
85 | 'key' => env('AWS_ACCESS_KEY_ID'),
86 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
87 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
88 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
89 | 'endpoint' => env('DYNAMODB_ENDPOINT'),
90 | ],
91 |
92 | 'octane' => [
93 | 'driver' => 'octane',
94 | ],
95 |
96 | ],
97 |
98 | /*
99 | |--------------------------------------------------------------------------
100 | | Cache Key Prefix
101 | |--------------------------------------------------------------------------
102 | |
103 | | When utilizing the APC, database, memcached, Redis, or DynamoDB cache
104 | | stores there might be other applications using the same cache. For
105 | | that reason, you may prefix every cache key to avoid collisions.
106 | |
107 | */
108 |
109 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
110 |
111 | ];
112 |
--------------------------------------------------------------------------------
/config/cors.php:
--------------------------------------------------------------------------------
1 | ['api/*', 'sanctum/csrf-cookie'],
19 |
20 | 'allowed_methods' => ['*'],
21 |
22 | 'allowed_origins' => ['*'],
23 |
24 | 'allowed_origins_patterns' => [],
25 |
26 | 'allowed_headers' => ['*'],
27 |
28 | 'exposed_headers' => [],
29 |
30 | 'max_age' => 0,
31 |
32 | 'supports_credentials' => false,
33 |
34 | ];
35 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DISK', 'local'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Filesystem Disks
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure as many filesystem "disks" as you wish, and you
24 | | may even configure multiple disks of the same driver. Defaults have
25 | | been set up for each driver as an example of the required values.
26 | |
27 | | Supported Drivers: "local", "ftp", "sftp", "s3"
28 | |
29 | */
30 |
31 | 'disks' => [
32 |
33 | 'local' => [
34 | 'driver' => 'local',
35 | 'root' => storage_path('app'),
36 | 'throw' => false,
37 | ],
38 |
39 | 'public' => [
40 | 'driver' => 'local',
41 | 'root' => storage_path('app/public'),
42 | 'url' => env('APP_URL').'/storage',
43 | 'visibility' => 'public',
44 | 'throw' => false,
45 | ],
46 |
47 | 's3' => [
48 | 'driver' => 's3',
49 | 'key' => env('AWS_ACCESS_KEY_ID'),
50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
51 | 'region' => env('AWS_DEFAULT_REGION'),
52 | 'bucket' => env('AWS_BUCKET'),
53 | 'url' => env('AWS_URL'),
54 | 'endpoint' => env('AWS_ENDPOINT'),
55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
56 | 'throw' => false,
57 | ],
58 |
59 | ],
60 |
61 | /*
62 | |--------------------------------------------------------------------------
63 | | Symbolic Links
64 | |--------------------------------------------------------------------------
65 | |
66 | | Here you may configure the symbolic links that will be created when the
67 | | `storage:link` Artisan command is executed. The array keys should be
68 | | the locations of the links and the values should be their targets.
69 | |
70 | */
71 |
72 | 'links' => [
73 | public_path('storage') => storage_path('app/public'),
74 | ],
75 |
76 | ];
77 |
--------------------------------------------------------------------------------
/config/hashing.php:
--------------------------------------------------------------------------------
1 | 'bcrypt',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Bcrypt Options
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may specify the configuration options that should be used when
26 | | passwords are hashed using the Bcrypt algorithm. This will allow you
27 | | to control the amount of time it takes to hash the given password.
28 | |
29 | */
30 |
31 | 'bcrypt' => [
32 | 'rounds' => env('BCRYPT_ROUNDS', 10),
33 | ],
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | Argon Options
38 | |--------------------------------------------------------------------------
39 | |
40 | | Here you may specify the configuration options that should be used when
41 | | passwords are hashed using the Argon algorithm. These will allow you
42 | | to control the amount of time it takes to hash the given password.
43 | |
44 | */
45 |
46 | 'argon' => [
47 | 'memory' => 65536,
48 | 'threads' => 1,
49 | 'time' => 4,
50 | ],
51 |
52 | ];
53 |
--------------------------------------------------------------------------------
/config/logging.php:
--------------------------------------------------------------------------------
1 | env('LOG_CHANNEL', 'stack'),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Deprecations Log Channel
26 | |--------------------------------------------------------------------------
27 | |
28 | | This option controls the log channel that should be used to log warnings
29 | | regarding deprecated PHP and library features. This allows you to get
30 | | your application ready for upcoming major versions of dependencies.
31 | |
32 | */
33 |
34 | 'deprecations' => [
35 | 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
36 | 'trace' => false,
37 | ],
38 |
39 | /*
40 | |--------------------------------------------------------------------------
41 | | Log Channels
42 | |--------------------------------------------------------------------------
43 | |
44 | | Here you may configure the log channels for your application. Out of
45 | | the box, Laravel uses the Monolog PHP logging library. This gives
46 | | you a variety of powerful log handlers / formatters to utilize.
47 | |
48 | | Available Drivers: "single", "daily", "slack", "syslog",
49 | | "errorlog", "monolog",
50 | | "custom", "stack"
51 | |
52 | */
53 |
54 | 'channels' => [
55 | 'stack' => [
56 | 'driver' => 'stack',
57 | 'channels' => ['single'],
58 | 'ignore_exceptions' => false,
59 | ],
60 |
61 | 'single' => [
62 | 'driver' => 'single',
63 | 'path' => storage_path('logs/laravel.log'),
64 | 'level' => env('LOG_LEVEL', 'debug'),
65 | 'replace_placeholders' => true,
66 | ],
67 |
68 | 'daily' => [
69 | 'driver' => 'daily',
70 | 'path' => storage_path('logs/laravel.log'),
71 | 'level' => env('LOG_LEVEL', 'debug'),
72 | 'days' => 14,
73 | 'replace_placeholders' => true,
74 | ],
75 |
76 | 'slack' => [
77 | 'driver' => 'slack',
78 | 'url' => env('LOG_SLACK_WEBHOOK_URL'),
79 | 'username' => 'Laravel Log',
80 | 'emoji' => ':boom:',
81 | 'level' => env('LOG_LEVEL', 'critical'),
82 | 'replace_placeholders' => true,
83 | ],
84 |
85 | 'papertrail' => [
86 | 'driver' => 'monolog',
87 | 'level' => env('LOG_LEVEL', 'debug'),
88 | 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
89 | 'handler_with' => [
90 | 'host' => env('PAPERTRAIL_URL'),
91 | 'port' => env('PAPERTRAIL_PORT'),
92 | 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
93 | ],
94 | 'processors' => [PsrLogMessageProcessor::class],
95 | ],
96 |
97 | 'stderr' => [
98 | 'driver' => 'monolog',
99 | 'level' => env('LOG_LEVEL', 'debug'),
100 | 'handler' => StreamHandler::class,
101 | 'formatter' => env('LOG_STDERR_FORMATTER'),
102 | 'with' => [
103 | 'stream' => 'php://stderr',
104 | ],
105 | 'processors' => [PsrLogMessageProcessor::class],
106 | ],
107 |
108 | 'syslog' => [
109 | 'driver' => 'syslog',
110 | 'level' => env('LOG_LEVEL', 'debug'),
111 | 'facility' => LOG_USER,
112 | 'replace_placeholders' => true,
113 | ],
114 |
115 | 'errorlog' => [
116 | 'driver' => 'errorlog',
117 | 'level' => env('LOG_LEVEL', 'debug'),
118 | 'replace_placeholders' => true,
119 | ],
120 |
121 | 'null' => [
122 | 'driver' => 'monolog',
123 | 'handler' => NullHandler::class,
124 | ],
125 |
126 | 'emergency' => [
127 | 'path' => storage_path('logs/laravel.log'),
128 | ],
129 | ],
130 |
131 | ];
132 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_MAILER', 'smtp'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Mailer Configurations
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure all of the mailers used by your application plus
24 | | their respective settings. Several examples have been configured for
25 | | you and you are free to add your own as your application requires.
26 | |
27 | | Laravel supports a variety of mail "transport" drivers to be used while
28 | | sending an e-mail. You will specify which one you are using for your
29 | | mailers below. You are free to add additional mailers as required.
30 | |
31 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
32 | | "postmark", "log", "array", "failover"
33 | |
34 | */
35 |
36 | 'mailers' => [
37 | 'smtp' => [
38 | 'transport' => 'smtp',
39 | 'url' => env('MAIL_URL'),
40 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
41 | 'port' => env('MAIL_PORT', 587),
42 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
43 | 'username' => env('MAIL_USERNAME'),
44 | 'password' => env('MAIL_PASSWORD'),
45 | 'timeout' => null,
46 | 'local_domain' => env('MAIL_EHLO_DOMAIN'),
47 | ],
48 |
49 | 'ses' => [
50 | 'transport' => 'ses',
51 | ],
52 |
53 | 'mailgun' => [
54 | 'transport' => 'mailgun',
55 | // 'client' => [
56 | // 'timeout' => 5,
57 | // ],
58 | ],
59 |
60 | 'postmark' => [
61 | 'transport' => 'postmark',
62 | // 'client' => [
63 | // 'timeout' => 5,
64 | // ],
65 | ],
66 |
67 | 'sendmail' => [
68 | 'transport' => 'sendmail',
69 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
70 | ],
71 |
72 | 'log' => [
73 | 'transport' => 'log',
74 | 'channel' => env('MAIL_LOG_CHANNEL'),
75 | ],
76 |
77 | 'array' => [
78 | 'transport' => 'array',
79 | ],
80 |
81 | 'failover' => [
82 | 'transport' => 'failover',
83 | 'mailers' => [
84 | 'smtp',
85 | 'log',
86 | ],
87 | ],
88 | ],
89 |
90 | /*
91 | |--------------------------------------------------------------------------
92 | | Global "From" Address
93 | |--------------------------------------------------------------------------
94 | |
95 | | You may wish for all e-mails sent by your application to be sent from
96 | | the same address. Here, you may specify a name and address that is
97 | | used globally for all e-mails that are sent by your application.
98 | |
99 | */
100 |
101 | 'from' => [
102 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
103 | 'name' => env('MAIL_FROM_NAME', 'Example'),
104 | ],
105 |
106 | /*
107 | |--------------------------------------------------------------------------
108 | | Markdown Mail Settings
109 | |--------------------------------------------------------------------------
110 | |
111 | | If you are using Markdown based email rendering, you may configure your
112 | | theme and component paths here, allowing you to customize the design
113 | | of the emails. Or, you may simply stick with the Laravel defaults!
114 | |
115 | */
116 |
117 | 'markdown' => [
118 | 'theme' => 'default',
119 |
120 | 'paths' => [
121 | resource_path('views/vendor/mail'),
122 | ],
123 | ],
124 |
125 | ];
126 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_CONNECTION', 'sync'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Queue Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure the connection information for each server that
24 | | is used by your application. A default configuration has been added
25 | | for each back-end shipped with Laravel. You are free to add more.
26 | |
27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'retry_after' => 90,
42 | 'after_commit' => false,
43 | ],
44 |
45 | 'beanstalkd' => [
46 | 'driver' => 'beanstalkd',
47 | 'host' => 'localhost',
48 | 'queue' => 'default',
49 | 'retry_after' => 90,
50 | 'block_for' => 0,
51 | 'after_commit' => false,
52 | ],
53 |
54 | 'sqs' => [
55 | 'driver' => 'sqs',
56 | 'key' => env('AWS_ACCESS_KEY_ID'),
57 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
58 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
59 | 'queue' => env('SQS_QUEUE', 'default'),
60 | 'suffix' => env('SQS_SUFFIX'),
61 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
62 | 'after_commit' => false,
63 | ],
64 |
65 | 'redis' => [
66 | 'driver' => 'redis',
67 | 'connection' => 'default',
68 | 'queue' => env('REDIS_QUEUE', 'default'),
69 | 'retry_after' => 90,
70 | 'block_for' => null,
71 | 'after_commit' => false,
72 | ],
73 |
74 | ],
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | Job Batching
79 | |--------------------------------------------------------------------------
80 | |
81 | | The following options configure the database and table that store job
82 | | batching information. These options can be updated to any database
83 | | connection and table which has been defined by your application.
84 | |
85 | */
86 |
87 | 'batching' => [
88 | 'database' => env('DB_CONNECTION', 'mysql'),
89 | 'table' => 'job_batches',
90 | ],
91 |
92 | /*
93 | |--------------------------------------------------------------------------
94 | | Failed Queue Jobs
95 | |--------------------------------------------------------------------------
96 | |
97 | | These options configure the behavior of failed queue job logging so you
98 | | can control which database and table are used to store the jobs that
99 | | have failed. You may change them to any database / table you wish.
100 | |
101 | */
102 |
103 | 'failed' => [
104 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
105 | 'database' => env('DB_CONNECTION', 'mysql'),
106 | 'table' => 'failed_jobs',
107 | ],
108 |
109 | ];
110 |
--------------------------------------------------------------------------------
/config/sanctum.php:
--------------------------------------------------------------------------------
1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
19 | '%s%s',
20 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
21 | Sanctum::currentApplicationUrlWithPort()
22 | ))),
23 |
24 | /*
25 | |--------------------------------------------------------------------------
26 | | Sanctum Guards
27 | |--------------------------------------------------------------------------
28 | |
29 | | This array contains the authentication guards that will be checked when
30 | | Sanctum is trying to authenticate a request. If none of these guards
31 | | are able to authenticate the request, Sanctum will use the bearer
32 | | token that's present on an incoming request for authentication.
33 | |
34 | */
35 |
36 | 'guard' => ['web'],
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Expiration Minutes
41 | |--------------------------------------------------------------------------
42 | |
43 | | This value controls the number of minutes until an issued token will be
44 | | considered expired. If this value is null, personal access tokens do
45 | | not expire. This won't tweak the lifetime of first-party sessions.
46 | |
47 | */
48 |
49 | 'expiration' => null,
50 |
51 | /*
52 | |--------------------------------------------------------------------------
53 | | Sanctum Middleware
54 | |--------------------------------------------------------------------------
55 | |
56 | | When authenticating your first-party SPA with Sanctum you may need to
57 | | customize some of the middleware Sanctum uses while processing the
58 | | request. You may change the middleware listed below as required.
59 | |
60 | */
61 |
62 | 'middleware' => [
63 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
64 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
65 | ],
66 |
67 | ];
68 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
21 | 'scheme' => 'https',
22 | ],
23 |
24 | 'postmark' => [
25 | 'token' => env('POSTMARK_TOKEN'),
26 | ],
27 |
28 | 'ses' => [
29 | 'key' => env('AWS_ACCESS_KEY_ID'),
30 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
31 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
32 | ],
33 |
34 | ];
35 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('views'),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => env(
32 | 'VIEW_COMPILED_PATH',
33 | realpath(storage_path('framework/views'))
34 | ),
35 |
36 | ];
37 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite*
2 |
--------------------------------------------------------------------------------
/database/factories/CompanyFactory.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | class CompanyFactory extends Factory
11 | {
12 | /**
13 | * Define the model's default state.
14 | *
15 | * @return array
16 | */
17 | public function definition(): array
18 | {
19 | return [
20 | 'name' => fake()->company(),
21 | 'url' => fake()->domainName(),
22 | ];
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/database/factories/ContactFactory.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | class ContactFactory extends Factory
11 | {
12 | /**
13 | * Define the model's default state.
14 | *
15 | * @return array
16 | */
17 | public function definition(): array
18 | {
19 | $firstName = fake()->firstName();
20 | $lastName = fake()->lastName();
21 | return [
22 | 'name' => $firstName . ' ' . $lastName,
23 | 'email' => fake()->unique()->companyEmail(),
24 | 'phone_number' => fake()->phoneNumber,
25 | ];
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/database/factories/DealFactory.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | class DealFactory extends Factory
11 | {
12 | const DEAL_STATUSES = [
13 | 'lead', 'to contact', 'contacted', 'won', 'lost'
14 | ];
15 |
16 | /**
17 | * Define the model's default state.
18 | *
19 | * @return array
20 | */
21 | public function definition(): array
22 | {
23 | return [
24 | 'value' => fake()->numberBetween(1000, 100000),
25 | 'status' => fake()->randomElement(self::DEAL_STATUSES),
26 | ];
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/database/factories/OrganizationFactory.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | class OrganizationFactory extends Factory
11 | {
12 | /**
13 | * Define the model's default state.
14 | *
15 | * @return array
16 | */
17 | public function definition(): array
18 | {
19 | return [
20 | 'name' => fake()->company(),
21 | ];
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/database/factories/UserFactory.php:
--------------------------------------------------------------------------------
1 |
10 | */
11 | class UserFactory extends Factory
12 | {
13 | /**
14 | * Define the model's default state.
15 | *
16 | * @return array
17 | */
18 | public function definition(): array
19 | {
20 | return [
21 | 'name' => fake()->name(),
22 | 'email' => fake()->unique()->safeEmail(),
23 | 'email_verified_at' => now(),
24 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
25 | 'remember_token' => Str::random(10),
26 | ];
27 | }
28 |
29 | /**
30 | * Indicate that the model's email address should be unverified.
31 | */
32 | public function unverified(): static
33 | {
34 | return $this->state(fn (array $attributes) => [
35 | 'email_verified_at' => null,
36 | ]);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | id();
16 | $table->string('name');
17 | $table->string('email')->unique();
18 | $table->timestamp('email_verified_at')->nullable();
19 | $table->string('password');
20 | $table->rememberToken();
21 | $table->timestamps();
22 | });
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | */
28 | public function down(): void
29 | {
30 | Schema::dropIfExists('users');
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php:
--------------------------------------------------------------------------------
1 | string('email')->primary();
16 | $table->string('token');
17 | $table->timestamp('created_at')->nullable();
18 | });
19 | }
20 |
21 | /**
22 | * Reverse the migrations.
23 | */
24 | public function down(): void
25 | {
26 | Schema::dropIfExists('password_reset_tokens');
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/database/migrations/2019_08_19_000000_create_failed_jobs_table.php:
--------------------------------------------------------------------------------
1 | id();
16 | $table->string('uuid')->unique();
17 | $table->text('connection');
18 | $table->text('queue');
19 | $table->longText('payload');
20 | $table->longText('exception');
21 | $table->timestamp('failed_at')->useCurrent();
22 | });
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | */
28 | public function down(): void
29 | {
30 | Schema::dropIfExists('failed_jobs');
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php:
--------------------------------------------------------------------------------
1 | id();
16 | $table->morphs('tokenable');
17 | $table->string('name');
18 | $table->string('token', 64)->unique();
19 | $table->text('abilities')->nullable();
20 | $table->timestamp('last_used_at')->nullable();
21 | $table->timestamp('expires_at')->nullable();
22 | $table->timestamps();
23 | });
24 | }
25 |
26 | /**
27 | * Reverse the migrations.
28 | */
29 | public function down(): void
30 | {
31 | Schema::dropIfExists('personal_access_tokens');
32 | }
33 | };
34 |
--------------------------------------------------------------------------------
/database/migrations/2023_06_14_085749_add_avatar_to_users_table.php:
--------------------------------------------------------------------------------
1 | string('avatar_url')->nullable();
16 | });
17 | }
18 |
19 | /**
20 | * Reverse the migrations.
21 | */
22 | public function down(): void
23 | {
24 | Schema::table('users', function (Blueprint $table) {
25 | $table->dropColumn('avatar_url');
26 | });
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/database/migrations/2023_06_14_142103_create_organizations_table.php:
--------------------------------------------------------------------------------
1 | id();
16 | $table->string('name')->unique();
17 | $table->timestamps();
18 | });
19 | }
20 |
21 | /**
22 | * Reverse the migrations.
23 | */
24 | public function down(): void
25 | {
26 | Schema::dropIfExists('organizations');
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/database/migrations/2023_06_14_142559_add_organization_to_users.php:
--------------------------------------------------------------------------------
1 | foreignId('organization_id')->constrained();
16 | });
17 | }
18 |
19 | /**
20 | * Reverse the migrations.
21 | */
22 | public function down(): void
23 | {
24 | Schema::table('users', function (Blueprint $table) {
25 | //
26 | });
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/database/migrations/2023_06_14_144622_create_companies_table.php:
--------------------------------------------------------------------------------
1 | id();
16 | $table->string('name');
17 | $table->string('url');
18 | $table->foreignId('organization_id')->constrained();
19 | $table->timestamps();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | */
26 | public function down(): void
27 | {
28 | Schema::dropIfExists('companies');
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/database/migrations/2023_06_14_150142_create_contacts_table.php:
--------------------------------------------------------------------------------
1 | id();
16 | $table->string('name');
17 | $table->string('email');
18 | $table->string('phone_number');
19 | $table->foreignId('company_id')->constrained();
20 | $table->timestamps();
21 | });
22 | }
23 |
24 | /**
25 | * Reverse the migrations.
26 | */
27 | public function down(): void
28 | {
29 | Schema::dropIfExists('contacts');
30 | }
31 | };
32 |
--------------------------------------------------------------------------------
/database/migrations/2023_06_14_162820_create_deals_table.php:
--------------------------------------------------------------------------------
1 | id();
16 | $table->foreignId('organization_id')->constrained();
17 | $table->foreignId('company_id')->constrained();
18 | $table->foreignId('contact_id')->constrained();
19 | $table->integer('value');
20 | $table->string('status');
21 | $table->timestamps();
22 | });
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | */
28 | public function down(): void
29 | {
30 | Schema::dropIfExists('deals');
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/database/migrations/2023_06_20_140920_add_meilisearch_token_to_organizations.php:
--------------------------------------------------------------------------------
1 | text('meilisearch_token')->nullable();
16 | });
17 | }
18 |
19 | /**
20 | * Reverse the migrations.
21 | */
22 | public function down(): void
23 | {
24 | Schema::table('organizations', function (Blueprint $table) {
25 | //
26 | });
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/database/seeders/CompanySeeder.php:
--------------------------------------------------------------------------------
1 | CSV_FILE);
33 |
34 | $companies = array_filter($dataset[0], function ($row, $index) {
35 | return ($index > 0);
36 | }, ARRAY_FILTER_USE_BOTH);
37 |
38 | Organization::all()->each(function (Organization $organization) use ($companies) {
39 | $companiesToCreate = fake()->randomElements($companies, 20);
40 | foreach ($companiesToCreate as $row) {
41 | // Get company attributes from CSV row
42 | $companyAttributes = [
43 | 'name' => $row[$this->NAME_COLUMN_INDEX],
44 | 'url' => $row[$this->URL_COLUMN_INDEX],
45 | ];
46 | // Create company belonging to organization
47 | Company::factory()->for($organization)->create($companyAttributes);
48 | // $organization->companies()->save(
49 | // Company::factory()->make($companyAttributes)
50 | // );
51 | }
52 | });
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/database/seeders/ContactSeeder.php:
--------------------------------------------------------------------------------
1 | each(function (Company $company) {
19 | $contacts = Contact::factory()->count(5)->make();
20 | $contacts->each(function (Contact $contact) use ($company) {
21 | $sanizedName = filter_var($contact->name, FILTER_SANITIZE_URL);
22 | $contact->email = strtolower($sanizedName) . '@' . $company->getEmailDomain();
23 | });
24 | $company->contacts()->saveMany($contacts);
25 | });
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/database/seeders/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call([
16 | OrganizationSeeder::class,
17 | UserSeeder::class,
18 | CompanySeeder::class,
19 | ContactSeeder::class,
20 | DealSeeder::class,
21 | ]);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/database/seeders/DealSeeder.php:
--------------------------------------------------------------------------------
1 | each(function (Organization $organization) {
19 | $organization->contacts->each(function (Contact $contact) use ($organization) {
20 | $organization->deals()->save(
21 | Deal::factory()->make([
22 | 'company_id' => $contact->company->id,
23 | 'contact_id' => $contact->id,
24 | ])
25 | );
26 | });
27 | });
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/database/seeders/OrganizationSeeder.php:
--------------------------------------------------------------------------------
1 | create([
17 | 'name' => 'Acme',
18 | ]);
19 | Organization::factory()->create([
20 | 'name' => 'Example',
21 | ]);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/database/seeders/UserSeeder.php:
--------------------------------------------------------------------------------
1 | create([
17 | 'name' => 'John Doe',
18 | 'email' => config('app.seeders.user1.email'),
19 | 'avatar_url' => 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=987&q=80',
20 | 'organization_id' => 1,
21 | ]);
22 |
23 | User::factory()->create([
24 | 'name' => 'Jane Doe',
25 | 'email' => config('app.seeders.user2.email'),
26 | 'avatar_url' => 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1364&q=80',
27 | 'organization_id' => 2,
28 | ]);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | services:
2 | laravel.test:
3 | build:
4 | context: ./vendor/laravel/sail/runtimes/8.2
5 | dockerfile: Dockerfile
6 | args:
7 | WWWGROUP: '${WWWGROUP}'
8 | image: sail-8.2/app
9 | extra_hosts:
10 | - 'host.docker.internal:host-gateway'
11 | ports:
12 | - '${APP_PORT:-80}:80'
13 | - '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
14 | - '${STORYBOOK_PORT:-6006}:${STORYBOOK_PORT:-6006}'
15 | environment:
16 | WWWUSER: '${WWWUSER}'
17 | LARAVEL_SAIL: 1
18 | XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
19 | XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
20 | IGNITION_LOCAL_SITES_PATH: '${PWD}'
21 | # Fixes issue with Blast crashing because of undefined $SHELL
22 | SHELL: /bin/bash
23 | volumes:
24 | - '.:/var/www/html'
25 | networks:
26 | - sail
27 | depends_on:
28 | - mysql
29 | - meilisearch
30 | mysql:
31 | image: 'mysql/mysql-server:8.0'
32 | ports:
33 | - '${FORWARD_DB_PORT:-3306}:3306'
34 | environment:
35 | MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
36 | MYSQL_ROOT_HOST: '%'
37 | MYSQL_DATABASE: '${DB_DATABASE}'
38 | MYSQL_USER: '${DB_USERNAME}'
39 | MYSQL_PASSWORD: '${DB_PASSWORD}'
40 | MYSQL_ALLOW_EMPTY_PASSWORD: 1
41 | volumes:
42 | - 'sail-mysql:/var/lib/mysql'
43 | - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
44 | networks:
45 | - sail
46 | healthcheck:
47 | test:
48 | - CMD
49 | - mysqladmin
50 | - ping
51 | - '-p${DB_PASSWORD}'
52 | retries: 3
53 | timeout: 5s
54 | redis:
55 | image: 'redis:alpine'
56 | ports:
57 | - '${FORWARD_REDIS_PORT:-6379}:6379'
58 | volumes:
59 | - 'sail-redis:/data'
60 | networks:
61 | - sail
62 | healthcheck:
63 | test:
64 | - CMD
65 | - redis-cli
66 | - ping
67 | retries: 3
68 | timeout: 5s
69 | meilisearch:
70 | image: 'getmeili/meilisearch:v1.10.0'
71 | environment:
72 | MEILI_MASTER_KEY: '${MEILISEARCH_MASTER_KEY}'
73 | ports:
74 | - '${FORWARD_MEILISEARCH_PORT:-7700}:7700'
75 | volumes:
76 | - 'sail-meilisearch:/meili_data'
77 | networks:
78 | - sail
79 | healthcheck:
80 | test: set -o pipefail;curl -fsS http://localhost:7700/health | grep -q '{"status":"available"}'
81 | retries: 3
82 | timeout: 5s
83 | networks:
84 | sail:
85 | driver: bridge
86 | volumes:
87 | sail-mysql:
88 | driver: local
89 | sail-redis:
90 | driver: local
91 | sail-meilisearch:
92 | driver: local
93 |
--------------------------------------------------------------------------------
/eslint.config.js:
--------------------------------------------------------------------------------
1 | import js from '@eslint/js'
2 | import eslintPluginVue from 'eslint-plugin-vue'
3 | import ts from 'typescript-eslint'
4 |
5 | export default ts.config(
6 | js.configs.recommended,
7 | ...ts.configs.recommended,
8 | ...eslintPluginVue.configs['flat/recommended'],
9 | {
10 | files: ['**/*.vue', '**/*.ts', '**/*.js'],
11 | languageOptions: {
12 | parserOptions: {
13 | parser: '@typescript-eslint/parser',
14 | },
15 | },
16 | rules: {
17 | 'comma-dangle': ['error', 'always-multiline'],
18 | 'quotes': ['error', 'single'],
19 | 'semi': ['error', 'never'],
20 | },
21 | },
22 | )
23 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "type": "module",
4 | "scripts": {
5 | "dev": "vite",
6 | "build": "vite build",
7 | "lint": "eslint ./resources/js/**/*.{js,ts,vue}"
8 | },
9 | "engines": {
10 | "node": "20.17.0"
11 | },
12 | "devDependencies": {
13 | "@tailwindcss/forms": "^0.5.3",
14 | "@vitejs/plugin-vue": "^4.2.3",
15 | "autoprefixer": "^10.4.14",
16 | "axios": "^1.1.2",
17 | "eslint": "^9.4.0",
18 | "eslint-plugin-vue": "^9.26.0",
19 | "laravel-vite-plugin": "^0.7.5",
20 | "postcss": "^8.4.24",
21 | "tailwindcss": "^3.3.2",
22 | "typescript": "^5.5.4",
23 | "typescript-eslint": "^8.3.0",
24 | "vite": "^4.0.0"
25 | },
26 | "dependencies": {
27 | "@meilisearch/instant-meilisearch": "^0.20.0",
28 | "@vueuse/core": "^10.2.1",
29 | "jenesius-vue-modal": "^1.11.2",
30 | "meilisearch": "^0.42.0",
31 | "vue": "^3.3.4",
32 | "vue-instantsearch": "4.17.0"
33 | },
34 | "resolutions": {
35 | "strip-ansi": "6.0.1"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 | ./tests/Feature
13 |
14 |
15 |
16 |
17 | ./app
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | }
7 |
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 |
3 | Options -MultiViews -Indexes
4 |
5 |
6 | RewriteEngine On
7 |
8 | # Handle Authorization Header
9 | RewriteCond %{HTTP:Authorization} .
10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
11 |
12 | # Redirect Trailing Slashes If Not A Folder...
13 | RewriteCond %{REQUEST_FILENAME} !-d
14 | RewriteCond %{REQUEST_URI} (.+)/$
15 | RewriteRule ^ %1 [L,R=301]
16 |
17 | # Send Requests To Front Controller...
18 | RewriteCond %{REQUEST_FILENAME} !-d
19 | RewriteCond %{REQUEST_FILENAME} !-f
20 | RewriteRule ^ index.php [L]
21 |
22 |
--------------------------------------------------------------------------------
/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meilisearch/saas-demo/51a0b3934a914d35f0c1e64952c8ac63de7ab7af/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/public/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meilisearch/saas-demo/51a0b3934a914d35f0c1e64952c8ac63de7ab7af/public/favicon-16x16.png
--------------------------------------------------------------------------------
/public/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meilisearch/saas-demo/51a0b3934a914d35f0c1e64952c8ac63de7ab7af/public/favicon-32x32.png
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/meilisearch/saas-demo/51a0b3934a914d35f0c1e64952c8ac63de7ab7af/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class);
50 |
51 | $response = $kernel->handle(
52 | $request = Request::capture()
53 | )->send();
54 |
55 | $kernel->terminate($request, $response);
56 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/resources/assets/loading-illustration.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/resources/assets/meilisearch-logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/resources/css/app.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
--------------------------------------------------------------------------------
/resources/js/app-search.js:
--------------------------------------------------------------------------------
1 | import { createApp } from 'vue'
2 | // import InstantSearch from 'vue-instantsearch/vue3/es'
3 | // import { container } from 'jenesius-vue-modal'
4 |
5 | import AppSearch from './components/header/AppSearch.vue'
6 |
7 | const app = createApp({
8 | components: {
9 | // Meilisearch,
10 | // VueModalContainer: container,
11 | AppSearch,
12 | },
13 | })
14 |
15 | // app.use(InstantSearch)
16 |
17 | app.mount('#app-search')
18 |
--------------------------------------------------------------------------------
/resources/js/app.js:
--------------------------------------------------------------------------------
1 | import.meta.glob([
2 | '../assets/**',
3 | ])
4 |
5 |
--------------------------------------------------------------------------------
/resources/js/components/header/AppSearch.vue:
--------------------------------------------------------------------------------
1 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/resources/js/components/header/CompanyCard.vue:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
21 |
22 |
23 |
28 |
29 | {{ props.companyName }}
30 |
31 |
32 |
33 |
34 | {{ props.contactCount }} contacts
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/resources/js/components/header/ContactCard.vue:
--------------------------------------------------------------------------------
1 |
13 | ^
14 |
15 |
19 |
20 |
21 |
24 |
25 |
26 | {{ props.contactName }}
27 |
28 |
29 | {{ props.contactEmail }}
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/resources/js/components/header/DealCard.vue:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
18 |
19 |
20 |
21 | {{ props.companyName }}
22 |
23 |
27 | {{ props.dealStatus }}
28 |
29 |
30 |
31 | {{ formatDealAmount(props.dealAmount) }}
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/resources/js/components/header/ResultCard.vue:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/resources/js/components/header/SearchButton.vue:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
17 |
18 |
--------------------------------------------------------------------------------
/resources/js/components/header/SearchModal.vue:
--------------------------------------------------------------------------------
1 |
57 |
58 |
59 |
60 |
61 |
62 |
75 |
76 |
77 |
81 |
82 |
83 | Top result
84 |
85 |
89 |
90 |
91 | Other results
92 |
93 |
94 | -
98 |
105 |
112 |
119 |
120 |
121 |
122 |
123 |
124 |
125 | No results found for {{ query }}
126 |
127 |
128 |
129 |
130 |
134 |

139 |
140 | Search results will appear here.
141 |
142 |
143 |
144 |
145 |
146 |
147 |
156 |
--------------------------------------------------------------------------------
/resources/js/components/header/SearchModalLayout.vue:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
--------------------------------------------------------------------------------
/resources/js/components/header/TopResultCard.vue:
--------------------------------------------------------------------------------
1 |
103 |
104 |
105 |
109 |
110 |
111 | {{ hitConfig.type }}
112 |
113 |
114 |
115 |
116 |
121 |
122 |
123 |
124 | {{ props.hit.company_name }}
125 | {{ props.hit.name }}
126 |
127 |
131 |
132 | {{ props.hit.number_of_contacts }} contacts
133 |
134 |
138 | {{ props.hit.email }}
139 |
140 |
144 |
{{ formatDealAmount(props.hit.value) }}
145 |
149 | {{ props.hit.status }}
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/resources/js/components/tables/CompanyList.vue:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 | Name
21 | |
22 |
23 |
24 |
25 |
26 |
33 |
36 |
37 | ![]()
41 |
42 |
46 | |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/resources/js/components/tables/ContactList.vue:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 | Name
21 | |
22 |
23 | Company
24 | |
25 |
26 | Email
27 | |
28 |
29 | Phone
30 | |
31 |
32 |
33 |
34 |
35 |
42 |
45 |
46 | ![]()
50 |
51 |
55 | |
56 |
57 |
58 |
59 | ![{{ contact.company_name }}]()
63 |
64 |
68 |
69 | |
70 |
71 |
75 | |
76 |
77 |
81 | |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/resources/js/components/tables/DealList.vue:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 | Company
21 | |
22 |
23 | Prospect
24 | |
25 |
26 | Status
27 | |
28 |
29 | Value
30 | |
31 |
32 |
33 |
34 |
35 |
42 |
43 |
44 |
45 | ![{{ deal.company_name }}]()
49 |
50 |
54 |
55 | |
56 |
57 |
58 | ![]()
62 |
63 |
67 | |
68 |
69 |
73 |
78 |
79 | |
80 |
81 | {{ new Intl.NumberFormat('en-US', {
82 | style: 'currency', currency: 'USD',
83 | }).format(deal.value) }}
84 | |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/resources/js/components/tables/InstantsearchProvider.vue:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/resources/js/components/tables/SearchBar.vue:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
21 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/resources/js/components/tables/SearchFilterMenu.vue:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/resources/js/components/tables/SearchSortBy.vue:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/resources/js/components/ui/OrganizationLogo.vue:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
Logo
11 |
![]()
16 |
17 |
18 |
--------------------------------------------------------------------------------
/resources/js/components/ui/SearchIcon.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/resources/js/components/ui/SearchInput.vue:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/resources/js/components/ui/SearchResetButton.vue:
--------------------------------------------------------------------------------
1 |
2 |
21 |
22 |
--------------------------------------------------------------------------------
/resources/js/components/ui/UserAvatar.vue:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
20 |
![]()
24 |
25 |
26 |
--------------------------------------------------------------------------------
/resources/js/components/ui/icons/micro/BriefcaseIcon.vue:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
--------------------------------------------------------------------------------
/resources/js/components/ui/icons/micro/BuildingOfficeIcon.vue:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
--------------------------------------------------------------------------------
/resources/js/components/ui/icons/micro/UserGroupIcon.vue:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
--------------------------------------------------------------------------------
/resources/js/components/ui/icons/micro/UserIcon.vue:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
--------------------------------------------------------------------------------
/resources/js/components/ui/icons/mini/UserGroupIcon.vue:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
--------------------------------------------------------------------------------
/resources/js/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | interface ImportMeta {
4 | readonly env: ImportMetaEnv
5 | }
6 |
7 | interface ImportMetaEnv {
8 | readonly VITE_MEILISEARCH_HOST: string
9 | // Add other environment variables here if needed
10 | }
11 |
--------------------------------------------------------------------------------
/resources/js/table-search.js:
--------------------------------------------------------------------------------
1 | import { createApp } from 'vue'
2 | import InstantSearch from 'vue-instantsearch/vue3/es'
3 |
4 | // Components
5 | import InstantsearchProvider from './components/tables/InstantsearchProvider.vue'
6 | import SearchBar from './components/tables/SearchBar.vue'
7 | import SearchFilterMenu from './components/tables/SearchFilterMenu.vue'
8 | import SearchSortBy from './components/tables/SearchSortBy.vue'
9 | import DealList from './components/tables/DealList.vue'
10 | import ContactList from './components/tables/ContactList.vue'
11 | import CompanyList from './components/tables/CompanyList.vue'
12 |
13 | const app = createApp({
14 | components: {
15 | InstantsearchProvider,
16 | SearchBar,
17 | SearchSortBy,
18 | SearchFilterMenu,
19 | CompanyList,
20 | ContactList,
21 | DealList,
22 | },
23 | })
24 |
25 | app.use(InstantSearch)
26 |
27 | app.mount('#table-search')
28 |
--------------------------------------------------------------------------------
/resources/js/utils.ts:
--------------------------------------------------------------------------------
1 | export const navigateToDataUrl = (event: MouseEvent) => {
2 | const parentRow = (event.target as HTMLElement).closest('tr')
3 | if (parentRow && parentRow.dataset.url) {
4 | window.location.href = parentRow.dataset.url
5 | }
6 | }
7 |
8 | export const getDealStatusClass = (status: string) => {
9 | switch (status) {
10 | case 'won':
11 | return 'bg-green-50 text-green-500'
12 | case 'lost':
13 | return 'bg-red-50 text-red-500'
14 | case 'contacted':
15 | return 'bg-yellow-50 text-yellow-500'
16 | case 'to contact':
17 | return 'bg-blue-50 text-blue-500'
18 | default:
19 | return 'bg-gray-50 text-gray-500'
20 | }
21 | }
22 |
23 | export const formatDealAmount = (amount: number) => {
24 | return new Intl.NumberFormat('en-US', {
25 | style: 'currency', currency: 'USD',
26 | }).format(amount)
27 | }
28 |
--------------------------------------------------------------------------------
/resources/views/app.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | {{ env('APP_NAME') }}
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | @vite('resources/css/app.css')
21 |
22 | @env('production')
23 |
24 |
25 | @endenv
26 |
27 |
28 |
29 | {{-- Header --}}
30 |
32 |
33 |
34 | {{-- Side menu --}}
35 |
36 |
38 |
39 |
40 | {{-- Content --}}
41 |
42 |
43 | @yield('content')
44 |
45 |
46 |
47 | @stack('scripts')
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/resources/views/companies/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.table')
2 |
3 | @section('title', 'Companies')
4 |
5 | @section('sort')
6 | @php
7 | $sortingOptions = [['value' => 'companies:name:asc', 'label' => 'Sort by Name'], ['value' => 'companies:name:desc', 'label' => 'Sort by Name (descending)']];
8 | @endphp
9 |
10 | @endsection
11 |
12 | @section('search-bar')
13 |
14 | @endsection
15 |
16 | @section('table')
17 |
18 | @endsection
19 |
--------------------------------------------------------------------------------
/resources/views/companies/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.resource')
2 |
3 | @section('title')
4 |
5 |
6 |

7 |
8 |
{{ $company->name }}
9 |
10 | @endsection
11 |
12 | @section('back-button-text', 'Back to Companies')
13 |
14 | @section('resource')
15 |
16 |
17 | {{ $company->deals->count() }} deals
18 |
19 |
28 |
29 | @endsection
30 |
--------------------------------------------------------------------------------
/resources/views/components/app-search.blade.php:
--------------------------------------------------------------------------------
1 | @props(['meilisearchToken'])
2 |
3 |
6 |
7 | @push('scripts')
8 | @vite('resources/js/app-search.js')
9 | @endpush
10 |
--------------------------------------------------------------------------------
/resources/views/components/navbar.blade.php:
--------------------------------------------------------------------------------
1 | @props(['organizationLogoUrl', 'organizationName', 'meilisearchToken'])
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Meilisearch SaaS demo
12 | {{ $organizationName }} workspace
13 |
14 |
15 |
16 |
17 |
18 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/resources/views/components/side-menu-item.blade.php:
--------------------------------------------------------------------------------
1 | @props(['href', 'isActive' => false])
2 |
3 | !$isActive,
6 | 'rounded-lg bg-gray-100 text-gray-700' => $isActive,
7 | ])>
8 | {{ $icon }}
9 |
10 | {{ $slot }}
11 |
12 |
--------------------------------------------------------------------------------
/resources/views/components/side-menu.blade.php:
--------------------------------------------------------------------------------
1 | @props(['userAvatarUrl', 'userName', 'userEmail', 'otherUserEmail'])
2 |
3 |
4 |
5 |
30 |
31 |
32 |
33 |
34 | Try switching to another user by clicking on the user below 👇
35 |
36 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/resources/views/components/ui/avatar.blade.php:
--------------------------------------------------------------------------------
1 | @props(['imageUrl'])
2 |
3 |
4 |
5 |

6 |
7 |
--------------------------------------------------------------------------------
/resources/views/components/ui/company-icon.blade.php:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/resources/views/components/ui/contact-icon.blade.php:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/resources/views/components/ui/discord-icon.blade.php:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/resources/views/components/ui/github-icon.blade.php:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/resources/views/components/ui/home-icon.blade.php:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/resources/views/components/ui/organization-logo.blade.php:
--------------------------------------------------------------------------------
1 | @props(['organizationName', 'logoUrl'])
2 |
3 |
4 |
Logo
5 |

6 |
7 |
--------------------------------------------------------------------------------
/resources/views/components/ui/twitter-icon.blade.php:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/resources/views/components/ui/web-icon.blade.php:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/resources/views/contacts/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.table')
2 |
3 | @section('title', 'Contacts')
4 |
5 | @section('sort')
6 | @php
7 | $sortingOptions = [['value' => 'contacts:name:asc', 'label' => 'Sort by Name'], ['value' => 'contacts:name:desc', 'label' => 'Sort by Name (descending)'], ['value' => 'contacts:company_name:asc', 'label' => 'Sort by Company'], ['value' => 'contacts:company_name:desc', 'label' => 'Sort by Company (descending)']];
8 | @endphp
9 |
10 | @endsection
11 |
12 | @section('search-bar')
13 |
14 | @endsection
15 |
16 | @section('table')
17 |
18 | @endsection
19 |
--------------------------------------------------------------------------------
/resources/views/contacts/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.resource')
2 |
3 | @section('title')
4 |
5 |
6 |

7 |
8 |
{{ $contact->name }}
9 |
10 | @endsection
11 |
12 | @section('back-button-text', 'Back to Contacts')
13 |
14 | @section('resource')
15 |
16 |
17 |
18 |
22 |
23 |
24 |
25 |
26 |
27 | {{ $contact->email }}
28 |
29 |
30 | {{ $contact->phone_number }}
31 |
32 |
33 |
34 |
35 |
36 |

38 |
39 |
40 |
41 | @endsection
42 |
--------------------------------------------------------------------------------
/resources/views/deals/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.table')
2 |
3 | @section('title', 'Deals')
4 |
5 | @section('filter')
6 |
7 | @endsection
8 |
9 | @section('sort')
10 | @php
11 | $sortingOptions = [['value' => 'deals:company_name:asc', 'label' => 'Sort by Company'], ['value' => 'deals:company_name:desc', 'label' => 'Sort by Company (descending)'], ['value' => 'deals:status:asc', 'label' => 'Sort by Status'], ['value' => 'deals:status:desc', 'label' => 'Sort by Status (descending)'], ['value' => 'deals:value:asc', 'label' => 'Sort by Value'], ['value' => 'deals:value:desc', 'label' => 'Sort by Value (descending)']];
12 | @endphp
13 |
14 | @endsection
15 |
16 | @section('search-bar')
17 |
18 | @endsection
19 |
20 | @section('table')
21 |
22 | @endsection
23 |
--------------------------------------------------------------------------------
/resources/views/deals/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.resource')
2 |
3 | @section('title')
4 |
5 |
6 |

7 |
8 |
{{ $deal->company->name }} deal
9 |
10 | @endsection
11 |
12 | @section('back-button-text', 'Back to Deals')
13 |
14 | @section('resource')
15 |
16 |
17 | ${{ number_format($deal->value, 2, ',', '.') }}
18 |
19 |
20 |
21 | Status:
22 | {{ $deal->status }}
23 |
24 |
25 |
32 |
33 |
38 |
39 | @endsection
40 |
--------------------------------------------------------------------------------
/resources/views/layouts/resource.blade.php:
--------------------------------------------------------------------------------
1 | @extends('app')
2 |
3 | @section('content')
4 |
5 |
6 |
7 | @yield('title')
8 |
9 |
19 |
20 |
21 |
22 | @yield('resource')
23 |
24 | @endsection
25 |
--------------------------------------------------------------------------------
/resources/views/layouts/table.blade.php:
--------------------------------------------------------------------------------
1 | @extends('app')
2 |
3 | @section('content')
4 |
5 |
6 |
7 |
8 |
9 | @yield('title')
10 |
11 |
12 |
13 | @yield('filter')
14 |
15 |
16 | @yield('sort')
17 |
18 |
19 | @yield('search-bar')
20 |
21 |
22 |
23 |
24 |
25 |
26 | @yield('table')
27 |
28 |
29 |
30 |
33 |
34 | @endsection
35 |
36 | @push('scripts')
37 | @vite('resources/js/table-search.js')
38 | @endpush
39 |
--------------------------------------------------------------------------------
/routes/api.php:
--------------------------------------------------------------------------------
1 | get('/user', function (Request $request) {
18 | return $request->user();
19 | });
20 |
--------------------------------------------------------------------------------
/routes/channels.php:
--------------------------------------------------------------------------------
1 | id === (int) $id;
18 | });
19 |
--------------------------------------------------------------------------------
/routes/console.php:
--------------------------------------------------------------------------------
1 | comment(Inspiring::quote());
19 | })->purpose('Display an inspiring quote');
20 |
--------------------------------------------------------------------------------
/routes/web.php:
--------------------------------------------------------------------------------
1 | query('utm_source');
29 | $queryParams['utm_medium'] = request()->query('utm_medium');
30 | $queryParams['utm_campaign'] =request()->query('utm_campaign');
31 |
32 | return redirect()->route('deals.index', $queryParams);
33 | });
34 |
35 | // Login the user with ID 1 if no user is logged in
36 | Route::middleware([LoginAutomatically::class])->group(function () {
37 |
38 | Route::resource('companies', CompanyController::class)->only([
39 | 'index', 'show'
40 | ]);
41 |
42 | Route::resource('contacts', ContactController::class)->only([
43 | 'index', 'show'
44 | ]);
45 |
46 | Route::resource('deals', DealController::class)->only([
47 | 'index', 'show'
48 | ]);
49 | });
50 |
--------------------------------------------------------------------------------
/storage/app/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !public/
3 | !.gitignore
4 | !Fortune500.csv
5 |
--------------------------------------------------------------------------------
/storage/app/public/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/debugbar/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/.gitignore:
--------------------------------------------------------------------------------
1 | compiled.php
2 | config.php
3 | down
4 | events.scanned.php
5 | maintenance.php
6 | routes.php
7 | routes.scanned.php
8 | schedule-*
9 | services.json
10 |
--------------------------------------------------------------------------------
/storage/framework/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !data/
3 | !.gitignore
4 |
--------------------------------------------------------------------------------
/storage/framework/cache/data/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/sessions/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/testing/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/views/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/logs/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/tailwind.config.ts:
--------------------------------------------------------------------------------
1 | import type { Config } from 'tailwindcss'
2 | import formsPlugin from '@tailwindcss/forms'
3 | import plugin from 'tailwindcss/plugin'
4 |
5 | export default {
6 | content: [
7 | './resources/**/*.blade.php',
8 | './resources/**/*.js',
9 | './resources/**/*.ts',
10 | './resources/**/*.vue',
11 | ],
12 | theme: {
13 | extend: {},
14 | },
15 | plugins: [
16 | formsPlugin,
17 | plugin(function ({addBase}) {
18 | addBase({
19 | '[type="search"]::-webkit-search-decoration': {display: 'none'},
20 | '[type="search"]::-webkit-search-cancel-button': {display: 'none'},
21 | '[type="search"]::-webkit-search-results-button': {display: 'none'},
22 | '[type="search"]::-webkit-search-results-decoration': {display: 'none'},
23 | })
24 | }),
25 | ],
26 | } satisfies Config
27 |
--------------------------------------------------------------------------------
/tests/CreatesApplication.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class)->bootstrap();
18 |
19 | return $app;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/Feature/CompanyTest.php:
--------------------------------------------------------------------------------
1 | for(Organization::factory()->create())->create();
21 | $this->assertInstanceOf(\App\Models\Organization::class, $company->organization);
22 | }
23 |
24 | /**
25 | * @test
26 | */
27 | public function itHasContacts(): void
28 | {
29 | $company = Company::factory()->for(Organization::factory()->create())->hasContacts(3)->create();
30 | $this->assertCount(3, $company->contacts);
31 | }
32 |
33 | /**
34 | * @test
35 | */
36 | public function itHasAnEmailDomainAttribute(): void
37 | {
38 | $company = Company::factory()->for(Organization::factory()->create())->create([
39 | 'url' => 'www.meilisearch.com',
40 | ]);
41 | $this->assertEquals('meilisearch.com', $company->getEmailDomain());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tests/Feature/ContactTest.php:
--------------------------------------------------------------------------------
1 | create();
22 | $company = Company::factory()->for($org)->create();
23 | $contact = Contact::factory()->for($company)->create();
24 | $this->assertInstanceOf(Company::class, $contact->company);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/Feature/DatabaseSeederTest.php:
--------------------------------------------------------------------------------
1 | seed();
20 | }
21 |
22 | /**
23 | * @test
24 | */
25 | public function itCreatesTwoOrganizations(): void
26 | {
27 | $this->assertCount(2, Organization::all());
28 | }
29 |
30 | /**
31 | * @test
32 | */
33 | public function itCreatesTwoUsersFromConfiguration(): void
34 | {
35 | $this->assertDatabaseHas('users', [
36 | 'email' => config('app.seeders.user1.email'),
37 | 'avatar_url' => 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=987&q=80',
38 | 'organization_id' => Organization::findById(1)->id,
39 | ]);
40 | $this->assertDatabaseHas('users', [
41 | 'email' => config('app.seeders.user2.email'),
42 | 'avatar_url' => 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1364&q=80',
43 | 'organization_id' => Organization::findById(2)->id,
44 | ]);
45 | }
46 |
47 | /**
48 | * @test
49 | */
50 | public function itCreates20CompaniesForEachOrganization(): void
51 | {
52 | Organization::all()->each(function ($org) {
53 | $this->assertCount(20, $org->companies);
54 | });
55 | }
56 |
57 | /**
58 | * @test
59 | */
60 | public function itCreatesCompaniesWithUrl(): void
61 | {
62 | Company::all()->each(function ($company) {
63 | $this->assertNotNull($company->url);
64 | });
65 | }
66 |
67 | /**
68 | * @test
69 | */
70 | public function itCreates5ContactsForEachCompany(): void
71 | {
72 | Company::all()->each(function ($company) {
73 | $this->assertCount(5, $company->contacts);
74 | });
75 | }
76 |
77 | /**
78 | * @test
79 | */
80 | public function itCreatesContactsWithCompanyEmail(): void
81 | {
82 | Company::all()->each(function ($company) {
83 | $company->contacts->each(function ($contact) use ($company) {
84 | $this->assertStringContainsString($company->getEmailDomain(), $contact->email);
85 | });
86 | });
87 | }
88 |
89 | /**
90 | * @test
91 | */
92 | public function itCreatesOneDealPerContactForEachOrganization(): void
93 | {
94 | $orgs = Organization::with('companies.contacts')->get();
95 |
96 | $orgs->each(function ($org) {
97 | $this->assertEquals($org->contacts->count(), $org->deals->count());
98 | $org->contacts->each(function ($contact) use ($org) {
99 | $this->assertDatabaseHas('deals', [
100 | 'organization_id' => $org->id,
101 | 'contact_id' => $contact->id,
102 | ]);
103 | });
104 | });
105 | }
106 |
107 | /**
108 | * @test
109 | */
110 | public function itCreatesDealsForCompaniesOwnedByTheOrganization(): void
111 | {
112 | Organization::with('deals.company')->get()->each(function ($org) {
113 | $org->deals->each(function ($deal) use ($org) {
114 | $this->assertEquals($org->id, $deal->company->organization->id);
115 | });
116 | });
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/tests/Feature/DealTest.php:
--------------------------------------------------------------------------------
1 | create();
20 | $company = Company::factory()->for($org)->create();
21 | $contact = Contact::factory()->for($company)->create();
22 | return Deal::factory()
23 | ->for($org)
24 | ->for($company)
25 | ->for($contact)
26 | ->create();
27 | }
28 |
29 | /**
30 | * @test
31 | */
32 | public function itBelongsToAnOrganization(): void
33 | {
34 | $deal = $this->makeDeal();
35 | $this->assertInstanceOf(Organization::class, $deal->organization);
36 | }
37 |
38 | /**
39 | * @test
40 | */
41 | public function itBelongsToACompany(): void
42 | {
43 | $deal = $this->makeDeal();
44 | $this->assertInstanceOf(Company::class, $deal->company);
45 | }
46 |
47 | /**
48 | * @test
49 | */
50 | public function itBelongsToAContact(): void
51 | {
52 | $deal = $this->makeDeal();
53 | $this->assertInstanceOf(Contact::class, $deal->contact);
54 | }
55 |
56 | /**
57 | * @test
58 | */
59 | public function itHasAValue(): void
60 | {
61 | $deal = $this->makeDeal();
62 | $this->assertIsInt($deal->value);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/tests/Feature/LoginControllerTest.php:
--------------------------------------------------------------------------------
1 | seedUsers();
17 | $this->assertGuest();
18 | $this->post('/login', ['email' => config('app.seeders.user1.email')])
19 | ->assertStatus(302);
20 | $this->assertAuthenticatedAs(User::findByEmail(config('app.seeders.user1.email')));
21 | }
22 |
23 | public function testSeededUser2CanLogin(): void
24 | {
25 | $this->seedUsers();
26 | $this->assertGuest();
27 | $this->post('/login', ['email' => config('app.seeders.user2.email')])
28 | ->assertStatus(302);
29 | $this->assertAuthenticatedAs(User::findByEmail(config('app.seeders.user2.email')));
30 | }
31 |
32 | /**
33 | * @test
34 | */
35 | public function itRedirectsToPreviousRoute(): void
36 | {
37 | $this->seedUsers();
38 | $routeNames = [
39 | 'deals.index',
40 | 'contacts.index',
41 | 'companies.index',
42 | ];
43 |
44 | foreach ($routeNames as $routeName) {
45 | $this->get(route($routeName));
46 | $this->post('/login', ['email' => config('app.seeders.user1.email')])
47 | ->assertRedirectToRoute($routeName);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/tests/Feature/OrganizationTest.php:
--------------------------------------------------------------------------------
1 | create();
23 | $this->assertEquals(1, Organization::findById(1)->id);
24 | }
25 |
26 | /**
27 | * @test
28 | */
29 | public function itHasContactsThroughCompanies(): void
30 | {
31 | $org = Organization::factory()->create();
32 | $org->companies()->saveMany(
33 | Company::factory()->count(20)->make()
34 | );
35 | $org->companies->each(function ($company) {
36 | $company->contacts()->saveMany(
37 | Contact::factory()->count(5)->make()
38 | );
39 | });
40 | $org->refresh();
41 |
42 | $totalContacts = $org->companies->reduce(function ($carry, $company) {
43 | return $carry + $company->contacts->count();
44 | }, 0);
45 |
46 | $this->assertEquals($totalContacts, $org->contacts->count());
47 | }
48 |
49 | /**
50 | * @test
51 | */
52 | public function itAddsAMeilisearchOnRetrieval(): void
53 | {
54 | $org = Organization::factory()->create();
55 | $this->assertNull($org->meilisearch_token);
56 |
57 | // TODO: Figure out how to mock the engine manager
58 | $this->assertEquals('fake-tenant-token', Organization::find($org->id)->meilisearch_token);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/tests/Feature/PagesTest.php:
--------------------------------------------------------------------------------
1 | assertGuest();
26 | $this->get('/')->assertRedirectToRoute('deals.index');
27 | }
28 |
29 | /**
30 | * @test
31 | */
32 | public function itLogsUser1ByDefault(): void
33 | {
34 | $this->seedUsers();
35 | $user = User::findById(1);
36 |
37 | $this->assertGuest();
38 | foreach (self::ROUTE_NAMES as $routeName) {
39 | $this->actingAs($user)
40 | ->get(route($routeName))
41 | ->assertSee($user->organization->name);
42 | }
43 | }
44 |
45 | /**
46 | * @test
47 | */
48 | public function itDisplaysTheUserOrganization(): void
49 | {
50 | $this->seedUsers();
51 | $user = User::findById(1);
52 |
53 | foreach (self::ROUTE_NAMES as $routeName) {
54 | $this->actingAs($user)
55 | ->get(route($routeName))
56 | ->assertSee($user->organization->name);
57 | }
58 | }
59 |
60 | /**
61 | * @test
62 | */
63 | public function itProvidesTheOrganizationMeilisearchToken(): void
64 | {
65 | $this->seedUsers();
66 | $user = User::findById(1);
67 |
68 | foreach (self::ROUTE_NAMES as $routeName) {
69 | $this->actingAs($user)
70 | ->get(route($routeName))
71 | ->assertViewHas('meilisearchToken', $user->organization->meilisearch_token);
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/tests/Feature/SearchTest.php:
--------------------------------------------------------------------------------
1 | resetSearchIndexes();
21 | // TODO: waiting for Meilisearch tasks to be finished would be optimal to avoid random failures
22 | }
23 |
24 | /**
25 | * @test
26 | */
27 | public function itSynchronizesCompaniesData(): void
28 | {
29 | $company = Company::factory()->for(Organization::factory()->create())->create();
30 | Search::assertSynced($company);
31 | }
32 |
33 | /**
34 | * @test
35 | */
36 | public function itSynchronizesContactsData(): void
37 | {
38 | $org = Organization::factory()->create();
39 | $company = Company::factory()->for($org)->create();
40 | $contact = Contact::factory()->for($company)->create();
41 | Search::assertSynced($contact);
42 | }
43 |
44 | /**
45 | * @test
46 | */
47 | public function itSynchronizesDealsData(): void
48 | {
49 |
50 | $org = Organization::factory()->create();
51 | $company = Company::factory()->for($org)->create();
52 | $contact = Contact::factory()->for($company)->create();
53 | $deal = Deal::factory()
54 | ->for($org)
55 | ->for($company)
56 | ->for($contact)
57 | ->create();
58 | Search::assertSynced($deal);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/tests/Feature/UserTest.php:
--------------------------------------------------------------------------------
1 | for(Organization::factory()->create())
19 | ->create();
20 | }
21 |
22 | /**
23 | * @test
24 | */
25 | public function itCanFindByEmail(): void
26 | {
27 | $user = $this->makeUser();
28 | $this->assertEquals($user->id, User::findByEmail($user->email)->id);
29 | }
30 |
31 | /**
32 | * @test
33 | */
34 | public function itCanFindById(): void
35 | {
36 | $user = $this->makeUser();
37 | $this->assertEquals($user->id, User::findById($user->id)->id);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/tests/Pest.php:
--------------------------------------------------------------------------------
1 | in('Feature');
18 |
19 | /*
20 | |--------------------------------------------------------------------------
21 | | Expectations
22 | |--------------------------------------------------------------------------
23 | |
24 | | When you're writing tests, you often need to check that values meet certain conditions. The
25 | | "expect()" function gives you access to a set of "expectations" methods that you can use
26 | | to assert different things. Of course, you may extend the Expectation API at any time.
27 | |
28 | */
29 |
30 | expect()->extend('toBeOne', function () {
31 | return $this->toBe(1);
32 | });
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | Functions
37 | |--------------------------------------------------------------------------
38 | |
39 | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your
40 | | project that you don't want to repeat in every file. Here you can also expose helpers as
41 | | global functions to help you to reduce the number of lines of code in your test files.
42 | |
43 | */
44 |
45 | function something()
46 | {
47 | // ..
48 | }
49 |
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 | seed(OrganizationSeeder::class);
17 | $this->seed(UserSeeder::class);
18 | }
19 |
20 | public function resetSearchIndexes(): void
21 | {
22 | $this->artisan('scout:flush', ['model' => \App\Models\Company::class]);
23 | $this->artisan('scout:flush', ['model' => \App\Models\Deal::class]);
24 | $this->artisan('scout:flush', ['model' => \App\Models\Company::class]);
25 | $this->artisan('scout:sync-index-settings');
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "module": "esnext",
5 | "moduleResolution": "node",
6 | "strict": true,
7 | "jsx": "preserve",
8 | "sourceMap": true,
9 | "resolveJsonModule": true,
10 | "esModuleInterop": true,
11 | "lib": [
12 | "esnext",
13 | "dom"
14 | ],
15 | "types": [
16 | "vite/client"
17 | ]
18 | },
19 | "include": [
20 | "resources/js/**/*.ts",
21 | "resources/js/**/*.d.ts",
22 | "resources/js/**/*.tsx",
23 | "resources/js/**/*.vue"
24 | ]
25 | }
26 |
--------------------------------------------------------------------------------
/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import laravel from 'laravel-vite-plugin'
3 | import vue from '@vitejs/plugin-vue'
4 |
5 | export default defineConfig({
6 | plugins: [
7 | laravel({
8 | input: [
9 | 'resources/css/app.css',
10 | 'resources/js/app.js',
11 | 'resources/js/app-search',
12 | 'resources/js/table-search',
13 | ],
14 | refresh: true,
15 | }),
16 | vue({
17 | template: {
18 | transformAssetUrls: {
19 | // The Vue plugin will re-write asset URLs, when referenced
20 | // in Single File Components, to point to the Laravel web
21 | // server. Setting this to `null` allows the Laravel plugin
22 | // to instead re-write asset URLs to point to the Vite
23 | // server instead.
24 | base: null,
25 |
26 | // The Vue plugin will parse absolute URLs and treat them
27 | // as absolute paths to files on disk. Setting this to
28 | // `false` will leave absolute URLs un-touched so they can
29 | // reference assets in the public directory as expected.
30 | includeAbsolute: false,
31 | },
32 | },
33 | }),
34 | ],
35 | resolve: {
36 | alias: {
37 | 'vue': 'vue/dist/vue.esm-bundler',
38 | },
39 | },
40 | })
41 |
--------------------------------------------------------------------------------