├── public ├── favicon.ico ├── robots.txt ├── .htaccess ├── web.config └── index.php ├── database ├── .gitignore ├── migrations │ ├── 2019_03_05_000000_create_accounts_table.php │ ├── 2019_03_05_000000_create_password_resets_table.php │ ├── 2019_03_05_000000_create_users_table.php │ ├── 2019_03_05_000000_create_organizations_table.php │ └── 2019_03_05_000000_create_contacts_table.php ├── factories │ ├── UserFactory.php │ ├── OrganizationFactory.php │ └── ContactFactory.php └── seeders │ └── DatabaseSeeder.php ├── bootstrap ├── cache │ └── .gitignore └── app.php ├── storage ├── logs │ └── .gitignore ├── app │ ├── public │ │ └── .gitignore │ └── .gitignore ├── debugbar │ └── .gitignore └── framework │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── cache │ ├── data │ │ └── .gitignore │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── Procfile ├── screenshot.png ├── .gitattributes ├── jsconfig.json ├── .prettierrc ├── postcss.config.js ├── resources ├── js │ ├── utils.js │ ├── Shared │ │ ├── DeleteButton.jsx │ │ ├── MainMenu.jsx │ │ ├── LoadingButton.jsx │ │ ├── TextInput.jsx │ │ ├── SelectInput.jsx │ │ ├── TrashedMessage.jsx │ │ ├── MainMenuItem.jsx │ │ ├── Layout.jsx │ │ ├── TopHeader.jsx │ │ ├── Pagination.jsx │ │ ├── FileInput.jsx │ │ ├── BottomHeader.jsx │ │ ├── FlashMessages.jsx │ │ ├── SearchFilter.jsx │ │ └── Icon.jsx │ ├── Pages │ │ ├── Reports │ │ │ └── Index.jsx │ │ ├── Error.jsx │ │ ├── Dashboard │ │ │ └── Index.jsx │ │ ├── Auth │ │ │ └── Login.jsx │ │ ├── Users │ │ │ ├── Create.jsx │ │ │ ├── Index.jsx │ │ │ └── Edit.jsx │ │ ├── Organizations │ │ │ ├── Index.jsx │ │ │ └── Create.jsx │ │ └── Contacts │ │ │ ├── Index.jsx │ │ │ └── Create.jsx │ └── app.jsx ├── css │ ├── app.css │ └── components │ │ ├── button.css │ │ └── form.css ├── views │ └── app.blade.php └── lang │ └── en │ ├── pagination.php │ ├── auth.php │ └── passwords.php ├── .editorconfig ├── tests ├── TestCase.php ├── CreatesApplication.php └── Feature │ ├── UsersTest.php │ ├── ContactsTest.php │ └── OrganizationsTest.php ├── app ├── Http │ ├── Controllers │ │ ├── ReportsController.php │ │ ├── DashboardController.php │ │ ├── ImagesController.php │ │ ├── Controller.php │ │ ├── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── ResetPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── VerificationController.php │ │ │ └── RegisterController.php │ │ ├── UsersController.php │ │ ├── OrganizationsController.php │ │ └── ContactsController.php │ ├── Resources │ │ ├── UserOrganizationCollection.php │ │ ├── UserCollection.php │ │ ├── OrganizationCollection.php │ │ ├── ContactCollection.php │ │ ├── UserResource.php │ │ ├── OrganizationResource.php │ │ └── ContactResource.php │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── CheckForMaintenanceMode.php │ │ ├── TrimStrings.php │ │ ├── TrustProxies.php │ │ ├── Authenticate.php │ │ ├── VerifyCsrfToken.php │ │ ├── RedirectIfAuthenticated.php │ │ └── HandleInertiaRequests.php │ ├── Requests │ │ ├── UserDeleteRequest.php │ │ ├── UserUpdateRequest.php │ │ ├── UserStoreRequest.php │ │ ├── OrganizationStoreRequest.php │ │ ├── OrganizationUpdateRequest.php │ │ ├── ContactStoreRequest.php │ │ └── ContactUpdateRequest.php │ └── Kernel.php ├── Models │ ├── Account.php │ ├── Model.php │ ├── Organization.php │ ├── Contact.php │ └── User.php ├── Providers │ ├── BroadcastServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ ├── AppServiceProvider.php │ └── RouteServiceProvider.php ├── Traits │ └── LockedDemoUser.php ├── Console │ └── Kernel.php └── Exceptions │ └── Handler.php ├── .gitignore ├── .eslintrc.js ├── vite.config.js ├── routes ├── channels.php ├── api.php ├── console.php └── web.php ├── server.php ├── config ├── sentry.php ├── services.php ├── view.php ├── hashing.php ├── broadcasting.php ├── filesystems.php ├── queue.php ├── logging.php ├── cache.php ├── auth.php ├── mail.php └── database.php ├── .env.example ├── package.json ├── LICENSE ├── phpunit.xml ├── Makefile ├── artisan ├── tailwind.config.js ├── readme.md └── composer.json /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/debugbar/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: vendor/bin/heroku-php-apache2 public/ 2 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/artemio87/pingcrm-react18-laravel10/HEAD/screenshot.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "@/*": ["./resources/js/*"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "singleQuote": true, 4 | "tabWidth": 2, 5 | "arrowParens": "avoid", 6 | "trailingComma": "none" 7 | } 8 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | 'postcss-import': {}, 4 | 'tailwindcss/nesting': {}, 5 | tailwindcss: {}, 6 | autoprefixer: {}, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /resources/js/utils.js: -------------------------------------------------------------------------------- 1 | export function filesize(size) { 2 | const i = Math.floor(Math.log(size) / Math.log(1024)); 3 | return ( 4 | (size / Math.pow(1024, i)).toFixed(2) * 1 + 5 | ' ' + 6 | ['B', 'kB', 'MB', 'GB', 'TB'][i] 7 | ); 8 | } 9 | -------------------------------------------------------------------------------- /resources/css/app.css: -------------------------------------------------------------------------------- 1 | /* Base */ 2 | @import 'tailwindcss/base'; 3 | @import 'tailwindcss/components'; 4 | 5 | /* Components */ 6 | @import 'components/button'; 7 | @import 'components/form'; 8 | 9 | /* Utilities */ 10 | @import 'tailwindcss/utilities'; 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 2 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.php] 15 | indent_size = 4 16 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | fromRequest()->response(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /resources/js/Shared/DeleteButton.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default ({ onDelete, children }) => ( 4 | 12 | ); 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/css 3 | /public/hot 4 | /public/js 5 | /public/mix-manifest.json 6 | /public/storage 7 | /public/build 8 | /storage/*.key 9 | /database/*.sqlite 10 | /vendor 11 | .DS_Store 12 | .env 13 | .php_cs.dist 14 | .phpunit.result.cache 15 | Homestead.json 16 | Homestead.yaml 17 | npm-debug.log 18 | yarn-error.log 19 | .idea 20 | -------------------------------------------------------------------------------- /app/Http/Resources/UserOrganizationCollection.php: -------------------------------------------------------------------------------- 1 | collection->map->only('id', 'name'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /resources/js/Pages/Reports/Index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Layout from '@/Shared/Layout'; 3 | 4 | const Index = () => { 5 | return ( 6 |
7 |

Reports

8 |
9 | ); 10 | }; 11 | 12 | Index.layout = page => ; 13 | 14 | export default Index; 15 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | hasMany(User::class); 10 | } 11 | 12 | public function organizations() 13 | { 14 | return $this->hasMany(Organization::class); 15 | } 16 | 17 | public function contacts() 18 | { 19 | return $this->hasMany(Contact::class); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Requests/UserDeleteRequest.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | increments('id'); 13 | $table->string('name', 50); 14 | $table->timestamps(); 15 | }); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /resources/js/Shared/MainMenu.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import MainMenuItem from '@/Shared/MainMenuItem'; 3 | 4 | export default ({ className }) => { 5 | return ( 6 |
7 | 8 | 9 | 10 | 11 |
12 | ); 13 | }; 14 | -------------------------------------------------------------------------------- /resources/views/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @viteReactRefresh 7 | @vite('resources/js/app.jsx') 8 | @vite(['resources/css/app.css', 'resources/js/manifest.js', 'resources/js/vendor.js', 'resources/js/app.js']) 9 | @routes 10 | 11 | 12 | 13 | @inertia 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /resources/js/Shared/LoadingButton.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import cx from 'classnames'; 3 | 4 | export default ({ loading, className, children, ...props }) => { 5 | const classNames = cx( 6 | 'flex items-center', 7 | 'focus:outline-none', 8 | { 9 | 'pointer-events-none bg-opacity-75 select-none': loading 10 | }, 11 | className 12 | ); 13 | return ( 14 | 18 | ); 19 | }; 20 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /database/migrations/2019_03_05_000000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 13 | $table->string('token'); 14 | $table->timestamp('created_at')->nullable(); 15 | }); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /app/Http/Resources/UserCollection.php: -------------------------------------------------------------------------------- 1 | collection->map->only( 18 | 'id', 'name', 'email', 'owner', 'photo', 'deleted_at' 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Resources/OrganizationCollection.php: -------------------------------------------------------------------------------- 1 | collection->map->only( 18 | 'id', 'name', 'phone', 'city', 'deleted_at' 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /resources/js/Shared/TextInput.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default ({ label, name, className, errors = [], ...props }) => { 4 | return ( 5 |
6 | {label && ( 7 | 10 | )} 11 | 17 | {errors &&
{errors}
} 18 |
19 | ); 20 | }; 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | collection->map->only( 18 | 'id', 'name', 'phone', 'city', 'deleted_at', 'organization' 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Models/Model.php: -------------------------------------------------------------------------------- 1 | where($this->getRouteKeyName(), $value)->withTrashed()->first() 18 | : parent::resolveRouteBinding($value); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 17 | return $request->user(); 18 | }); 19 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | # Handle Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /config/sentry.php: -------------------------------------------------------------------------------- 1 | env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), 6 | 7 | // capture release as git sha 8 | // 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')), 9 | 10 | 'breadcrumbs' => [ 11 | // Capture Laravel logs in breadcrumbs 12 | 'logs' => true, 13 | 14 | // Capture SQL queries in breadcrumbs 15 | 'sql_queries' => true, 16 | 17 | // Capture bindings on SQL queries logged in breadcrumbs 18 | 'sql_bindings' => true, 19 | 20 | // Capture queue job information in breadcrumbs 21 | 'queue_info' => true, 22 | ], 23 | 24 | ]; 25 | -------------------------------------------------------------------------------- /resources/js/Shared/SelectInput.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default ({ 4 | label, 5 | name, 6 | className, 7 | children, 8 | errors = [], 9 | ...props 10 | }) => { 11 | return ( 12 |
13 | {label && ( 14 | 17 | )} 18 | 26 | {errors &&
{errors}
} 27 |
28 | ); 29 | }; 30 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /resources/js/app.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; 3 | import { createInertiaApp } from '@inertiajs/react' 4 | import { createRoot } from 'react-dom/client' 5 | import * as Sentry from '@sentry/browser'; 6 | import '../css/app.css'; 7 | 8 | createInertiaApp({ 9 | id: 'app', 10 | progress: { 11 | color: '#ED8936', 12 | }, 13 | resolve: name => { 14 | const pages = import.meta.glob('./Pages/**/*.jsx', { eager: true }) 15 | return pages[`./Pages/${name}.jsx`] 16 | }, 17 | setup({ el, App, props }) { 18 | createRoot(el).render() 19 | }, 20 | }) 21 | 22 | Sentry.init({ 23 | dsn: process.env.MIX_SENTRY_LARAVEL_DSN 24 | }); 25 | 26 | -------------------------------------------------------------------------------- /app/Traits/LockedDemoUser.php: -------------------------------------------------------------------------------- 1 | route('user')->isDemoUser(); 17 | } 18 | 19 | public function failedAuthorization() { 20 | 21 | $this->session()->flash('error', 'Updating or deleting the demo user is not allowed.'); 22 | 23 | // Note: This is required, otherwise demo user will update 24 | // and both, success and error messages will be returned. 25 | throw ValidationException::withMessages([]); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /resources/css/components/button.css: -------------------------------------------------------------------------------- 1 | .btn-indigo { 2 | @apply px-6 py-3 rounded bg-indigo-700 text-white text-sm font-bold whitespace-nowrap hover:bg-orange-500 focus:bg-orange-500; 3 | } 4 | 5 | .btn-spinner, 6 | .btn-spinner:after { 7 | border-radius: 50%; 8 | width: 1.5em; 9 | height: 1.5em; 10 | } 11 | 12 | .btn-spinner { 13 | font-size: 10px; 14 | position: relative; 15 | text-indent: -9999em; 16 | border-top: 0.2em solid white; 17 | border-right: 0.2em solid white; 18 | border-bottom: 0.2em solid white; 19 | border-left: 0.2em solid transparent; 20 | transform: translateZ(0); 21 | animation: spinning 1s infinite linear; 22 | } 23 | 24 | @keyframes spinning { 25 | 0% { 26 | transform: rotate(0deg); 27 | } 28 | 100% { 29 | transform: rotate(360deg); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /resources/js/Shared/TrashedMessage.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Icon from '@/Shared/Icon'; 3 | 4 | export default ({ onRestore, children }) => { 5 | return ( 6 |
7 |
8 | 12 |
{children}
13 |
14 | 22 |
23 | ); 24 | }; 25 | -------------------------------------------------------------------------------- /app/Http/Resources/UserResource.php: -------------------------------------------------------------------------------- 1 | $this->id, 19 | 'first_name' => $this->first_name, 20 | 'last_name' => $this->last_name, 21 | 'name' => $this->name, 22 | 'email' => $this->email, 23 | 'owner' => $this->owner, 24 | 'photo' => $this->photo, 25 | 'deleted_at' => $this->deleted_at, 26 | 'account' => $this->whenLoaded('account') 27 | ]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | parent::boot(); 31 | 32 | // 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least eight characters and match the confirmation.', 17 | 'reset' => 'Your password has been reset!', 18 | 'sent' => 'We have e-mailed your password reset link!', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that e-mail address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /app/Models/Organization.php: -------------------------------------------------------------------------------- 1 | hasMany(Contact::class); 15 | } 16 | 17 | public function scopeFilter($query, array $filters) 18 | { 19 | $query->when($filters['search'] ?? null, function ($query, $search) { 20 | $query->where('name', 'like', '%'.$search.'%'); 21 | })->when($filters['trashed'] ?? null, function ($query, $trashed) { 22 | if ($trashed === 'with') { 23 | $query->withTrashed(); 24 | } elseif ($trashed === 'only') { 25 | $query->onlyTrashed(); 26 | } 27 | }); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /.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 | 9 | DB_CONNECTION=sqlite 10 | 11 | BROADCAST_DRIVER=log 12 | CACHE_DRIVER=file 13 | QUEUE_CONNECTION=sync 14 | SESSION_DRIVER=file 15 | SESSION_LIFETIME=120 16 | 17 | REDIS_HOST=127.0.0.1 18 | REDIS_PASSWORD=null 19 | REDIS_PORT=6379 20 | 21 | MAIL_DRIVER=smtp 22 | MAIL_HOST=smtp.mailtrap.io 23 | MAIL_PORT=2525 24 | MAIL_USERNAME=null 25 | MAIL_PASSWORD=null 26 | MAIL_ENCRYPTION=null 27 | 28 | AWS_ACCESS_KEY_ID= 29 | AWS_SECRET_ACCESS_KEY= 30 | AWS_DEFAULT_REGION=us-east-1 31 | AWS_BUCKET= 32 | 33 | PUSHER_APP_ID= 34 | PUSHER_APP_KEY= 35 | PUSHER_APP_SECRET= 36 | PUSHER_APP_CLUSTER=mt1 37 | 38 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 39 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 40 | 41 | SENTRY_LARAVEL_DSN= 42 | VITE_SENTRY_LARAVEL_DSN="${SENTRY_LARAVEL_DSN}" 43 | -------------------------------------------------------------------------------- /resources/js/Shared/MainMenuItem.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from '@inertiajs/react'; 3 | import classNames from 'classnames'; 4 | import Icon from '@/Shared/Icon'; 5 | 6 | export default ({ icon, link, text }) => { 7 | const isActive = route().current(link + '*'); 8 | 9 | const iconClasses = classNames('w-4 h-4 mr-2', { 10 | 'text-white fill-current': isActive, 11 | 'text-indigo-400 group-hover:text-white fill-current': !isActive 12 | }); 13 | 14 | const textClasses = classNames({ 15 | 'text-white': isActive, 16 | 'text-indigo-200 group-hover:text-white': !isActive 17 | }); 18 | 19 | return ( 20 |
21 | 22 | 23 |
{text}
24 | 25 |
26 | ); 27 | }; 28 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | $this->faker->firstName, 27 | 'last_name' => $this->faker->lastName, 28 | 'email' => $this->faker->unique()->safeEmail, 29 | 'password' => 'secret', 30 | 'remember_token' => Str::random(10), 31 | 'owner' => false, 32 | ]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2019_03_05_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 13 | $table->integer('account_id')->index(); 14 | $table->string('first_name', 25); 15 | $table->string('last_name', 25); 16 | $table->string('email', 50)->unique(); 17 | $table->string('password')->nullable(); 18 | $table->boolean('owner')->default(false); 19 | $table->string('photo_path', 100)->nullable(); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | $table->softDeletes(); 23 | }); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | registerGlide(); 21 | } 22 | 23 | protected function registerGlide() 24 | { 25 | $this->app->bind(Server::class, function ($app) { 26 | return Server::create([ 27 | 'source' => Storage::getDriver(), 28 | 'cache' => Storage::getDriver(), 29 | 'cache_folder' => '.glide-cache', 30 | 'base_url' => 'img', 31 | ]); 32 | }); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/Http/Requests/UserUpdateRequest.php: -------------------------------------------------------------------------------- 1 | ['required', 'max:50'], 23 | 'last_name' => ['required', 'max:50'], 24 | 'email' => ['required', 'max:50', 'email', 25 | Rule::unique('users')->ignore($this->route('user')->id) 26 | ], 27 | 'password' => ['nullable'], 28 | 'owner' => ['required', 'boolean'], 29 | 'photo' => ['nullable', 'image'], 30 | ]; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/Http/Requests/UserStoreRequest.php: -------------------------------------------------------------------------------- 1 | ['required', 'max:50'], 29 | 'last_name' => ['required', 'max:50'], 30 | 'email' => ['required', 'max:50', 'email', Rule::unique('users')], 31 | 'password' => ['nullable'], 32 | 'owner' => ['required', 'boolean'], 33 | 'photo' => ['nullable', 'image'], 34 | ]; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Resources/OrganizationResource.php: -------------------------------------------------------------------------------- 1 | $this->id, 19 | 'name' => $this->name, 20 | 'email' => $this->email, 21 | 'phone' => $this->phone, 22 | 'address' => $this->address, 23 | 'city' => $this->city, 24 | 'region' => $this->region, 25 | 'country' => $this->country, 26 | 'postal_code' => $this->postal_code, 27 | 'deleted_at' => $this->deleted_at, 28 | 'contacts' => $this->contacts()->orderByName()->get()->map->only('id', 'name', 'city', 'phone'), 29 | ]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Http/Resources/ContactResource.php: -------------------------------------------------------------------------------- 1 | $this->id, 20 | 'first_name' => $this->first_name, 21 | 'last_name' => $this->last_name, 22 | 'email' => $this->email, 23 | 'phone' => $this->phone, 24 | 'address' => $this->address, 25 | 'city' => $this->city, 26 | 'region' => $this->region, 27 | 'country' => $this->country, 28 | 'postal_code' => $this->postal_code, 29 | 'deleted_at' => $this->deleted_at, 30 | 'organization_id' => $this->organization_id, 31 | ]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/factories/OrganizationFactory.php: -------------------------------------------------------------------------------- 1 | $this->faker->company, 26 | 'email' => $this->faker->companyEmail, 27 | 'phone' => $this->faker->tollFreePhoneNumber, 28 | 'address' => $this->faker->streetAddress, 29 | 'city' => $this->faker->city, 30 | 'region' => $this->faker->state, 31 | 'country' => 'US', 32 | 'postal_code' => $this->faker->postcode, 33 | ]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | 31 | /** 32 | * Register the commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | $this->load(__DIR__.'/Commands'); 39 | 40 | require base_path('routes/console.php'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /database/migrations/2019_03_05_000000_create_organizations_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 13 | $table->integer('account_id')->index(); 14 | $table->string('name', 100); 15 | $table->string('email', 50)->nullable(); 16 | $table->string('phone', 50)->nullable(); 17 | $table->string('address', 150)->nullable(); 18 | $table->string('city', 50)->nullable(); 19 | $table->string('region', 50)->nullable(); 20 | $table->string('country', 2)->nullable(); 21 | $table->string('postal_code', 25)->nullable(); 22 | $table->timestamps(); 23 | $table->softDeletes(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Requests/OrganizationStoreRequest.php: -------------------------------------------------------------------------------- 1 | ['required', 'max:100'], 28 | 'email' => ['nullable', 'max:50', 'email'], 29 | 'phone' => ['nullable', 'max:50'], 30 | 'address' => ['nullable', 'max:150'], 31 | 'city' => ['nullable', 'max:50'], 32 | 'region' => ['nullable', 'max:50'], 33 | 'country' => ['nullable', 'max:2'], 34 | 'postal_code' => ['nullable', 'max:25'], 35 | ]; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/Http/Requests/OrganizationUpdateRequest.php: -------------------------------------------------------------------------------- 1 | ['required', 'max:100'], 28 | 'email' => ['nullable', 'max:50', 'email'], 29 | 'phone' => ['nullable', 'max:50'], 30 | 'address' => ['nullable', 'max:150'], 31 | 'city' => ['nullable', 'max:50'], 32 | 'region' => ['nullable', 'max:50'], 33 | 'country' => ['nullable', 'max:2'], 34 | 'postal_code' => ['nullable', 'max:25'], 35 | ]; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /database/factories/ContactFactory.php: -------------------------------------------------------------------------------- 1 | $this->faker->firstName, 26 | 'last_name' => $this->faker->lastName, 27 | 'email' => $this->faker->unique()->safeEmail, 28 | 'phone' => $this->faker->tollFreePhoneNumber, 29 | 'address' => $this->faker->streetAddress, 30 | 'city' => $this->faker->city, 31 | 'region' => $this->faker->state, 32 | 'country' => 'US', 33 | 'postal_code' => $this->faker->postcode, 34 | ]; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "vite", 5 | "build": "vite build", 6 | "lint": "eslint ./resources/js/ --ext .js --ext .jsx" 7 | }, 8 | "dependencies": { 9 | "@inertiajs/react": "^1.0.2", 10 | "@sentry/browser": "^7.38.0", 11 | "axios": "^1.3.3", 12 | "classnames": "^2.3.2", 13 | "lodash": "^4.17.21", 14 | "react": "^18.2.0", 15 | "react-dom": "^18.2.0", 16 | "react-helmet": "^6.1.0", 17 | "react-use": "^17.4.0", 18 | "resolve-url-loader": "^5.0.0", 19 | "tailwindcss": "^3.2.7" 20 | }, 21 | "devDependencies": { 22 | "@babel/eslint-parser": "^7.19.1", 23 | "@babel/preset-react": "^7.18.6", 24 | "@vitejs/plugin-react": "^3.1.0", 25 | "autoprefixer": "^10.4.13", 26 | "babel-eslint": "^10.1.0", 27 | "cross-env": "^7.0.3", 28 | "eslint": "^8.35.0", 29 | "eslint-plugin-react": "^7.32.2", 30 | "laravel-vite-plugin": "^0.7.4", 31 | "postcss": "^8.4.21", 32 | "postcss-import": "^15.1.0", 33 | "react-refresh": "^0.14.0", 34 | "vite": "^4.1.4" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /resources/js/Pages/Error.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Helmet from 'react-helmet'; 3 | // import { usePage } from '@inertiajs/inertia-react'; 4 | 5 | export default ({ status }) => { 6 | // const { status } = usePage().props; 7 | 8 | const title = { 9 | 503: '503: Service Unavailable', 10 | 500: '500: Server Error', 11 | 404: '404: Page Not Found', 12 | 403: '403: Forbidden' 13 | }[status]; 14 | 15 | const description = { 16 | 503: 'Sorry, we are doing some maintenance. Please check back soon.', 17 | 500: 'Whoops, something went wrong on our servers.', 18 | 404: 'Sorry, the page you are looking for could not be found.', 19 | 403: 'Sorry, you are forbidden from accessing this page.' 20 | }[status]; 21 | 22 | return ( 23 |
24 | 25 |
26 |

{title}

27 |

{description}

28 |
29 |
30 | ); 31 | }; 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Jonathan Reinink 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 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /database/migrations/2019_03_05_000000_create_contacts_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 13 | $table->integer('account_id')->index(); 14 | $table->integer('organization_id')->nullable()->index(); 15 | $table->string('first_name', 25); 16 | $table->string('last_name', 25); 17 | $table->string('email', 50)->nullable(); 18 | $table->string('phone', 50)->nullable(); 19 | $table->string('address', 150)->nullable(); 20 | $table->string('city', 50)->nullable(); 21 | $table->string('region', 50)->nullable(); 22 | $table->string('country', 2)->nullable(); 23 | $table->string('postal_code', 25)->nullable(); 24 | $table->timestamps(); 25 | $table->softDeletes(); 26 | }); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /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/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | 'Acme Corporation']); 16 | 17 | User::factory()->create([ 18 | 'account_id' => $account->id, 19 | 'first_name' => 'John', 20 | 'last_name' => 'Doe', 21 | 'email' => 'johndoe@example.com', 22 | 'owner' => true, 23 | ]); 24 | 25 | User::factory()->count(5)->create([ 26 | 'account_id' => $account->id 27 | ]); 28 | 29 | $organizations = Organization::factory()->count(100)->create([ 30 | 'account_id' => $account->id 31 | ]); 32 | 33 | Contact::factory()->count(100)->create([ 34 | 'account_id' => $account->id 35 | ]) 36 | ->each(function (Contact $contact) use ($organizations) { 37 | $contact->update(['organization_id' => $organizations->random()->id]); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /resources/js/Shared/Layout.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Helmet from 'react-helmet'; 3 | import MainMenu from '@/Shared/MainMenu'; 4 | import FlashMessages from '@/Shared/FlashMessages'; 5 | import TopHeader from '@/Shared/TopHeader'; 6 | import BottomHeader from '@/Shared/BottomHeader'; 7 | 8 | export default function Layout({ title, children }) { 9 | return ( 10 |
11 | 12 |
13 |
14 |
15 | 16 | 17 |
18 |
19 | 20 | {/* To reset scroll region (https://inertiajs.com/pages#scroll-regions) add `scroll-region="true"` to div below */} 21 |
22 | 23 | {children} 24 |
25 |
26 |
27 |
28 |
29 | ); 30 | } 31 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Feature 14 | 15 | 16 | 17 | 18 | ./app 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/VerificationController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 38 | $this->middleware('signed')->only('verify'); 39 | $this->middleware('throttle:6,1')->only('verify', 'resend'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /resources/js/Pages/Dashboard/Index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from '@inertiajs/react'; 3 | import Layout from '@/Shared/Layout'; 4 | 5 | const Dashboard = () => { 6 | return ( 7 |
8 |

Dashboard

9 |

10 | Hey there! Welcome to Ping CRM, a demo app designed to help illustrate 11 | how 12 | 16 | Inertia.js 17 | 18 | works with 19 | 23 | React 24 | 25 | . 26 |

27 |
28 | 29 | 500 error 30 | 31 | 32 | 404 error 33 | 34 |
35 |
36 | ); 37 | }; 38 | 39 | // Persistent layout 40 | // Docs: https://inertiajs.com/pages#persistent-layouts 41 | Dashboard.layout = page => ; 42 | 43 | export default Dashboard; 44 | -------------------------------------------------------------------------------- /resources/js/Shared/TopHeader.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { Link } from '@inertiajs/react'; 3 | import Logo from '@/Shared/Logo'; 4 | import MainMenu from '@/Shared/MainMenu'; 5 | 6 | export default () => { 7 | const [menuOpened, setMenuOpened] = useState(false); 8 | return ( 9 |
10 | 11 | 12 | 13 |
14 | setMenuOpened(true)} 16 | className="w-6 h-6 text-white cursor-pointer fill-current" 17 | xmlns="http://www.w3.org/2000/svg" 18 | viewBox="0 0 20 20" 19 | > 20 | 21 | 22 |
23 | 24 |
{ 26 | setMenuOpened(false); 27 | }} 28 | className="fixed inset-0 z-10 bg-black opacity-25" 29 | >
30 |
31 |
32 |
33 | ); 34 | }; 35 | -------------------------------------------------------------------------------- /app/Http/Requests/ContactStoreRequest.php: -------------------------------------------------------------------------------- 1 | ['required', 'max:50'], 30 | 'last_name' => ['required', 'max:50'], 31 | 'organization_id' => ['nullable', Rule::exists('organizations', 'id')->where(function ($query) { 32 | $query->where('account_id', Auth::user()->account_id); 33 | })], 34 | 'email' => ['nullable', 'max:50', 'email'], 35 | 'phone' => ['nullable', 'max:50'], 36 | 'address' => ['nullable', 'max:150'], 37 | 'city' => ['nullable', 'max:50'], 38 | 'region' => ['nullable', 'max:50'], 39 | 'country' => ['nullable', 'max:2'], 40 | 'postal_code' => ['nullable', 'max:25'], 41 | ]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /app/Http/Requests/ContactUpdateRequest.php: -------------------------------------------------------------------------------- 1 | ['required', 'max:50'], 30 | 'last_name' => ['required', 'max:50'], 31 | 'organization_id' => ['nullable', Rule::exists('organizations', 'id')->where(function ($query) { 32 | $query->where('account_id', Auth::user()->account_id); 33 | })], 34 | 'email' => ['nullable', 'max:50', 'email'], 35 | 'phone' => ['nullable', 'max:50'], 36 | 'address' => ['nullable', 'max:150'], 37 | 'city' => ['nullable', 'max:50'], 38 | 'region' => ['nullable', 'max:50'], 39 | 'country' => ['nullable', 'max:2'], 40 | 'postal_code' => ['nullable', 'max:25'], 41 | ]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /resources/css/components/form.css: -------------------------------------------------------------------------------- 1 | .form-label { 2 | @apply mb-2 block text-gray-800 select-none; 3 | } 4 | 5 | .form-input, 6 | .form-textarea, 7 | .form-select { 8 | @apply p-2 leading-normal block w-full border border-gray-300 text-gray-800 bg-white font-sans rounded text-left appearance-none relative focus:outline-none focus:ring-1 focus:ring-indigo-400 focus:border-indigo-400; 9 | @apply placeholder-gray-600 placeholder-opacity-100; 10 | } 11 | 12 | .form-select { 13 | @apply pr-6; 14 | 15 | background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAABGdBTUEAALGPC/xhBQAAAQtJREFUOBG1lEEOgjAQRalbGj2OG9caOACn4ALGtfEuHACiazceR1PWOH/CNA3aMiTaBDpt/7zPdBKy7M/DCL9pGkvxxVp7KsvyJftL5rZt1865M+Ucq6pyyF3hNcI7Cuu+728QYn/JQA5yKaempxuZmQngOwEaYx55nu+1lQh8GIatMGi+01NwBcEmhxBqK4nAPZJ78K0KKFAJmR3oPp8+Iwgob0Oa6+TLoeCvRx+mTUYf/FVBGTPRwDkfLxnaSrRwcH0FWhNOmrkWYbE2XEicqgSa1J0LQ+aPCuQgZiLnwewbGuz5MGoAhcIkCQcjaTBjMgtXGURMVHC1wcQEy0J+Zlj8bKAnY1/UzDe2dbAVqfXn6wAAAABJRU5ErkJggg=='); 16 | background-size: 0.7rem; 17 | background-repeat: no-repeat; 18 | background-position: right 0.7rem center; 19 | 20 | &::-ms-expand { 21 | @apply opacity-0; 22 | } 23 | } 24 | 25 | .form-error { 26 | @apply text-red-500 mt-2 text-sm; 27 | } 28 | 29 | .form-input.error, 30 | .form-textarea.error, 31 | .form-select.error { 32 | @apply border-red-400 focus:border-red-400 focus:ring-red-400; 33 | } 34 | -------------------------------------------------------------------------------- /app/Models/Contact.php: -------------------------------------------------------------------------------- 1 | belongsTo(Organization::class); 15 | } 16 | 17 | public function getNameAttribute() 18 | { 19 | return $this->first_name.' '.$this->last_name; 20 | } 21 | 22 | public function scopeOrderByName($query) 23 | { 24 | $query->orderBy('last_name')->orderBy('first_name'); 25 | } 26 | 27 | public function scopeFilter($query, array $filters) 28 | { 29 | $query->when($filters['search'] ?? null, function ($query, $search) { 30 | $query->where(function ($query) use ($search) { 31 | $query->where('first_name', 'like', '%'.$search.'%') 32 | ->orWhere('last_name', 'like', '%'.$search.'%') 33 | ->orWhere('email', 'like', '%'.$search.'%') 34 | ->orWhereHas('organization', function ($query) use ($search) { 35 | $query->where('name', 'like', '%'.$search.'%'); 36 | }); 37 | }); 38 | })->when($filters['trashed'] ?? null, function ($query, $trashed) { 39 | if ($trashed === 'with') { 40 | $query->withTrashed(); 41 | } elseif ($trashed === 'only') { 42 | $query->onlyTrashed(); 43 | } 44 | }); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /resources/js/Shared/Pagination.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from '@inertiajs/react'; 3 | import classNames from 'classnames'; 4 | 5 | const PageLink = ({ active, label, url }) => { 6 | const className = classNames( 7 | [ 8 | 'mr-1 mb-1', 9 | 'px-4 py-3', 10 | 'border border-solid border-gray-300 rounded', 11 | 'text-sm', 12 | 'hover:bg-white', 13 | 'focus:outline-none focus:border-indigo-700 focus:text-indigo-700' 14 | ], 15 | { 16 | 'bg-white': active 17 | } 18 | ); 19 | return ( 20 | 21 | 22 | 23 | ); 24 | }; 25 | 26 | // Previous, if on first page 27 | // Next, if on last page 28 | // and dots, if exists (...) 29 | const PageInactive = ({ label }) => { 30 | const className = classNames( 31 | 'mr-1 mb-1 px-4 py-3 text-sm border rounded border-solid border-gray-300 text-gray' 32 | ); 33 | return ( 34 |
35 | ); 36 | }; 37 | 38 | export default ({ links = [] }) => { 39 | // dont render, if there's only 1 page (previous, 1, next) 40 | if (links.length === 3) return null; 41 | return ( 42 |
43 | {links.map(({ active, label, url }) => { 44 | return url === null ? ( 45 | 46 | ) : ( 47 | 48 | ); 49 | })} 50 |
51 | ); 52 | }; 53 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # THIS := $(realpath $(lastword $(MAKEFILE_LIST))) 2 | # HERE := $(shell dirname $(THIS)) 3 | 4 | 5 | .PHONY: all 6 | 7 | all: bannar setup install migrate note serve 8 | 9 | setup: 10 | @php -r "file_exists('.env') || copy('.env.example', '.env');" 11 | @rm -fr database/database.sqlite 12 | @touch database/database.sqlite 13 | 14 | install: 15 | @$(MAKE) composer 16 | @$(MAKE) npm 17 | @$(MAKE) key 18 | 19 | composer: 20 | @composer install 21 | 22 | npm: 23 | @npm ci 24 | @npm run dev 25 | 26 | key: 27 | @php artisan key:generate 28 | 29 | migrate: 30 | @php artisan migrate:refresh 31 | @php artisan db:seed 32 | 33 | serve: 34 | @php artisan serve 35 | @$(MAKE) note 36 | 37 | test: 38 | @php ./vendor/bin/phpunit --testdox 39 | 40 | test-coverage: 41 | @php ./vendor/bin/phpunit --coverage-html storage/logs/coverage --testdox 42 | 43 | note: 44 | @echo "\n======================================== [NOTE] ========================================" 45 | @echo "You're ready to go! Visit Ping CRM in your browser, and login with: " 46 | @echo "[*] Username: johndoe@example.com " 47 | @echo "[*] Password: secret" 48 | @echo "========================================================================================\n" 49 | 50 | bannar: 51 | @echo " _____ _ _____ _____ __ __" 52 | @echo "| __ (_) / ____| __ \| \/ |" 53 | @echo "| |__) | _ __ __ _| | | |__) | \ / |" 54 | @echo "| ___/ | '_ \ / _\` | | | _ /| |\/| |" 55 | @echo "| | | | | | | (_| | |____| | \ \| | | |" 56 | @echo "|_| |_|_| |_|\__, |\_____|_| \_\_| |_|" 57 | @echo " __/ |" 58 | @echo " |___/" 59 | @echo "\n" 60 | -------------------------------------------------------------------------------- /app/Http/Middleware/HandleInertiaRequests.php: -------------------------------------------------------------------------------- 1 | function () { 43 | return [ 44 | 'user' => Auth::check() ? new UserResource(Auth::user()->load('account')) : null 45 | ]; 46 | }, 47 | 'flash' => function () use ($request) { 48 | return [ 49 | 'success' => $request->session()->get('success'), 50 | 'error' => $request->session()->get('error'), 51 | ]; 52 | }, 53 | ]); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /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' => 1024, 48 | 'threads' => 2, 49 | 'time' => 2, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 'useTLS' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 39 | 40 | $this->mapWebRoutes(); 41 | 42 | // 43 | } 44 | 45 | /** 46 | * Define the "web" routes for the application. 47 | * 48 | * These routes all receive session state, CSRF protection, etc. 49 | * 50 | * @return void 51 | */ 52 | protected function mapWebRoutes() 53 | { 54 | Route::middleware('web') 55 | ->namespace($this->namespace) 56 | ->group(base_path('routes/web.php')); 57 | } 58 | 59 | /** 60 | * Define the "api" routes for the application. 61 | * 62 | * These routes are typically stateless. 63 | * 64 | * @return void 65 | */ 66 | protected function mapApiRoutes() 67 | { 68 | Route::prefix('api') 69 | ->middleware('api') 70 | ->namespace($this->namespace) 71 | ->group(base_path('routes/api.php')); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | bound('sentry') && $this->shouldReport($exception)) { 41 | app('sentry')->captureException($exception); 42 | } 43 | 44 | parent::report($exception); 45 | } 46 | 47 | /** 48 | * Render an exception into an HTTP response. 49 | * 50 | * @param \Illuminate\Http\Request $request 51 | * @param \Exception $exception 52 | * @return \Illuminate\Http\Response 53 | */ 54 | public function render($request, Throwable $exception) 55 | { 56 | $response = parent::render($request, $exception); 57 | 58 | if ( 59 | (App::environment('production')) 60 | && $request->header('X-Inertia') 61 | && in_array($response->status(), [500, 503, 404, 403]) 62 | ) { 63 | return Inertia::render('Error', ['status' => $response->status()]) 64 | ->toResponse($request) 65 | ->setStatusCode($response->status()); 66 | } 67 | 68 | return $response; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | content: ['./resources/views/**/*.blade.php', './resources/js/**/*.js', './resources/js/**/*.jsx'], 3 | theme: { 4 | colors: { 5 | transparent: 'transparent', 6 | current: 'currentColor', 7 | 8 | black: '#000', 9 | white: '#fff', 10 | 11 | gray: { 12 | 100: '#f7fafc', 13 | 200: '#edf2f7', 14 | 300: '#e2e8f0', 15 | 400: '#cbd5e0', 16 | 500: '#a0aec0', 17 | 600: '#718096', 18 | 700: '#4a5568', 19 | 800: '#2d3748', 20 | 900: '#1a202c' 21 | }, 22 | red: { 23 | 100: '#fff5f5', 24 | 200: '#fed7d7', 25 | 300: '#feb2b2', 26 | 400: '#fc8181', 27 | 500: '#f56565', 28 | 600: '#e53e3e', 29 | 700: '#c53030', 30 | 800: '#9b2c2c', 31 | 900: '#742a2a' 32 | }, 33 | orange: { 34 | 100: '#fffaf0', 35 | 200: '#feebc8', 36 | 300: '#fbd38d', 37 | 400: '#f6ad55', 38 | 500: '#ed8936', 39 | 600: '#dd6b20', 40 | 700: '#c05621', 41 | 800: '#9c4221', 42 | 900: '#7b341e' 43 | }, 44 | yellow: { 45 | 100: '#fffff0', 46 | 200: '#fefcbf', 47 | 300: '#faf089', 48 | 400: '#f6e05e', 49 | 500: '#ecc94b', 50 | 600: '#d69e2e', 51 | 700: '#b7791f', 52 | 800: '#975a16', 53 | 900: '#744210' 54 | }, 55 | green: { 56 | 100: '#f0fff4', 57 | 200: '#c6f6d5', 58 | 300: '#9ae6b4', 59 | 400: '#68d391', 60 | 500: '#48bb78', 61 | 600: '#38a169', 62 | 700: '#2f855a', 63 | 800: '#276749', 64 | 900: '#22543d' 65 | }, 66 | indigo: { 67 | 100: '#ebf4ff', 68 | 200: '#c3dafe', 69 | 300: '#a3bffa', 70 | 400: '#7f9cf5', 71 | 500: '#667eea', 72 | 600: '#5a67d8', 73 | 700: '#4c51bf', 74 | 800: '#434190', 75 | 900: '#3c366b' 76 | } 77 | } 78 | }, 79 | plugins: [] 80 | }; 81 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | define('LARAVEL_START', microtime(true)); 11 | 12 | /* 13 | |-------------------------------------------------------------------------- 14 | | Register The Auto Loader 15 | |-------------------------------------------------------------------------- 16 | | 17 | | Composer provides a convenient, automatically generated class loader for 18 | | our application. We just need to utilize it! We'll simply require it 19 | | into the script here so that we don't have to worry about manual 20 | | loading any of our classes later on. It feels great to relax. 21 | | 22 | */ 23 | 24 | require __DIR__.'/../vendor/autoload.php'; 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | Turn On The Lights 29 | |-------------------------------------------------------------------------- 30 | | 31 | | We need to illuminate PHP development, so let us turn on the lights. 32 | | This bootstraps the framework and gets it ready for use, then it 33 | | will load up this application so that we can run it and send 34 | | the responses back to the browser and delight our users. 35 | | 36 | */ 37 | 38 | $app = require_once __DIR__.'/../bootstrap/app.php'; 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Run The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once we have the application, we can handle the incoming request 46 | | through the kernel, and send the associated response back to 47 | | the client's browser allowing them to enjoy the creative 48 | | and wonderful application we have prepared for them. 49 | | 50 | */ 51 | 52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 53 | 54 | $response = $kernel->handle( 55 | $request = Illuminate\Http\Request::capture() 56 | ); 57 | 58 | $response->send(); 59 | 60 | $kernel->terminate($request, $response); 61 | -------------------------------------------------------------------------------- /resources/js/Shared/FileInput.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useRef } from 'react'; 2 | import { filesize } from '@/utils'; 3 | 4 | const Button = ({ text, onClick }) => ( 5 | 12 | ); 13 | 14 | export default ({ className, name, label, accept, errors = [], onChange }) => { 15 | const fileInput = useRef(); 16 | const [file, setFile] = useState(null); 17 | 18 | function browse() { 19 | fileInput.current.click(); 20 | } 21 | 22 | function remove() { 23 | setFile(null); 24 | onChange(null); 25 | fileInput.current.value = null; 26 | } 27 | 28 | function handleFileChange(e) { 29 | const file = e.target.files[0]; 30 | setFile(file); 31 | onChange(file); 32 | } 33 | 34 | return ( 35 |
36 | {label && ( 37 | 40 | )} 41 |
42 | 50 | {!file && ( 51 |
52 |
54 | )} 55 | {file && ( 56 |
57 |
58 | {file.name} 59 | 60 | ({filesize(file.size)}) 61 | 62 |
63 |
65 | )} 66 |
67 | {errors.length > 0 &&
{errors}
} 68 |
69 | ); 70 | }; 71 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 41 | } 42 | 43 | /** 44 | * Get a validator for an incoming registration request. 45 | * 46 | * @param array $data 47 | * @return \Illuminate\Contracts\Validation\Validator 48 | */ 49 | protected function validator(array $data) 50 | { 51 | return Validator::make($data, [ 52 | 'name' => ['required', 'string', 'max:255'], 53 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 54 | 'password' => ['required', 'string', 'min:8', 'confirmed'], 55 | ]); 56 | } 57 | 58 | /** 59 | * Create a new user instance after a valid registration. 60 | * 61 | * @param array $data 62 | * @return \App\User 63 | */ 64 | protected function create(array $data) 65 | { 66 | return User::create([ 67 | 'name' => $data['name'], 68 | 'email' => $data['email'], 69 | 'password' => Hash::make($data['password']), 70 | ]); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/Http/Controllers/UsersController.php: -------------------------------------------------------------------------------- 1 | Request::all('search', 'role', 'trashed'), 22 | 'users' => new UserCollection( 23 | Auth::user()->account->users() 24 | ->orderByName() 25 | ->filter(Request::only('search', 'role', 'trashed')) 26 | ->paginate() 27 | ->appends(Request::all()) 28 | ), 29 | ]); 30 | } 31 | 32 | public function create() 33 | { 34 | return Inertia::render('Users/Create'); 35 | } 36 | 37 | public function store(UserStoreRequest $request) 38 | { 39 | Auth::user()->account->users()->create( 40 | $request->validated() 41 | ); 42 | 43 | return Redirect::route('users')->with('success', 'User created.'); 44 | } 45 | 46 | public function edit(User $user) 47 | { 48 | return Inertia::render('Users/Edit', [ 49 | 'user' => new UserResource($user), 50 | ]); 51 | } 52 | 53 | public function update(User $user, UserUpdateRequest $request) 54 | { 55 | $user->update( 56 | $request->validated() 57 | ); 58 | 59 | return Redirect::back()->with('success', 'User updated.'); 60 | } 61 | 62 | public function destroy(User $user, UserDeleteRequest $request) 63 | { 64 | $user->delete(); 65 | 66 | return Redirect::back()->with('success', 'User deleted.'); 67 | } 68 | 69 | public function restore(User $user) 70 | { 71 | $user->restore(); 72 | 73 | return Redirect::back()->with('success', 'User restored.'); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Cloud Filesystem Disk 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Many applications store files both locally and in the cloud. For this 24 | | reason, you may specify a default "cloud" driver here. This driver 25 | | will be bound as the Cloud disk implementation in the container. 26 | | 27 | */ 28 | 29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Filesystem Disks 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may configure as many filesystem "disks" as you wish, and you 37 | | may even configure multiple disks of the same driver. Defaults have 38 | | been setup for each driver as an example of the required options. 39 | | 40 | | Supported Drivers: "local", "ftp", "sftp", "s3" 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'url' => env('APP_URL').'/storage', 55 | 'visibility' => 'public', 56 | ], 57 | 58 | 's3' => [ 59 | 'driver' => 's3', 60 | 'key' => env('AWS_ACCESS_KEY_ID'), 61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 62 | 'region' => env('AWS_DEFAULT_REGION'), 63 | 'bucket' => env('AWS_BUCKET'), 64 | 'url' => env('AWS_URL'), 65 | ], 66 | 67 | ], 68 | 69 | ]; 70 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Ping CRM React 2 | 3 | A demo application to illustrate how [Inertia.js](https://inertiajs.com/) works with [Laravel](https://laravel.com/) and [React](https://reactjs.org/). 4 | 5 | > This is a port of the original [Ping CRM](https://github.com/inertiajs/pingcrm) written in Laravel and Vue. 6 | 7 | ![](https://raw.githubusercontent.com/landish/pingcrm-react/master/screenshot.png) 8 | 9 | ## Requirements 10 | 11 | ``` 12 | PHP 8.1 or higher 13 | Node ^14.18.0 || >=16.0.0 14 | ``` 15 | 16 | ## Installation 17 | 18 | Clone the repo locally: 19 | 20 | ```sh 21 | git clone https://github.com/artemio87/pingcrm-react18-laravel10 22 | cd pingcrm-react18-laravel10 23 | ``` 24 | 25 | Install PHP dependencies: 26 | 27 | ```sh 28 | composer install 29 | ``` 30 | 31 | Install NPM dependencies: 32 | 33 | ```sh 34 | npm install 35 | ``` 36 | Or 37 | 38 | ```sh 39 | yarn install 40 | ``` 41 | 42 | Build assets: 43 | 44 | ```sh 45 | npm run dev 46 | ``` 47 | 48 | Or 49 | 50 | ```sh 51 | yarn dev 52 | ``` 53 | 54 | Setup configuration: 55 | 56 | ```sh 57 | cp .env.example .env 58 | ``` 59 | 60 | Generate application key: 61 | 62 | ```sh 63 | php artisan key:generate 64 | ``` 65 | 66 | Create an SQLite database. You can also use another database (MySQL, Postgres), simply update your configuration accordingly. 67 | 68 | ```sh 69 | touch database/database.sqlite 70 | ``` 71 | 72 | Run database migrations: 73 | 74 | ```sh 75 | php artisan migrate 76 | ``` 77 | 78 | Run database seeder: 79 | 80 | ```sh 81 | php artisan db:seed 82 | ``` 83 | 84 | Run artisan server: 85 | 86 | ```sh 87 | php artisan serve 88 | ``` 89 | 90 | You're ready to go! [Visit Ping CRM](http://127.0.0.1:8000/) in your browser, and login with: 91 | 92 | - **Username:** johndoe@example.com 93 | - **Password:** secret 94 | 95 | ** you need to make sure APP_URL on .env is setted like: 96 | ```code 97 | APP_URL=http://127.0.0.1:8000 98 | ``` 99 | 100 | ## Running tests 101 | 102 | To run the Ping CRM tests, run: 103 | 104 | ``` 105 | phpunit 106 | ``` 107 | 108 | ## Credits 109 | 110 | - Original work by Jonathan Reinink (@reinink) and contributors 111 | - Port to Ruby on Rails by Georg Ledermann (@ledermann) 112 | - Port to React by Lado Lomidze (@landish) 113 | - Upgrade to laravel 10 + inertia 1.0 + React 18 Artemio Rodriguez (@artemio87) 114 | -------------------------------------------------------------------------------- /app/Http/Controllers/OrganizationsController.php: -------------------------------------------------------------------------------- 1 | Request::all('search', 'trashed'), 21 | 'organizations' => new OrganizationCollection( 22 | Auth::user()->account->organizations() 23 | ->orderBy('name') 24 | ->filter(Request::only('search', 'trashed')) 25 | ->paginate() 26 | ->appends(Request::all()) 27 | ), 28 | ]); 29 | } 30 | 31 | public function create() 32 | { 33 | return Inertia::render('Organizations/Create'); 34 | } 35 | 36 | public function store(OrganizationStoreRequest $request) 37 | { 38 | Auth::user()->account->organizations()->create( 39 | $request->validated() 40 | ); 41 | 42 | return Redirect::route('organizations')->with('success', 'Organization created.'); 43 | } 44 | 45 | public function edit(Organization $organization) 46 | { 47 | return Inertia::render('Organizations/Edit', [ 48 | 'organization' => new OrganizationResource($organization), 49 | ]); 50 | } 51 | 52 | public function update(Organization $organization, OrganizationUpdateRequest $request) 53 | { 54 | $organization->update( 55 | $request->validated() 56 | ); 57 | 58 | return Redirect::back()->with('success', 'Organization updated.'); 59 | } 60 | 61 | public function destroy(Organization $organization) 62 | { 63 | $organization->delete(); 64 | 65 | return Redirect::back()->with('success', 'Organization deleted.'); 66 | } 67 | 68 | public function restore(Organization $organization) 69 | { 70 | $organization->restore(); 71 | 72 | return Redirect::back()->with('success', 'Organization restored.'); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": [ 5 | "framework", 6 | "laravel" 7 | ], 8 | "license": "MIT", 9 | "type": "project", 10 | "require": { 11 | "php": "^7.2|^8.1", 12 | "laravel/framework": "^10.0", 13 | "laravel/tinker": "^2.8.0", 14 | "inertiajs/inertia-laravel": "^0.6.9", 15 | "laravel/ui": "^4.2.1", 16 | "reinink/remember-query-strings": "^0.1.2", 17 | "sentry/sentry-laravel": "^3.2.0", 18 | "tightenco/ziggy": "^1.5.0" 19 | }, 20 | "require-dev": { 21 | "fakerphp/faker": "^1.21.0", 22 | "mockery/mockery": "^1.5.1", 23 | "spatie/laravel-ignition": "^2.0.0", 24 | "nunomaduro/collision": "^7.0.5", 25 | "barryvdh/laravel-debugbar": "^3.8.0", 26 | "beyondcode/laravel-dump-server": "^1.9.0", 27 | "phpunit/phpunit": "^10.0", 28 | "brianium/paratest": "^7.0.6" 29 | }, 30 | "autoload": { 31 | "classmap": [ 32 | "database/seeders", 33 | "database/factories" 34 | ], 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 | "extra": { 47 | "laravel": { 48 | "dont-discover": [] 49 | } 50 | }, 51 | "scripts": { 52 | "compile": [ 53 | "npm run prod", 54 | "@php artisan migrate:fresh --force", 55 | "@php artisan db:seed --force" 56 | ], 57 | "reseed": [ 58 | "@php artisan migrate:fresh", 59 | "@php artisan db:seed" 60 | ], 61 | "post-root-package-install": [ 62 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 63 | ], 64 | "post-create-project-cmd": [ 65 | "@php artisan key:generate" 66 | ], 67 | "post-autoload-dump": [ 68 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 69 | "@php artisan package:discover" 70 | ] 71 | }, 72 | "config": { 73 | "preferred-install": "dist", 74 | "sort-packages": true, 75 | "optimize-autoloader": true 76 | }, 77 | "minimum-stability": "stable", 78 | "prefer-stable": true 79 | } 80 | -------------------------------------------------------------------------------- /resources/js/Shared/BottomHeader.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { Link, usePage } from '@inertiajs/react'; 3 | import Icon from '@/Shared/Icon'; 4 | 5 | export default () => { 6 | const { auth } = usePage().props; 7 | const [menuOpened, setMenuOpened] = useState(false); 8 | return ( 9 |
10 |
{auth.user.account.name}
11 |
12 |
setMenuOpened(true)} 15 | > 16 |
17 | {auth.user.first_name} 18 | {auth.user.last_name} 19 |
20 | 24 |
25 |
26 |
27 | setMenuOpened(false)} 31 | > 32 | My Profile 33 | 34 | setMenuOpened(false)} 38 | > 39 | Manage Users 40 | 41 | 47 | Logout 48 | 49 |
50 |
{ 52 | setMenuOpened(false); 53 | }} 54 | className="fixed inset-0 z-10 bg-black opacity-25" 55 | >
56 |
57 |
58 |
59 | ); 60 | }; 61 | -------------------------------------------------------------------------------- /app/Http/Controllers/ContactsController.php: -------------------------------------------------------------------------------- 1 | Request::all('search', 'trashed'), 23 | 'contacts' => new ContactCollection( 24 | Auth::user()->account->contacts() 25 | ->with('organization') 26 | ->orderByName() 27 | ->filter(Request::only('search', 'trashed')) 28 | ->paginate() 29 | ->appends(Request::all()) 30 | ), 31 | ]); 32 | } 33 | 34 | public function create() 35 | { 36 | return Inertia::render('Contacts/Create', [ 37 | 'organizations' => new UserOrganizationCollection( 38 | Auth::user()->account->organizations() 39 | ->orderBy('name') 40 | ->get() 41 | ), 42 | ]); 43 | } 44 | 45 | public function store(ContactStoreRequest $request) 46 | { 47 | Auth::user()->account->contacts()->create( 48 | $request->validated() 49 | ); 50 | 51 | return Redirect::route('contacts')->with('success', 'Contact created.'); 52 | } 53 | 54 | public function edit(Contact $contact) 55 | { 56 | return Inertia::render('Contacts/Edit', [ 57 | 'contact' => new ContactResource($contact), 58 | 'organizations' => new UserOrganizationCollection( 59 | Auth::user()->account->organizations() 60 | ->orderBy('name') 61 | ->get() 62 | ), 63 | ]); 64 | } 65 | 66 | public function update(Contact $contact, ContactUpdateRequest $request) 67 | { 68 | $contact->update( 69 | $request->validated() 70 | ); 71 | 72 | return Redirect::back()->with('success', 'Contact updated.'); 73 | } 74 | 75 | public function destroy(Contact $contact) 76 | { 77 | $contact->delete(); 78 | 79 | return Redirect::back()->with('success', 'Contact deleted.'); 80 | } 81 | 82 | public function restore(Contact $contact) 83 | { 84 | $contact->restore(); 85 | 86 | return Redirect::back()->with('success', 'Contact restored.'); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /tests/Feature/UsersTest.php: -------------------------------------------------------------------------------- 1 | 'Acme Corporation']); 18 | 19 | $this->user = User::factory()->make([ 20 | 'account_id' => $account->id, 21 | 'first_name' => 'John', 22 | 'last_name' => 'Doe', 23 | 'email' => 'johndoe@example.com', 24 | 'owner' => true, 25 | ]); 26 | } 27 | 28 | public function test_can_view_users() 29 | { 30 | User::factory()->count(5)->create(['account_id' => 1]); 31 | 32 | $this->actingAs($this->user) 33 | ->get('/users') 34 | ->assertStatus(200) 35 | ->assertInertia(function (Assert $page) { 36 | $page->component('Users/Index'); 37 | $page->has('users.data', 5, function (Assert $page) { 38 | $page->hasAll(['id', 'name', 'email', 'owner', 'photo', 'deleted_at']); 39 | }); 40 | }); 41 | } 42 | 43 | public function test_can_search_for_users() 44 | { 45 | User::factory()->count(5)->create(['account_id' => 1]); 46 | 47 | User::first()->update([ 48 | 'first_name' => 'Greg', 49 | 'last_name' => 'Andersson' 50 | ]); 51 | 52 | $this->actingAs($this->user) 53 | ->get('/users?search=Greg') 54 | ->assertStatus(200) 55 | ->assertInertia(function (Assert $page) { 56 | $page->where('filters.search', 'Greg'); 57 | $page->has('users.data', 1, function (Assert $page) { 58 | $page->where('name', 'Greg Andersson')->etc(); 59 | }); 60 | }); 61 | } 62 | 63 | public function test_cannot_view_deleted_users() 64 | { 65 | User::factory()->count(5)->create(['account_id' => 1]); 66 | User::first()->delete(); 67 | 68 | $this->actingAs($this->user) 69 | ->get('/users') 70 | ->assertStatus(200) 71 | ->assertInertia(function (Assert $page) { 72 | $page->has('users.data', 4); 73 | }); 74 | } 75 | 76 | public function test_can_filter_to_view_deleted_users() 77 | { 78 | User::factory()->count(5)->create(['account_id' => 1]); 79 | User::first()->delete(); 80 | 81 | $this->actingAs($this->user) 82 | ->get('/users?trashed=with') 83 | ->assertStatus(200) 84 | ->assertInertia(function (Assert $page) { 85 | $page->where('filters.trashed', 'with'); 86 | $page->has('users.data', 5); 87 | }); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/Login.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Helmet from 'react-helmet'; 3 | import { useForm } from '@inertiajs/react'; 4 | import Logo from '@/Shared/Logo'; 5 | import LoadingButton from '@/Shared/LoadingButton'; 6 | import TextInput from '@/Shared/TextInput'; 7 | 8 | export default () => { 9 | const { data, setData, errors, post, processing } = useForm({ 10 | email: 'johndoe@example.com', 11 | password: 'secret', 12 | remember: true 13 | }); 14 | 15 | function handleSubmit(e) { 16 | e.preventDefault(); 17 | post(route('login.attempt')); 18 | } 19 | 20 | return ( 21 |
22 | 23 |
24 | 28 |
32 |
33 |

Welcome Back!

34 |
35 | setData('email', e.target.value)} 43 | /> 44 | setData('password', e.target.value)} 52 | /> 53 | 67 |
68 |
69 | 70 | Forgot password? 71 | 72 | 77 | Login 78 | 79 |
80 | 81 |
82 |
83 | ); 84 | }; 85 | -------------------------------------------------------------------------------- /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 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'retry_after' => 90, 49 | 'block_for' => 0, 50 | ], 51 | 52 | 'sqs' => [ 53 | 'driver' => 'sqs', 54 | 'key' => env('AWS_ACCESS_KEY_ID'), 55 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 56 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 57 | 'queue' => env('SQS_QUEUE', 'your-queue-name'), 58 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 59 | ], 60 | 61 | 'redis' => [ 62 | 'driver' => 'redis', 63 | 'connection' => 'default', 64 | 'queue' => env('REDIS_QUEUE', 'default'), 65 | 'retry_after' => 90, 66 | 'block_for' => null, 67 | ], 68 | 69 | ], 70 | 71 | /* 72 | |-------------------------------------------------------------------------- 73 | | Failed Queue Jobs 74 | |-------------------------------------------------------------------------- 75 | | 76 | | These options configure the behavior of failed queue job logging so you 77 | | can control which database and table are used to store the jobs that 78 | | have failed. You may change them to any database / table you wish. 79 | | 80 | */ 81 | 82 | 'failed' => [ 83 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database'), 84 | 'database' => env('DB_CONNECTION', 'mysql'), 85 | 'table' => 'failed_jobs', 86 | ], 87 | 88 | ]; 89 | -------------------------------------------------------------------------------- /tests/Feature/ContactsTest.php: -------------------------------------------------------------------------------- 1 | 'Acme Corporation']); 18 | 19 | $this->user = User::factory()->make([ 20 | 'account_id' => $account->id, 21 | 'first_name' => 'John', 22 | 'last_name' => 'Doe', 23 | 'email' => 'johndoe@example.com', 24 | 'owner' => true, 25 | ]); 26 | } 27 | 28 | public function test_can_view_contacts() 29 | { 30 | $this->user->account->contacts()->saveMany( 31 | Contact::factory()->count(5)->make() 32 | ); 33 | 34 | $this->actingAs($this->user) 35 | ->get('/contacts') 36 | ->assertStatus(200) 37 | ->assertInertia(function (Assert $page) { 38 | $page->component('Contacts/Index'); 39 | $page->has('contacts.data', 5, function (Assert $page) { 40 | $page->hasAll(['id', 'name', 'phone', 'city', 'deleted_at', 'organization']); 41 | }); 42 | }); 43 | } 44 | 45 | public function test_can_search_for_contacts() 46 | { 47 | $this->user->account->contacts()->saveMany( 48 | Contact::factory()->count(5)->make() 49 | )->first()->update([ 50 | 'first_name' => 'Greg', 51 | 'last_name' => 'Andersson' 52 | ]); 53 | 54 | $this->actingAs($this->user) 55 | ->get('/contacts?search=Greg') 56 | ->assertStatus(200) 57 | ->assertInertia(function (Assert $page) { 58 | $page->where('filters.search', 'Greg'); 59 | $page->has('contacts.data', 1, function (Assert $page) { 60 | $page->where('name', 'Greg Andersson')->etc(); 61 | }); 62 | }); 63 | } 64 | 65 | public function test_cannot_view_deleted_contacts() 66 | { 67 | $this->user->account->contacts()->saveMany( 68 | Contact::factory()->count(5)->make() 69 | )->first()->delete(); 70 | 71 | $this->actingAs($this->user) 72 | ->get('/contacts') 73 | ->assertStatus(200) 74 | ->assertInertia(function (Assert $page) { 75 | $page->has('contacts.data', 4); 76 | }); 77 | } 78 | 79 | public function test_can_filter_to_view_deleted_contacts() 80 | { 81 | $this->user->account->contacts()->saveMany( 82 | Contact::factory()->count(5)->make() 83 | )->first()->delete(); 84 | 85 | $this->actingAs($this->user) 86 | ->get('/contacts?trashed=with') 87 | ->assertStatus(200) 88 | ->assertInertia(function (Assert $page) { 89 | $page->where('filters.trashed', 'with'); 90 | $page->has('contacts.data', 5); 91 | }); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /tests/Feature/OrganizationsTest.php: -------------------------------------------------------------------------------- 1 | 'Acme Corporation']); 18 | 19 | $this->user = User::factory()->make([ 20 | 'account_id' => $account->id, 21 | 'first_name' => 'John', 22 | 'last_name' => 'Doe', 23 | 'email' => 'johndoe@example.com', 24 | 'owner' => true, 25 | ]); 26 | } 27 | 28 | public function test_can_view_organizations() 29 | { 30 | $this->user->account->organizations()->saveMany( 31 | Organization::factory()->count(5)->make() 32 | ); 33 | 34 | $this->actingAs($this->user) 35 | ->get('/organizations') 36 | ->assertStatus(200) 37 | ->assertInertia(function (Assert $page) { 38 | $page->component('Organizations/Index'); 39 | $page->has('organizations.data', 5, function (Assert $page) { 40 | $page->hasAll(['id', 'name', 'phone', 'city', 'deleted_at']); 41 | }); 42 | }); 43 | } 44 | 45 | public function test_can_search_for_organizations() 46 | { 47 | $this->user->account->organizations()->saveMany( 48 | Organization::factory()->count(5)->make() 49 | )->first()->update(['name' => 'Some Big Fancy Company Name']); 50 | 51 | $this->actingAs($this->user) 52 | ->get('/organizations?search=Some Big Fancy Company Name') 53 | ->assertStatus(200) 54 | ->assertInertia(function (Assert $page) { 55 | $page->where('filters.search', 'Some Big Fancy Company Name'); 56 | $page->has('organizations.data', 1, function (Assert $page) { 57 | $page->where('name', 'Some Big Fancy Company Name')->etc(); 58 | }); 59 | }); 60 | } 61 | 62 | public function test_cannot_view_deleted_organizations() 63 | { 64 | $this->user->account->organizations()->saveMany( 65 | Organization::factory()->count(5)->make() 66 | )->first()->delete(); 67 | 68 | $this->actingAs($this->user) 69 | ->get('/organizations') 70 | ->assertStatus(200) 71 | ->assertInertia(function (Assert $page) { 72 | $page->has('organizations.data', 4); 73 | }); 74 | } 75 | 76 | public function test_can_filter_to_view_deleted_organizations() 77 | { 78 | $this->user->account->organizations()->saveMany( 79 | Organization::factory()->count(5)->make() 80 | )->first()->delete(); 81 | 82 | $this->actingAs($this->user) 83 | ->get('/organizations?trashed=with') 84 | ->assertStatus(200) 85 | ->assertInertia(function (Assert $page) { 86 | $page->where('filters.trashed', 'with'); 87 | $page->has('organizations.data', 5); 88 | }); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | 'boolean', 23 | ]; 24 | 25 | public function account() 26 | { 27 | return $this->belongsTo(Account::class); 28 | } 29 | 30 | public function getNameAttribute() 31 | { 32 | return $this->first_name.' '.$this->last_name; 33 | } 34 | 35 | public function setPasswordAttribute($password) 36 | { 37 | if(!$password) return; 38 | 39 | $this->attributes['password'] = Hash::make($password); 40 | } 41 | 42 | public function setPhotoAttribute($photo) 43 | { 44 | if(!$photo) return; 45 | 46 | $this->attributes['photo_path'] = $photo instanceof UploadedFile ? $photo->store('users') : $photo; 47 | } 48 | 49 | public function getPhotoAttribute() { 50 | return $this->photoUrl(['w' => 40, 'h' => 40, 'fit' => 'crop']); 51 | } 52 | 53 | public function photoUrl(array $attributes) 54 | { 55 | if ($this->photo_path) { 56 | return URL::to(App::make(Server::class)->fromPath($this->photo_path, $attributes)); 57 | } 58 | } 59 | 60 | public function isDemoUser() 61 | { 62 | return $this->email === 'johndoe@example.com'; 63 | } 64 | 65 | public function scopeOrderByName($query) 66 | { 67 | $query->orderBy('last_name')->orderBy('first_name'); 68 | } 69 | 70 | public function scopeWhereRole($query, $role) 71 | { 72 | switch ($role) { 73 | case 'user': return $query->where('owner', false); 74 | case 'owner': return $query->where('owner', true); 75 | } 76 | } 77 | 78 | public function scopeFilter($query, array $filters) 79 | { 80 | $query->when($filters['search'] ?? null, function ($query, $search) { 81 | $query->where(function ($query) use ($search) { 82 | $query->where('first_name', 'like', '%'.$search.'%') 83 | ->orWhere('last_name', 'like', '%'.$search.'%') 84 | ->orWhere('email', 'like', '%'.$search.'%'); 85 | }); 86 | })->when($filters['role'] ?? null, function ($query, $role) { 87 | $query->whereRole($role); 88 | })->when($filters['trashed'] ?? null, function ($query, $trashed) { 89 | if ($trashed === 'with') { 90 | $query->withTrashed(); 91 | } elseif ($trashed === 'only') { 92 | $query->onlyTrashed(); 93 | } 94 | }); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | [ 31 | \App\Http\Middleware\EncryptCookies::class, 32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 33 | \Illuminate\Session\Middleware\StartSession::class, 34 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 36 | \App\Http\Middleware\VerifyCsrfToken::class, 37 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 38 | \App\Http\Middleware\HandleInertiaRequests::class, 39 | ], 40 | 41 | 'api' => [ 42 | 'throttle:60,1', 43 | 'bindings', 44 | ], 45 | ]; 46 | 47 | /** 48 | * The application's route middleware. 49 | * 50 | * These middleware may be assigned to groups or used individually. 51 | * 52 | * @var array 53 | */ 54 | protected $routeMiddleware = [ 55 | 'auth' => \App\Http\Middleware\Authenticate::class, 56 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 57 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 58 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 59 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 60 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 61 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 62 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 63 | 'remember' => \Reinink\RememberQueryStrings::class, 64 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 65 | ]; 66 | 67 | /** 68 | * The priority-sorted list of middleware. 69 | * 70 | * This forces non-global middleware to always be in the given order. 71 | * 72 | * @var array 73 | */ 74 | protected $middlewarePriority = [ 75 | \Illuminate\Session\Middleware\StartSession::class, 76 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 77 | \App\Http\Middleware\Authenticate::class, 78 | \Illuminate\Session\Middleware\AuthenticateSession::class, 79 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 80 | \Illuminate\Auth\Middleware\Authorize::class, 81 | ]; 82 | } 83 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Log Channels 25 | |-------------------------------------------------------------------------- 26 | | 27 | | Here you may configure the log channels for your application. Out of 28 | | the box, Laravel uses the Monolog PHP logging library. This gives 29 | | you a variety of powerful log handlers / formatters to utilize. 30 | | 31 | | Available Drivers: "single", "daily", "slack", "syslog", 32 | | "errorlog", "monolog", 33 | | "custom", "stack" 34 | | 35 | */ 36 | 37 | 'channels' => [ 38 | 'stack' => [ 39 | 'driver' => 'stack', 40 | 'channels' => ['single'], 41 | 'ignore_exceptions' => false, 42 | ], 43 | 44 | 'single' => [ 45 | 'driver' => 'single', 46 | 'path' => storage_path('logs/laravel.log'), 47 | 'level' => 'debug', 48 | ], 49 | 50 | 'daily' => [ 51 | 'driver' => 'daily', 52 | 'path' => storage_path('logs/laravel.log'), 53 | 'level' => 'debug', 54 | 'days' => 14, 55 | ], 56 | 57 | 'slack' => [ 58 | 'driver' => 'slack', 59 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 60 | 'username' => 'Laravel Log', 61 | 'emoji' => ':boom:', 62 | 'level' => 'critical', 63 | ], 64 | 65 | 'papertrail' => [ 66 | 'driver' => 'monolog', 67 | 'level' => 'debug', 68 | 'handler' => SyslogUdpHandler::class, 69 | 'handler_with' => [ 70 | 'host' => env('PAPERTRAIL_URL'), 71 | 'port' => env('PAPERTRAIL_PORT'), 72 | ], 73 | ], 74 | 75 | 'stderr' => [ 76 | 'driver' => 'monolog', 77 | 'handler' => StreamHandler::class, 78 | 'formatter' => env('LOG_STDERR_FORMATTER'), 79 | 'with' => [ 80 | 'stream' => 'php://stderr', 81 | ], 82 | ], 83 | 84 | 'syslog' => [ 85 | 'driver' => 'syslog', 86 | 'level' => 'debug', 87 | ], 88 | 89 | 'errorlog' => [ 90 | 'driver' => 'errorlog', 91 | 'level' => 'debug', 92 | ], 93 | 94 | 'null' => [ 95 | 'driver' => 'monolog', 96 | 'handler' => NullHandler::class, 97 | ], 98 | 99 | 'emergency' => [ 100 | 'path' => storage_path('logs/laravel.log'), 101 | ], 102 | ], 103 | 104 | ]; 105 | -------------------------------------------------------------------------------- /resources/js/Shared/FlashMessages.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react'; 2 | import { usePage } from '@inertiajs/react'; 3 | import classNames from 'classnames'; 4 | 5 | const IconSuccess = () => ( 6 | 11 | 12 | 13 | ); 14 | 15 | const IconDanger = () => ( 16 | 21 | 22 | 23 | ); 24 | 25 | const ButtonClose = ({ color, onClick }) => { 26 | const className = classNames('block w-2 h-2 fill-current', { 27 | 'text-red-700 group-hover:text-red-800': color === 'red', 28 | 'text-green-700 group-hover:text-green-800': color === 'green' 29 | }); 30 | return ( 31 | 46 | ); 47 | }; 48 | 49 | export default () => { 50 | const [visible, setVisible] = useState(true); 51 | const { flash, errors } = usePage().props; 52 | const numOfErrors = Object.keys(errors).length; 53 | 54 | useEffect(() => { 55 | setVisible(true); 56 | }, [flash, errors]); 57 | 58 | return ( 59 |
60 | {flash.success && visible && ( 61 |
62 |
63 | 64 |
65 | {flash.success} 66 |
67 |
68 | setVisible(false)} color="green" /> 69 |
70 | )} 71 | {(flash.error || numOfErrors > 0) && visible && ( 72 |
73 |
74 | 75 |
76 | {flash.error && flash.error} 77 | {numOfErrors === 1 && 'There is one form error'} 78 | {numOfErrors > 1 && `There are ${numOfErrors} form errors.`} 79 |
80 |
81 | setVisible(false)} color="red" /> 82 |
83 | )} 84 |
85 | ); 86 | }; 87 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Cache Stores 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may define all of the cache "stores" for your application as 29 | | well as their drivers. You may even define multiple stores for the 30 | | same cache driver to group types of items stored in your caches. 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'apc' => [ 37 | 'driver' => 'apc', 38 | ], 39 | 40 | 'array' => [ 41 | 'driver' => 'array', 42 | ], 43 | 44 | 'database' => [ 45 | 'driver' => 'database', 46 | 'table' => 'cache', 47 | 'connection' => null, 48 | ], 49 | 50 | 'file' => [ 51 | 'driver' => 'file', 52 | 'path' => storage_path('framework/cache/data'), 53 | ], 54 | 55 | 'memcached' => [ 56 | 'driver' => 'memcached', 57 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 58 | 'sasl' => [ 59 | env('MEMCACHED_USERNAME'), 60 | env('MEMCACHED_PASSWORD'), 61 | ], 62 | 'options' => [ 63 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 64 | ], 65 | 'servers' => [ 66 | [ 67 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 68 | 'port' => env('MEMCACHED_PORT', 11211), 69 | 'weight' => 100, 70 | ], 71 | ], 72 | ], 73 | 74 | 'redis' => [ 75 | 'driver' => 'redis', 76 | 'connection' => 'cache', 77 | ], 78 | 79 | 'dynamodb' => [ 80 | 'driver' => 'dynamodb', 81 | 'key' => env('AWS_ACCESS_KEY_ID'), 82 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 83 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 84 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 85 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 86 | ], 87 | 88 | ], 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Cache Key Prefix 93 | |-------------------------------------------------------------------------- 94 | | 95 | | When utilizing a RAM based store such as APC or Memcached, there might 96 | | be other applications utilizing the same cache. So, we'll specify a 97 | | value to get prefixed to all our keys so we can avoid collisions. 98 | | 99 | */ 100 | 101 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), 102 | 103 | ]; 104 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | name('login')->uses('Auth\LoginController@showLoginForm')->middleware('guest'); 16 | Route::post('login')->name('login.attempt')->uses('Auth\LoginController@login')->middleware('guest'); 17 | Route::post('logout')->name('logout')->uses('Auth\LoginController@logout'); 18 | 19 | // Dashboard 20 | Route::get('/')->name('dashboard')->uses('DashboardController')->middleware('auth'); 21 | 22 | // Users 23 | Route::get('users')->name('users')->uses('UsersController@index')->middleware('remember', 'auth'); 24 | Route::get('users/create')->name('users.create')->uses('UsersController@create')->middleware('auth'); 25 | Route::post('users')->name('users.store')->uses('UsersController@store')->middleware('auth'); 26 | Route::get('users/{user}/edit')->name('users.edit')->uses('UsersController@edit')->middleware('auth'); 27 | Route::put('users/{user}')->name('users.update')->uses('UsersController@update')->middleware('auth'); 28 | Route::delete('users/{user}')->name('users.destroy')->uses('UsersController@destroy')->middleware('auth'); 29 | Route::put('users/{user}/restore')->name('users.restore')->uses('UsersController@restore')->middleware('auth'); 30 | 31 | // Images 32 | Route::get('/img/{path}', 'ImagesController@show')->where('path', '.*'); 33 | 34 | // Organizations 35 | Route::get('organizations')->name('organizations')->uses('OrganizationsController@index')->middleware('remember', 'auth'); 36 | Route::get('organizations/create')->name('organizations.create')->uses('OrganizationsController@create')->middleware('auth'); 37 | Route::post('organizations')->name('organizations.store')->uses('OrganizationsController@store')->middleware('auth'); 38 | Route::get('organizations/{organization}/edit')->name('organizations.edit')->uses('OrganizationsController@edit')->middleware('auth'); 39 | Route::put('organizations/{organization}')->name('organizations.update')->uses('OrganizationsController@update')->middleware('auth'); 40 | Route::delete('organizations/{organization}')->name('organizations.destroy')->uses('OrganizationsController@destroy')->middleware('auth'); 41 | Route::put('organizations/{organization}/restore')->name('organizations.restore')->uses('OrganizationsController@restore')->middleware('auth'); 42 | 43 | // Contacts 44 | Route::get('contacts')->name('contacts')->uses('ContactsController@index')->middleware('remember', 'auth'); 45 | Route::get('contacts/create')->name('contacts.create')->uses('ContactsController@create')->middleware('auth'); 46 | Route::post('contacts')->name('contacts.store')->uses('ContactsController@store')->middleware('auth'); 47 | Route::get('contacts/{contact}/edit')->name('contacts.edit')->uses('ContactsController@edit')->middleware('auth'); 48 | Route::put('contacts/{contact}')->name('contacts.update')->uses('ContactsController@update')->middleware('auth'); 49 | Route::delete('contacts/{contact}')->name('contacts.destroy')->uses('ContactsController@destroy')->middleware('auth'); 50 | Route::put('contacts/{contact}/restore')->name('contacts.restore')->uses('ContactsController@restore')->middleware('auth'); 51 | 52 | // Reports 53 | Route::get('reports')->name('reports')->uses('ReportsController')->middleware('auth'); 54 | 55 | // 500 error 56 | Route::get('500', function () { 57 | //echo $fail; 58 | }); 59 | -------------------------------------------------------------------------------- /resources/js/Pages/Users/Create.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, useForm } from '@inertiajs/react'; 3 | import Layout from '@/Shared/Layout'; 4 | import LoadingButton from '@/Shared/LoadingButton'; 5 | import TextInput from '@/Shared/TextInput'; 6 | import SelectInput from '@/Shared/SelectInput'; 7 | import FileInput from '@/Shared/FileInput'; 8 | 9 | const Create = () => { 10 | const { data, setData, errors, post, processing } = useForm({ 11 | first_name: '', 12 | last_name: '', 13 | email: '', 14 | password: '', 15 | owner: '0', 16 | photo: '' 17 | }); 18 | 19 | function handleSubmit(e) { 20 | e.preventDefault(); 21 | post(route('users.store')); 22 | } 23 | 24 | return ( 25 |
26 |
27 |

28 | 32 | Users 33 | 34 | / Create 35 |

36 |
37 |
38 |
39 |
40 | setData('first_name', e.target.value)} 47 | /> 48 | setData('last_name', e.target.value)} 55 | /> 56 | setData('email', e.target.value)} 64 | /> 65 | setData('password', e.target.value)} 73 | /> 74 | setData('owner', e.target.value)} 81 | > 82 | 83 | 84 | 85 | setData('photo', photo)} 93 | /> 94 |
95 |
96 | 101 | Create User 102 | 103 |
104 |
105 |
106 |
107 | ); 108 | }; 109 | 110 | Create.layout = page => ; 111 | 112 | export default Create; 113 | -------------------------------------------------------------------------------- /resources/js/Pages/Organizations/Index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, usePage } from '@inertiajs/react'; 3 | import Layout from '@/Shared/Layout'; 4 | import Icon from '@/Shared/Icon'; 5 | import SearchFilter from '@/Shared/SearchFilter'; 6 | import Pagination from '@/Shared/Pagination'; 7 | 8 | const Index = () => { 9 | const { organizations } = usePage().props; 10 | const { 11 | data, 12 | meta: { links } 13 | } = organizations; 14 | return ( 15 |
16 |

Organizations

17 |
18 | 19 | 23 | Create 24 | Organization 25 | 26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 | 36 | 37 | 38 | 39 | {data.map(({ id, name, city, phone, deleted_at }) => { 40 | return ( 41 | 45 | 59 | 68 | 77 | 89 | 90 | ); 91 | })} 92 | {data.length === 0 && ( 93 | 94 | 97 | 98 | )} 99 | 100 |
NameCity 34 | Phone 35 |
46 | 50 | {name} 51 | {deleted_at && ( 52 | 56 | )} 57 | 58 | 60 | 65 | {city} 66 | 67 | 69 | 74 | {phone} 75 | 76 | 78 | 83 | 87 | 88 |
95 | No organizations found. 96 |
101 |
102 | 103 |
104 | ); 105 | }; 106 | 107 | Index.layout = page => ; 108 | 109 | export default Index; 110 | -------------------------------------------------------------------------------- /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", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'token', 46 | 'provider' => 'users', 47 | 'hash' => false, 48 | ], 49 | ], 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | User Providers 54 | |-------------------------------------------------------------------------- 55 | | 56 | | All authentication drivers have a user provider. This defines how the 57 | | users are actually retrieved out of your database or other storage 58 | | mechanisms used by this application to persist your user's data. 59 | | 60 | | If you have multiple user tables or models you may configure multiple 61 | | sources which represent each model / table. These sources may then 62 | | be assigned to any extra authentication guards you have defined. 63 | | 64 | | Supported: "database", "eloquent" 65 | | 66 | */ 67 | 68 | 'providers' => [ 69 | 'users' => [ 70 | 'driver' => 'eloquent', 71 | 'model' => App\Models\User::class, 72 | ], 73 | 74 | // 'users' => [ 75 | // 'driver' => 'database', 76 | // 'table' => 'users', 77 | // ], 78 | ], 79 | 80 | /* 81 | |-------------------------------------------------------------------------- 82 | | Resetting Passwords 83 | |-------------------------------------------------------------------------- 84 | | 85 | | You may specify multiple password reset configurations if you have more 86 | | than one user table or model in the application and you want to have 87 | | separate password reset settings based on the specific user types. 88 | | 89 | | The expire time is the number of minutes that the reset token should be 90 | | considered valid. This security feature keeps tokens short-lived so 91 | | they have less time to be guessed. You may change this as needed. 92 | | 93 | */ 94 | 95 | 'passwords' => [ 96 | 'users' => [ 97 | 'provider' => 'users', 98 | 'table' => 'password_resets', 99 | 'expire' => 60, 100 | 'throttle' => 60, 101 | ], 102 | ], 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Password Confirmation Timeout 107 | |-------------------------------------------------------------------------- 108 | | 109 | | Here you may define the amount of seconds before a password confirmation 110 | | times out and the user is prompted to re-enter their password via the 111 | | confirmation screen. By default, the timeout lasts for three hours. 112 | | 113 | */ 114 | 115 | 'password_timeout' => 10800, 116 | 117 | ]; 118 | -------------------------------------------------------------------------------- /resources/js/Shared/SearchFilter.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect, useRef } from 'react'; 2 | import { usePage, router } from '@inertiajs/react'; 3 | import { usePrevious } from 'react-use'; 4 | import SelectInput from '@/Shared/SelectInput'; 5 | import pickBy from 'lodash/pickBy'; 6 | 7 | export default () => { 8 | const { filters } = usePage().props; 9 | const [opened, setOpened] = useState(false); 10 | 11 | const [values, setValues] = useState({ 12 | role: filters.role || '', // role is used only on users page 13 | search: filters.search || '', 14 | trashed: filters.trashed || '' 15 | }); 16 | 17 | const prevValues = usePrevious(values); 18 | 19 | function reset() { 20 | setValues({ 21 | role: '', 22 | search: '', 23 | trashed: '' 24 | }); 25 | } 26 | 27 | useEffect(() => { 28 | // https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state 29 | if (prevValues) { 30 | const query = Object.keys(pickBy(values)).length 31 | ? pickBy(values) 32 | : { remember: 'forget' }; 33 | router.get(route(route().current()), query, { 34 | replace: true, 35 | preserveState: true 36 | }); 37 | } 38 | }, [values]); 39 | 40 | function handleChange(e) { 41 | const key = e.target.name; 42 | const value = e.target.value; 43 | 44 | setValues(values => ({ 45 | ...values, 46 | [key]: value 47 | })); 48 | 49 | if (opened) setOpened(false); 50 | } 51 | 52 | return ( 53 |
54 |
55 |
59 |
setOpened(false)} 61 | className="fixed inset-0 z-20 bg-black opacity-25" 62 | >
63 |
64 | {filters.hasOwnProperty('role') && ( 65 | 72 | 73 | 74 | 75 | 76 | )} 77 | 83 | 84 | 85 | 86 | 87 |
88 |
89 | 104 | 113 |
114 | 121 |
122 | ); 123 | }; 124 | -------------------------------------------------------------------------------- /resources/js/Pages/Users/Index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, usePage } from '@inertiajs/react'; 3 | import Layout from '@/Shared/Layout'; 4 | import Icon from '@/Shared/Icon'; 5 | import SearchFilter from '@/Shared/SearchFilter'; 6 | import Pagination from '@/Shared/Pagination'; 7 | 8 | const Index = () => { 9 | const { users } = usePage().props; 10 | const { 11 | data, 12 | meta: { links } 13 | } = users; 14 | return ( 15 |
16 |

Users

17 |
18 | 19 | 23 | Create 24 | User 25 | 26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 | 36 | 37 | 38 | 39 | {data.map(({ id, name, photo, email, owner, deleted_at }) => { 40 | return ( 41 | 45 | 65 | 74 | 83 | 95 | 96 | ); 97 | })} 98 | {data.length === 0 && ( 99 | 100 | 103 | 104 | )} 105 | 106 |
NameEmail 34 | Role 35 |
46 | 50 | {photo && ( 51 | 55 | )} 56 | {name} 57 | {deleted_at && ( 58 | 62 | )} 63 | 64 | 66 | 71 | {email} 72 | 73 | 75 | 80 | {owner ? 'Owner' : 'User'} 81 | 82 | 84 | 89 | 93 | 94 |
101 | No users found. 102 |
107 |
108 | 109 |
110 | ); 111 | }; 112 | 113 | Index.layout = page => ; 114 | 115 | export default Index; 116 | -------------------------------------------------------------------------------- /resources/js/Pages/Contacts/Index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, usePage } from '@inertiajs/react'; 3 | import Layout from '@/Shared/Layout'; 4 | import Icon from '@/Shared/Icon'; 5 | import Pagination from '@/Shared/Pagination'; 6 | import SearchFilter from '@/Shared/SearchFilter'; 7 | 8 | const Index = () => { 9 | const { contacts } = usePage().props; 10 | const { 11 | data, 12 | meta: { links } 13 | } = contacts; 14 | return ( 15 |
16 |

Contacts

17 |
18 | 19 | 23 | Create 24 | Contact 25 | 26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 37 | 38 | 39 | 40 | {data.map(({ id, name, city, phone, organization, deleted_at }) => ( 41 | 45 | 59 | 68 | 77 | 86 | 98 | 99 | ))} 100 | {data.length === 0 && ( 101 | 102 | 105 | 106 | )} 107 | 108 |
NameOrganizationCity 35 | Phone 36 |
46 | 50 | {name} 51 | {deleted_at && ( 52 | 56 | )} 57 | 58 | 60 | 65 | {organization ? organization.name : ''} 66 | 67 | 69 | 74 | {city} 75 | 76 | 78 | 83 | {phone} 84 | 85 | 87 | 92 | 96 | 97 |
103 | No contacts found. 104 |
109 |
110 | 111 |
112 | ); 113 | }; 114 | 115 | Index.layout = page => ; 116 | 117 | export default Index; 118 | -------------------------------------------------------------------------------- /resources/js/Pages/Organizations/Create.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link, useForm } from '@inertiajs/react'; 3 | import Layout from '@/Shared/Layout'; 4 | import LoadingButton from '@/Shared/LoadingButton'; 5 | import TextInput from '@/Shared/TextInput'; 6 | import SelectInput from '@/Shared/SelectInput'; 7 | 8 | const Create = () => { 9 | const { data, setData, errors, post, processing } = useForm({ 10 | name: '', 11 | email: '', 12 | phone: '', 13 | address: '', 14 | city: '', 15 | region: '', 16 | country: '', 17 | postal_code: '' 18 | }); 19 | 20 | function handleSubmit(e) { 21 | e.preventDefault(); 22 | post(route('organizations.store')); 23 | } 24 | 25 | return ( 26 |
27 |

28 | 32 | Organizations 33 | 34 | / Create 35 |

36 |
37 |
38 |
39 | setData('name', e.target.value)} 46 | /> 47 | setData('email', e.target.value)} 55 | /> 56 | setData('phone', e.target.value)} 64 | /> 65 | setData('address', e.target.value)} 73 | /> 74 | setData('city', e.target.value)} 82 | /> 83 | setData('region', e.target.value)} 91 | /> 92 | setData('country', e.target.value)} 99 | > 100 | 101 | 102 | 103 | 104 | setData('postal_code', e.target.value)} 112 | /> 113 |
114 |
115 | 120 | Create Organization 121 | 122 |
123 |
124 |
125 |
126 | ); 127 | }; 128 | 129 | Create.layout = page => ; 130 | 131 | export default Create; 132 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_DRIVER', 'smtp'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | SMTP Host Address 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may provide the host address of the SMTP server used by your 27 | | applications. A default option is provided that is compatible with 28 | | the Mailgun mail service which will provide reliable deliveries. 29 | | 30 | */ 31 | 32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | SMTP Host Port 37 | |-------------------------------------------------------------------------- 38 | | 39 | | This is the SMTP port used by your application to deliver e-mails to 40 | | users of the application. Like the host we have set this value to 41 | | stay compatible with the Mailgun e-mail application by default. 42 | | 43 | */ 44 | 45 | 'port' => env('MAIL_PORT', 587), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Global "From" Address 50 | |-------------------------------------------------------------------------- 51 | | 52 | | You may wish for all e-mails sent by your application to be sent from 53 | | the same address. Here, you may specify a name and address that is 54 | | used globally for all e-mails that are sent by your application. 55 | | 56 | */ 57 | 58 | 'from' => [ 59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 60 | 'name' => env('MAIL_FROM_NAME', 'Example'), 61 | ], 62 | 63 | /* 64 | |-------------------------------------------------------------------------- 65 | | E-Mail Encryption Protocol 66 | |-------------------------------------------------------------------------- 67 | | 68 | | Here you may specify the encryption protocol that should be used when 69 | | the application send e-mail messages. A sensible default using the 70 | | transport layer security protocol should provide great security. 71 | | 72 | */ 73 | 74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | SMTP Server Username 79 | |-------------------------------------------------------------------------- 80 | | 81 | | If your SMTP server requires a username for authentication, you should 82 | | set it here. This will get used to authenticate with your server on 83 | | connection. You may also set the "password" value below this one. 84 | | 85 | */ 86 | 87 | 'username' => env('MAIL_USERNAME'), 88 | 89 | 'password' => env('MAIL_PASSWORD'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Sendmail System Path 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using the "sendmail" driver to send e-mails, we will need to know 97 | | the path to where Sendmail lives on this server. A default path has 98 | | been provided here, which will work well on most of your systems. 99 | | 100 | */ 101 | 102 | 'sendmail' => '/usr/sbin/sendmail -bs', 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Markdown Mail Settings 107 | |-------------------------------------------------------------------------- 108 | | 109 | | If you are using Markdown based email rendering, you may configure your 110 | | theme and component paths here, allowing you to customize the design 111 | | of the emails. Or, you may simply stick with the Laravel defaults! 112 | | 113 | */ 114 | 115 | 'markdown' => [ 116 | 'theme' => 'default', 117 | 118 | 'paths' => [ 119 | resource_path('views/vendor/mail'), 120 | ], 121 | ], 122 | 123 | /* 124 | |-------------------------------------------------------------------------- 125 | | Log Channel 126 | |-------------------------------------------------------------------------- 127 | | 128 | | If you are using the "log" driver, you may specify the logging channel 129 | | if you prefer to keep mail messages separate from other log entries 130 | | for simpler reading. Otherwise, the default channel will be used. 131 | | 132 | */ 133 | 134 | 'log_channel' => env('MAIL_LOG_CHANNEL'), 135 | 136 | ]; 137 | -------------------------------------------------------------------------------- /resources/js/Pages/Users/Edit.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Helmet from 'react-helmet'; 3 | import { Link, usePage, useForm, router } from '@inertiajs/react'; 4 | import Layout from '@/Shared/Layout'; 5 | import DeleteButton from '@/Shared/DeleteButton'; 6 | import LoadingButton from '@/Shared/LoadingButton'; 7 | import TextInput from '@/Shared/TextInput'; 8 | import SelectInput from '@/Shared/SelectInput'; 9 | import FileInput from '@/Shared/FileInput'; 10 | import TrashedMessage from '@/Shared/TrashedMessage'; 11 | 12 | const Edit = () => { 13 | const { user } = usePage().props; 14 | const { data, setData, errors, post, processing } = useForm({ 15 | first_name: user.first_name || '', 16 | last_name: user.last_name || '', 17 | email: user.email || '', 18 | password: user.password || '', 19 | owner: user.owner ? '1' : '0' || '0', 20 | photo: '', 21 | 22 | // NOTE: When working with Laravel PUT/PATCH requests and FormData 23 | // you SHOULD send POST request and fake the PUT request like this. 24 | _method: 'PUT' 25 | }); 26 | 27 | function handleSubmit(e) { 28 | e.preventDefault(); 29 | 30 | // NOTE: We are using POST method here, not PUT/PACH. See comment above. 31 | post(route('users.update', user.id)); 32 | } 33 | 34 | function destroy() { 35 | if (confirm('Are you sure you want to delete this user?')) { 36 | router.delete(route('users.destroy', user.id)); 37 | } 38 | } 39 | 40 | function restore() { 41 | if (confirm('Are you sure you want to restore this user?')) { 42 | router.put(route('users.restore', user.id)); 43 | } 44 | } 45 | 46 | return ( 47 |
48 | 49 |
50 |

51 | 55 | Users 56 | 57 | / 58 | {data.first_name} {data.last_name} 59 |

60 | {user.photo && ( 61 | 62 | )} 63 |
64 | {user.deleted_at && ( 65 | 66 | This user has been deleted. 67 | 68 | )} 69 |
70 |
71 |
72 | setData('first_name', e.target.value)} 79 | /> 80 | setData('last_name', e.target.value)} 87 | /> 88 | setData('email', e.target.value)} 96 | /> 97 | setData('password', e.target.value)} 105 | /> 106 | setData('owner', e.target.value)} 113 | > 114 | 115 | 116 | 117 | setData('photo', photo)} 125 | /> 126 |
127 |
128 | {!user.deleted_at && ( 129 | Delete User 130 | )} 131 | 136 | Update User 137 | 138 |
139 |
140 |
141 |
142 | ); 143 | }; 144 | 145 | Edit.layout = page => ; 146 | 147 | export default Edit; 148 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Database Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here are each of the database connections setup for your application. 26 | | Of course, examples of configuring each database platform that is 27 | | supported by Laravel is shown below to make development simple. 28 | | 29 | | 30 | | All database work in Laravel is done through the PHP PDO facilities 31 | | so make sure you have the driver for your particular database of 32 | | choice installed on your machine before you begin development. 33 | | 34 | */ 35 | 36 | 'connections' => [ 37 | 38 | 'sqlite' => [ 39 | 'driver' => 'sqlite', 40 | 'url' => env('DATABASE_URL'), 41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 42 | 'prefix' => '', 43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 44 | ], 45 | 46 | 'mysql' => [ 47 | 'driver' => 'mysql', 48 | 'url' => env('DATABASE_URL'), 49 | 'host' => env('DB_HOST', '127.0.0.1'), 50 | 'port' => env('DB_PORT', '3306'), 51 | 'database' => env('DB_DATABASE', 'forge'), 52 | 'username' => env('DB_USERNAME', 'forge'), 53 | 'password' => env('DB_PASSWORD', ''), 54 | 'unix_socket' => env('DB_SOCKET', ''), 55 | 'charset' => 'utf8mb4', 56 | 'collation' => 'utf8mb4_unicode_ci', 57 | 'prefix' => '', 58 | 'prefix_indexes' => true, 59 | 'strict' => true, 60 | 'engine' => null, 61 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 62 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 63 | ]) : [], 64 | ], 65 | 66 | 'pgsql' => [ 67 | 'driver' => 'pgsql', 68 | 'url' => env('DATABASE_URL'), 69 | 'host' => env('DB_HOST', '127.0.0.1'), 70 | 'port' => env('DB_PORT', '5432'), 71 | 'database' => env('DB_DATABASE', 'forge'), 72 | 'username' => env('DB_USERNAME', 'forge'), 73 | 'password' => env('DB_PASSWORD', ''), 74 | 'charset' => 'utf8', 75 | 'prefix' => '', 76 | 'prefix_indexes' => true, 77 | 'schema' => 'public', 78 | 'sslmode' => 'prefer', 79 | ], 80 | 81 | 'sqlsrv' => [ 82 | 'driver' => 'sqlsrv', 83 | 'url' => env('DATABASE_URL'), 84 | 'host' => env('DB_HOST', 'localhost'), 85 | 'port' => env('DB_PORT', '1433'), 86 | 'database' => env('DB_DATABASE', 'forge'), 87 | 'username' => env('DB_USERNAME', 'forge'), 88 | 'password' => env('DB_PASSWORD', ''), 89 | 'charset' => 'utf8', 90 | 'prefix' => '', 91 | 'prefix_indexes' => true, 92 | ], 93 | 94 | ], 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Migration Repository Table 99 | |-------------------------------------------------------------------------- 100 | | 101 | | This table keeps track of all the migrations that have already run for 102 | | your application. Using this information, we can determine which of 103 | | the migrations on disk haven't actually been run in the database. 104 | | 105 | */ 106 | 107 | 'migrations' => 'migrations', 108 | 109 | /* 110 | |-------------------------------------------------------------------------- 111 | | Redis Databases 112 | |-------------------------------------------------------------------------- 113 | | 114 | | Redis is an open source, fast, and advanced key-value store that also 115 | | provides a richer body of commands than a typical key-value system 116 | | such as APC or Memcached. Laravel makes it easy to dig right in. 117 | | 118 | */ 119 | 120 | 'redis' => [ 121 | 122 | 'client' => env('REDIS_CLIENT', 'phpredis'), 123 | 124 | 'options' => [ 125 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 126 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 127 | ], 128 | 129 | 'default' => [ 130 | 'url' => env('REDIS_URL'), 131 | 'host' => env('REDIS_HOST', '127.0.0.1'), 132 | 'password' => env('REDIS_PASSWORD', null), 133 | 'port' => env('REDIS_PORT', 6379), 134 | 'database' => env('REDIS_DB', 0), 135 | ], 136 | 137 | 'cache' => [ 138 | 'url' => env('REDIS_URL'), 139 | 'host' => env('REDIS_HOST', '127.0.0.1'), 140 | 'password' => env('REDIS_PASSWORD', null), 141 | 'port' => env('REDIS_PORT', 6379), 142 | 'database' => env('REDIS_CACHE_DB', 1), 143 | ], 144 | 145 | ], 146 | 147 | ]; 148 | -------------------------------------------------------------------------------- /resources/js/Shared/Icon.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default ({ name, className }) => { 4 | if (name === 'apple') { 5 | return ( 6 | 13 | 14 | 15 | 16 | 17 | 18 | ); 19 | } 20 | 21 | if (name === 'book') { 22 | return ( 23 | 28 | 29 | 30 | ); 31 | } 32 | 33 | if (name === 'cheveron-down') { 34 | return ( 35 | 40 | 41 | 42 | ); 43 | } 44 | 45 | if (name === 'cheveron-right') { 46 | return ( 47 | 52 | 53 | 54 | ); 55 | } 56 | 57 | if (name === 'dashboard') { 58 | return ( 59 | 64 | 65 | 66 | ); 67 | } 68 | 69 | if (name === 'location') { 70 | return ( 71 | 76 | 77 | 78 | ); 79 | } 80 | 81 | if (name === 'office') { 82 | return ( 83 | 90 | 94 | 95 | ); 96 | } 97 | 98 | if (name == 'printer') { 99 | return ( 100 | 105 | 106 | 107 | ); 108 | } 109 | 110 | if (name === 'shopping-cart') { 111 | return ( 112 | 117 | 118 | 119 | ); 120 | } 121 | 122 | if (name === 'store-front') { 123 | return ( 124 | 129 | 130 | 131 | ); 132 | } 133 | 134 | if (name === 'trash') { 135 | return ( 136 | 141 | 142 | 143 | ); 144 | } 145 | 146 | if (name === 'users') { 147 | return ( 148 | 153 | 154 | 155 | ); 156 | } 157 | 158 | return null; 159 | }; 160 | -------------------------------------------------------------------------------- /resources/js/Pages/Contacts/Create.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link , usePage, useForm } from '@inertiajs/react'; 3 | import Layout from '@/Shared/Layout'; 4 | import LoadingButton from '@/Shared/LoadingButton'; 5 | import TextInput from '@/Shared/TextInput'; 6 | import SelectInput from '@/Shared/SelectInput'; 7 | 8 | const Create = () => { 9 | const { organizations } = usePage().props; 10 | const { data, setData, errors, post, processing } = useForm({ 11 | first_name: '', 12 | last_name: '', 13 | organization_id: '', 14 | email: '', 15 | phone: '', 16 | address: '', 17 | city: '', 18 | region: '', 19 | country: '', 20 | postal_code: '' 21 | }); 22 | 23 | function handleSubmit(e) { 24 | e.preventDefault(); 25 | post(route('contacts.store')); 26 | } 27 | 28 | return ( 29 |
30 |

31 | 35 | Contacts 36 | 37 | / Create 38 |

39 |
40 |
41 |
42 | setData('first_name', e.target.value)} 49 | /> 50 | setData('last_name', e.target.value)} 57 | /> 58 | setData('organization_id', e.target.value)} 65 | > 66 | 67 | {organizations.map(({ id, name }) => ( 68 | 71 | ))} 72 | 73 | setData('email', e.target.value)} 81 | /> 82 | setData('phone', e.target.value)} 90 | /> 91 | setData('address', e.target.value)} 99 | /> 100 | setData('city', e.target.value)} 108 | /> 109 | setData('region', e.target.value)} 117 | /> 118 | setData('country', e.target.value)} 125 | > 126 | 127 | 128 | 129 | 130 | setData('postal_code', e.target.value)} 138 | /> 139 |
140 |
141 | 146 | Create Contact 147 | 148 |
149 |
150 |
151 |
152 | ); 153 | }; 154 | 155 | Create.layout = page => ; 156 | 157 | export default Create; 158 | --------------------------------------------------------------------------------