├── public ├── favicon.ico ├── robots.txt ├── .htaccess ├── web.config └── index.php ├── routes ├── api.php ├── channels.php ├── console.php └── web.php ├── database └── .gitignore ├── templates ├── empty │ ├── routes │ │ └── api.php │ ├── database │ │ └── .gitignore │ └── app │ │ └── Http │ │ └── Controllers │ │ ├── Controller.php │ │ └── Files │ │ └── FileController.php ├── cms │ ├── database │ │ ├── .gitignore │ │ ├── seeds │ │ │ └── DatabaseSeeder.php │ │ ├── migrations │ │ │ ├── 2019_05_02_145809_create_tags_table.php │ │ │ ├── 2019_05_02_145959_create_sections_table.php │ │ │ ├── 2019_05_02_145823_create_categories_table.php │ │ │ ├── 2019_05_02_150059_create_statuses_table.php │ │ │ ├── 2019_05_02_145740_create_settings_table.php │ │ │ ├── 2014_10_12_100000_create_password_resets_table.php │ │ │ ├── 2019_05_02_145951_create_messages_table.php │ │ │ ├── 2017_12_27_090000_create_permissions_table.php │ │ │ ├── 2019_05_02_145911_create_post_tags_table.php │ │ │ ├── 2019_11_07_112300_create_menu_items_table.php │ │ │ ├── 2013_12_01_090003_create_user_types_table.php │ │ │ ├── 2019_05_02_150123_create_transaction_products_table.php │ │ │ ├── 2014_10_12_000000_create_users_table.php │ │ │ ├── 2017_12_27_090001_create_user_permissions_table.php │ │ │ ├── 2019_05_02_150020_create_products_table.php │ │ │ ├── 2019_05_02_150051_create_customers_table.php │ │ │ ├── 2019_05_02_150104_create_transactions_table.php │ │ │ └── 2019_05_02_145857_create_posts_table.php │ │ └── factories │ │ │ └── ModelFactory.php │ └── app │ │ ├── Http │ │ └── Controllers │ │ │ ├── Admin │ │ │ ├── UserTypesController.php │ │ │ ├── PermissionsController.php │ │ │ ├── UserPermissionsController.php │ │ │ └── UsersController.php │ │ │ ├── Controller.php │ │ │ ├── Cms │ │ │ ├── MessagesController.php │ │ │ └── MenuItemsController.php │ │ │ ├── Blog │ │ │ ├── PostTagsController.php │ │ │ ├── TagsController.php │ │ │ ├── CategoriesController.php │ │ │ └── PostsController.php │ │ │ ├── Store │ │ │ ├── TransactionProductsController.php │ │ │ ├── TransactionsController.php │ │ │ └── ProductsController.php │ │ │ └── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── ResetPasswordController.php │ │ │ └── RegisterController.php │ │ └── Models │ │ ├── Cms │ │ ├── Message.php │ │ ├── Settings.php │ │ └── MenuItem.php │ │ ├── Blog │ │ ├── Tag.php │ │ ├── Category.php │ │ ├── PostTag.php │ │ └── Post.php │ │ ├── Store │ │ ├── Section.php │ │ ├── Status.php │ │ ├── TransactionProduct.php │ │ ├── Customer.php │ │ ├── Product.php │ │ └── Transaction.php │ │ └── Admin │ │ ├── Permission.php │ │ ├── UserPermission.php │ │ ├── UserType.php │ │ └── User.php ├── crm │ ├── database │ │ ├── .gitignore │ │ ├── seeds │ │ │ ├── DatabaseSeeder.php │ │ │ ├── PositionsSeeder.php │ │ │ ├── CompaniesSeeder.php │ │ │ └── PeopleSeeder.php │ │ ├── migrations │ │ │ ├── 2018_01_22_165725_add_initial_password_column_to_users_table.php │ │ │ ├── 2018_12_01_090004_add_user_type_id_to_users_table.php │ │ │ ├── 2014_10_12_100000_create_password_resets_table.php │ │ │ ├── 2017_12_27_090000_create_tasks_table.php │ │ │ ├── 2017_12_27_090000_create_company_comment_types_table.php │ │ │ ├── 2017_12_27_090000_create_person_comment_types_table.php │ │ │ ├── 2017_12_27_090000_create_languages_table.php │ │ │ ├── 2017_12_27_090000_create_company_types_table.php │ │ │ ├── 2017_12_27_090000_create_street_prefixes_table.php │ │ │ ├── 2014_10_12_000000_create_users_table.php │ │ │ ├── 2017_12_27_090000_create_permissions_table.php │ │ │ ├── 2017_12_27_090000_create_sexes_table.php │ │ │ ├── 2017_12_27_090002_create_company_files_table.php │ │ │ ├── 2018_12_01_090003_create_user_types_table.php │ │ │ ├── 2017_12_27_090003_create_position_tasks_table.php │ │ │ ├── 2017_12_27_090001_create_user_permissions_table.php │ │ │ ├── 2017_12_27_090002_create_person_comments_table.php │ │ │ ├── 2017_12_27_090002_create_company_comments_table.php │ │ │ ├── 2017_12_27_090001_create_people_table.php │ │ │ └── 2017_12_27_090002_create_positions_table.php │ │ └── factories │ │ │ └── ModelFactory.php │ └── app │ │ ├── Models │ │ ├── Crm │ │ │ ├── Sex.php │ │ │ ├── StreetPrefix.php │ │ │ ├── CompanyCommentType.php │ │ │ ├── PersonCommentType.php │ │ │ ├── CompanyType.php │ │ │ ├── Language.php │ │ │ ├── Task.php │ │ │ ├── PositionTask.php │ │ │ ├── CompanyFile.php │ │ │ ├── PersonComment.php │ │ │ ├── CompanyComment.php │ │ │ ├── Position.php │ │ │ └── Person.php │ │ └── Admin │ │ │ ├── UserType.php │ │ │ ├── Permission.php │ │ │ ├── UserPermission.php │ │ │ └── User.php │ │ └── Http │ │ └── Controllers │ │ ├── Crm │ │ ├── TasksController.php │ │ ├── LanguagesController.php │ │ ├── CompanyTypesController.php │ │ ├── CompanyCommentTypesController.php │ │ ├── CompanyFilesController.php │ │ ├── SexesController.php │ │ ├── StreetPrefixesController.php │ │ ├── PersonCommentsController.php │ │ ├── PersonCommentTypesController.php │ │ ├── CompanyCommentsController.php │ │ └── CompaniesController.php │ │ ├── Admin │ │ ├── UserTypesController.php │ │ ├── PermissionsController.php │ │ ├── UserPermissionsController.php │ │ └── UsersController.php │ │ ├── Controller.php │ │ ├── Auth │ │ ├── ForgotPasswordController.php │ │ ├── LoginController.php │ │ ├── ResetPasswordController.php │ │ └── RegisterController.php │ │ ├── Demo │ │ └── TasksController.php │ │ └── Files │ │ └── FileController.php ├── sandbox │ ├── database │ │ ├── .gitignore │ │ ├── seeds │ │ │ ├── DatabaseSeeder.php │ │ │ ├── PositionsSeeder.php │ │ │ ├── CompaniesSeeder.php │ │ │ ├── PeopleSeeder.php │ │ │ └── InitSeeder.php │ │ ├── migrations │ │ │ ├── 2018_12_01_090004_add_user_type_id_to_users_table.php │ │ │ ├── 2014_10_12_100000_create_password_resets_table.php │ │ │ ├── 2017_12_27_090000_create_tasks_table.php │ │ │ ├── 2014_10_12_000000_create_users_table.php │ │ │ └── 2018_12_01_090003_create_user_types_table.php │ │ └── factories │ │ │ └── ModelFactory.php │ ├── app │ │ ├── Models │ │ │ ├── Admin │ │ │ │ ├── UserType.php │ │ │ │ └── User.php │ │ │ └── Demo │ │ │ │ └── Task.php │ │ └── Http │ │ │ └── Controllers │ │ │ ├── Controller.php │ │ │ ├── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── ResetPasswordController.php │ │ │ └── RegisterController.php │ │ │ ├── Demo │ │ │ └── TasksController.php │ │ │ └── Files │ │ │ └── FileController.php │ └── routes │ │ └── api.php └── simple-crud │ ├── database │ ├── .gitignore │ └── migrations │ │ └── 2017_12_27_090000_create_tasks_table.php │ ├── app │ ├── Models │ │ └── Crud │ │ │ └── Task.php │ └── Http │ │ └── Controllers │ │ ├── Controller.php │ │ ├── Crud │ │ └── TasksController.php │ │ └── Files │ │ └── FileController.php │ └── routes │ └── api.php ├── bootstrap ├── cache │ └── .gitignore ├── autoload.php └── app.php ├── storage ├── debugbar │ └── .gitignore ├── logs │ └── .gitignore ├── app │ ├── public │ │ └── .gitignore │ └── .gitignore └── framework │ ├── cache │ └── .gitignore │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── .gitattributes ├── resources ├── views │ └── index.blade.php ├── assets │ ├── sass │ │ ├── app.scss │ │ └── _variables.scss │ └── js │ │ ├── components │ │ └── Example.vue │ │ ├── app.js │ │ └── bootstrap.js └── lang │ └── en │ ├── pagination.php │ ├── auth.php │ └── passwords.php ├── .gitignore ├── tests ├── TestCase.php ├── Unit │ └── ExampleTest.php ├── CreatesApplication.php └── Feature │ └── ExampleTest.php ├── app ├── Http │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── VerifyCsrfToken.php │ │ ├── TrimStrings.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── CheckRole.php │ │ └── CheckPermission.php │ └── Controllers │ │ └── Controller.php ├── Providers │ ├── BroadcastServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ ├── AppServiceProvider.php │ └── RouteServiceProvider.php ├── Console │ ├── Commands │ │ ├── HashPassword.php │ │ └── LoadTemplate.php │ └── Kernel.php ├── Libraries │ └── UserPermissions.php ├── Helpers │ ├── Validation.php │ └── Functions.php └── Exceptions │ └── Handler.php ├── config ├── cors.php ├── view.php ├── services.php ├── broadcasting.php └── filesystems.php ├── webpack.mix.js ├── server.php ├── .env.example ├── package.json ├── LICENSE ├── phpunit.xml ├── readme.md ├── composer.json └── artisan /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | title}} - {{$post->category->name}}
4 | 5 | @endforeach 6 | 7 | 8 | {{$posts->links()}} 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | /.idea 7 | /.vagrant 8 | Homestead.json 9 | Homestead.yaml 10 | npm-debug.log 11 | .env 12 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Crm/Sex.php: -------------------------------------------------------------------------------- 1 | call(InitSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /templates/crm/database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /templates/sandbox/database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Crm/CompanyCommentType.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:200', 13 | 'active' => 'boolean' 14 | ]; 15 | } 16 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Crm/PersonCommentType.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:200', 13 | 'active' => 'boolean' 14 | ]; 15 | } 16 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:200', 13 | 'code' => 'required|string|size:3', 14 | 'active' => 'boolean' 15 | ]; 16 | } 17 | -------------------------------------------------------------------------------- /templates/sandbox/app/Models/Demo/Task.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:200', 13 | 'description' => 'string|max:500|nullable', 14 | 'active' => 'boolean' 15 | ]; 16 | } 17 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | hasMany(Person::class); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /templates/simple-crud/app/Models/Crud/Task.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:200', 13 | 'description' => 'string|max:500|nullable', 14 | 'active' => 'boolean' 15 | ]; 16 | } 17 | -------------------------------------------------------------------------------- /tests/Unit/ExampleTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index']]); 14 | } 15 | 16 | public function index() 17 | { 18 | return Message::orderBy('id', 'desc')->get(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Cms/Message.php: -------------------------------------------------------------------------------- 1 | 'required|string', 18 | 'sender' => 'required|string', 19 | 'content' => 'required|string|max:5000', 20 | 'active' => 'boolean', 21 | ]; 22 | } 23 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Cms/MenuItemsController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index']]); 14 | } 15 | 16 | public function index() 17 | { 18 | return MenuItem::orderBy('order', 'asc') 19 | ->get(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Cms/Settings.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:100', 20 | 'name' => 'required|string', 21 | 'value' => 'required|string|max:5000' 22 | ]; 23 | } 24 | -------------------------------------------------------------------------------- /app/Console/Commands/HashPassword.php: -------------------------------------------------------------------------------- 1 | line('Hash: '.bcrypt($this->argument('password'))); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /templates/sandbox/app/Models/Admin/User.php: -------------------------------------------------------------------------------- 1 | belongsTo(UserType::class, 'user_type_id'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 20 | 21 | $response->assertStatus(200); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /templates/simple-crud/routes/api.php: -------------------------------------------------------------------------------- 1 | 'Crud\TasksController@multipleUpdate']); 5 | Route::post('/crud/tasks/multiple-delete', ['uses' => 'Crud\TasksController@multipleDelete']); 6 | Route::post('/crud/tasks/multiple-add', ['uses' => 'Crud\TasksController@multipleAdd']); 7 | 8 | // File management 9 | Route::group(['prefix' => 'files'], function () { 10 | // file upload 11 | Route::post('/file-upload', 'Files\FileController@fileUpload'); 12 | }); 13 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Admin/UserPermissionsController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index']]); 14 | } 15 | 16 | public function index() 17 | { 18 | return UserPermission::orderBy('id', 'asc')->with('user')->with('permission')->get(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Blog/PostTagsController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index']]); 14 | } 15 | 16 | public function index() 17 | { 18 | return PostTag 19 | ::with('post.category') 20 | ->with('tag') 21 | ->get(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Blog/Tag.php: -------------------------------------------------------------------------------- 1 | 'required|string', 19 | 'slug' => 'nullable|string' 20 | ]; 21 | 22 | public function tagPosts() 23 | { 24 | return $this->hasMany(PostTag::class, 'tag_id'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Admin/UserPermissionsController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index']]); 14 | } 15 | 16 | public function index() 17 | { 18 | return UserPermission::orderBy('id', 'asc')->with('user')->with('permission')->get(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Crm/Task.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:200', 14 | 'description' => 'string|max:500|nullable', 15 | 'active' => 'boolean' 16 | ]; 17 | 18 | public function taskPositions() 19 | { 20 | return $this->hasMany(PositionTask::class); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /config/cors.php: -------------------------------------------------------------------------------- 1 | false, 14 | 'allowedOrigins' => ['*'], 15 | 'allowedHeaders' => ['*'], 16 | 'allowedMethods' => ['*'], 17 | 'exposedHeaders' => [], 18 | 'maxAge' => 0, 19 | ]; 20 | 21 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Blog/Category.php: -------------------------------------------------------------------------------- 1 | 'required|string', 19 | 'slug' => 'nullable|string' 20 | ]; 21 | 22 | public function posts() 23 | { 24 | return $this->hasMany(Post::class, 'category_id'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Store/Section.php: -------------------------------------------------------------------------------- 1 | 'required|string', 19 | 'slug' => 'nullable|string' 20 | ]; 21 | 22 | public function products() 23 | { 24 | return $this->hasMany(Product::class, 'product_id'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Store/Status.php: -------------------------------------------------------------------------------- 1 | 'required|string', 19 | 'code' => 'nullable|string' 20 | ]; 21 | 22 | public function transactions() 23 | { 24 | return $this->hasMany(Transaction::class, 'status_id'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | const { mix } = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/assets/js/app.js', 'public/js') 15 | .sass('resources/assets/sass/app.scss', 'public/css'); 16 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Admin/Permission.php: -------------------------------------------------------------------------------- 1 | 'required|string', 16 | 'code' => 'required|string|max:10', 17 | 'active' => 'boolean' 18 | ]; 19 | 20 | public function permissionUsers() 21 | { 22 | return $this->hasMany(UserPermission::class); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /templates/crm/database/seeds/PositionsSeeder.php: -------------------------------------------------------------------------------- 1 | company; 13 | DB::table('positions')->insert([ 14 | 'company_id' => rand(1, 324), 15 | 'person_id' => rand(1, 3003), 16 | 'name' => $faker->jobTitle, 17 | 'phone' => $faker->phoneNumber, 18 | ]); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /bootstrap/autoload.php: -------------------------------------------------------------------------------- 1 | company; 13 | DB::table('positions')->insert([ 14 | 'company_id' => rand(1, 324), 15 | 'person_id' => rand(1, 3003), 16 | 'name' => $faker->jobTitle, 17 | 'phone' => $faker->phoneNumber, 18 | ]); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes If Not A Folder... 9 | RewriteCond %{REQUEST_FILENAME} !-d 10 | RewriteRule ^(.*)/$ /$1 [L,R=301] 11 | 12 | # Handle Front Controller... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_FILENAME} !-f 15 | RewriteRule ^ index.php [L] 16 | 17 | # Handle Authorization Header 18 | RewriteCond %{HTTP:Authorization} . 19 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 20 | 21 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | 'PostsController@index', 20 | 'as' => 'posts.index' 21 | ]); 22 | */ 23 | -------------------------------------------------------------------------------- /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('/home'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resources/assets/js/components/Example.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 24 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel-CRUD-API 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_LOG_LEVEL=debug 6 | APP_URL=http://127.0.0.1:8000 7 | 8 | DB_CONNECTION=mysql 9 | DB_HOST=127.0.0.1 10 | DB_PORT=3306 11 | 12 | DB_DATABASE=crm 13 | DB_USERNAME=root 14 | DB_PASSWORD= 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | SESSION_DRIVER=file 19 | SESSION_LIFETIME=120 20 | QUEUE_DRIVER=sync 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_DRIVER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | 33 | PUSHER_APP_ID= 34 | PUSHER_APP_KEY= 35 | PUSHER_APP_SECRET= 36 | -------------------------------------------------------------------------------- /app/Libraries/UserPermissions.php: -------------------------------------------------------------------------------- 1 | id; 14 | $permissions = UserPermission 15 | ::where('user_id', '=', $userId) 16 | ->where('active', true) 17 | ->with('permission') 18 | ->get(); 19 | $userPermissions = array(); 20 | 21 | foreach($permissions as $item) { 22 | $userPermissions[] = $item->permission->code; 23 | } 24 | return $userPermissions; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Cms/MenuItem.php: -------------------------------------------------------------------------------- 1 | 'required|string', 22 | 'path' => 'required|string', 23 | 'parent_menu_item_id' => 'nullable|exists:menu_items,id', 24 | 'order' => 'nullable|numeric', 25 | 'active' => 'boolean', 26 | ]; 27 | } 28 | -------------------------------------------------------------------------------- /resources/assets/js/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * First we will load all of this project's JavaScript dependencies which 4 | * includes Vue and other libraries. It is a great starting point when 5 | * building robust, powerful web applications using Vue and Laravel. 6 | */ 7 | 8 | require('./bootstrap'); 9 | 10 | window.Vue = require('vue'); 11 | 12 | /** 13 | * Next, we will create a fresh Vue application instance and attach it to 14 | * the page. Then, you may begin adding components to this application 15 | * or customize the JavaScript scaffolding to fit your unique needs. 16 | */ 17 | 18 | Vue.component('example', require('./components/Example.vue')); 19 | 20 | const app = new Vue({ 21 | el: '#app' 22 | }); 23 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Admin/Permission.php: -------------------------------------------------------------------------------- 1 | 'required|string', 19 | 'code' => 'required|string|max:10', 20 | 'active' => 'boolean', 21 | 'path' => 'required|string|max:10' 22 | ]; 23 | 24 | public function permissionUsers() 25 | { 26 | return $this->hasMany(UserPermission::class); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /templates/crm/database/seeds/CompaniesSeeder.php: -------------------------------------------------------------------------------- 1 | company; 13 | DB::table('companies')->insert([ 14 | 'name' => $company, 15 | 'common_name' => $company, 16 | 'company_type_id' => rand(1, 4), 17 | 'street_prefix_id' => 1, 18 | 'city' => $faker->city, 19 | 'street' => $faker->streetAddress, 20 | 'email' => $faker->email, 21 | ]); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'App\Listeners\EventListener', 18 | ], 19 | ]; 20 | 21 | /** 22 | * Register any events for your application. 23 | * 24 | * @return void 25 | */ 26 | public function boot() 27 | { 28 | parent::boot(); 29 | 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/sandbox/database/seeds/CompaniesSeeder.php: -------------------------------------------------------------------------------- 1 | company; 13 | DB::table('companies')->insert([ 14 | 'name' => $company, 15 | 'common_name' => $company, 16 | 'company_type_id' => rand(1, 4), 17 | 'street_prefix_id' => 1, 18 | 'city' => $faker->city, 19 | 'street' => $faker->streetAddress, 20 | 'email' => $faker->email, 21 | ]); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Blog/PostTag.php: -------------------------------------------------------------------------------- 1 | 'required|exists:posts,id', 20 | 'tag_id' => 'required|exists:tags,id' 21 | ]; 22 | 23 | public function post() 24 | { 25 | return $this->belongsTo(Post::class, 'post_id'); 26 | } 27 | 28 | public function tag() 29 | { 30 | return $this->belongsTo(Tag::class, 'tag_id'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Crm/PositionTask.php: -------------------------------------------------------------------------------- 1 | 'required|exists:positions,id', 18 | 'task_id' => 'required|exists:tasks,id', 19 | 'active' => 'boolean' 20 | ]; 21 | 22 | public function position() 23 | { 24 | return $this->belongsTo(Position::class); 25 | } 26 | 27 | public function task() 28 | { 29 | return $this->belongsTo(Task::class); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Http/Middleware/CheckRole.php: -------------------------------------------------------------------------------- 1 | user()->id; 21 | $checkRole = User::find($userId)->userType()->value($role); 22 | 23 | if ($checkRole){ 24 | return $next($request); 25 | }else{ 26 | abort(423, 'You don\'t have permission to do this'); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Crm/CompanyFile.php: -------------------------------------------------------------------------------- 1 | 'required|exists:companies,id', 20 | 'file' => 'required|string', 21 | 'file_2' => 'string|nullable', 22 | 'description' => 'string|nullable', 23 | 'active' => 'boolean', 24 | ]; 25 | 26 | public function company() 27 | { 28 | return $this->belongsTo(Company::class); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2018_01_22_165725_add_initial_password_column_to_users_table.php: -------------------------------------------------------------------------------- 1 | string('initial_password')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Admin/UserPermission.php: -------------------------------------------------------------------------------- 1 | 'required|exists:users,id', 18 | 'permission_id' => 'required|exists:permissions,id', 19 | 'active' => 'boolean' 20 | ]; 21 | 22 | public function user() 23 | { 24 | return $this->belongsTo(User::class); 25 | } 26 | 27 | public function permission() 28 | { 29 | return $this->belongsTo(Permission::class); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Admin/UserPermission.php: -------------------------------------------------------------------------------- 1 | 'required|exists:users,id', 18 | 'permission_id' => 'required|exists:permissions,id', 19 | 'active' => 'boolean' 20 | ]; 21 | 22 | public function user() 23 | { 24 | return $this->belongsTo(User::class); 25 | } 26 | 27 | public function permission() 28 | { 29 | return $this->belongsTo(Permission::class); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_05_02_145809_create_tags_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name')->unique(); 19 | $table->string('slug')->unique(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Store/TransactionProductsController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index']]); 14 | } 15 | 16 | private $m = TransactionProduct::class; 17 | private $pk = 'id'; 18 | 19 | public function index() 20 | { 21 | return TransactionProduct 22 | ::with('product.section') 23 | ->with('transaction.customer') 24 | ->with('transaction.status') 25 | ->orderBy('id', 'desc') 26 | ->get(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_05_02_145959_create_sections_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name')->unique(); 19 | $table->string('slug')->unique(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_05_02_145823_create_categories_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name')->unique(); 19 | $table->string('slug')->unique(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_05_02_150059_create_statuses_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name')->unique(); 19 | $table->string('code', 10)->unique(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2018_12_01_090004_add_user_type_id_to_users_table.php: -------------------------------------------------------------------------------- 1 | integer('user_type_id')->unsigned(); 18 | $table->foreign('user_type_id')->references('id')->on('user_types'); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | // 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /templates/sandbox/database/migrations/2018_12_01_090004_add_user_type_id_to_users_table.php: -------------------------------------------------------------------------------- 1 | integer('user_type_id')->unsigned(); 18 | $table->foreign('user_type_id')->references('id')->on('user_types'); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | // 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Helpers/Validation.php: -------------------------------------------------------------------------------- 1 | $b) { 11 | $objNoRequire[$a] = implode('|', array_diff(explode('|' , $b), ['required'])); 12 | } 13 | 14 | return $objNoRequire; 15 | } 16 | public static function update($obj, $id) 17 | { 18 | $rObj = []; 19 | 20 | foreach ($obj as $a => $b) { 21 | $rules = array_diff(explode('|' , $b), ['required']); 22 | foreach ($rules as &$rule) { 23 | $rule = strpos($rule, 'unique:') === false ? $rule : $rule . ',' . $id; 24 | } 25 | $rObj[$a] = implode('|', $rules); 26 | } 27 | 28 | return $rObj; 29 | } 30 | } -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name')->unique(); 19 | $table->string('value'); 20 | $table->string('type', 100); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | // 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six 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 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Admin/UserType.php: -------------------------------------------------------------------------------- 1 | 'required|string', 22 | 'read' => 'required|boolean', 23 | 'insert' => 'required|boolean', 24 | 'update' => 'required|boolean', 25 | 'delete' => 'required|boolean', 26 | 'admin' => 'required|boolean', 27 | 'active' => 'nullable|boolean', 28 | ]; 29 | 30 | public function user() 31 | { 32 | return $this->hasMany(User::class, 'user_type_id'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090000_create_tasks_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 200)->unique(); 19 | $table->boolean('active')->default(true); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('tasks'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /templates/crm/database/seeds/PeopleSeeder.php: -------------------------------------------------------------------------------- 1 | randomElement(['male', 'female']); 18 | DB::table('people')->insert([ 19 | 'firstname' => $faker->firstName($sex), 20 | 'lastname' => $faker->lastName, 21 | 'distinction' => $faker->suffix, 22 | 'sex_id' => $sex == 'male' ? 2 : 3, 23 | 'language_id' => 2, 24 | 'email' => $faker->email, 25 | 'phone' => $faker->phoneNumber, 26 | ]); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /templates/sandbox/database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/sandbox/database/migrations/2017_12_27_090000_create_tasks_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 200)->unique(); 19 | $table->boolean('active')->default(true); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('tasks'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /templates/sandbox/database/seeds/PeopleSeeder.php: -------------------------------------------------------------------------------- 1 | randomElement(['male', 'female']); 18 | DB::table('people')->insert([ 19 | 'firstname' => $faker->firstName($sex), 20 | 'lastname' => $faker->lastName, 21 | 'distinction' => $faker->suffix, 22 | 'sex_id' => $sex == 'male' ? 2 : 3, 23 | 'language_id' => 2, 24 | 'email' => $faker->email, 25 | 'phone' => $faker->phoneNumber, 26 | ]); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /templates/cms/database/factories/ModelFactory.php: -------------------------------------------------------------------------------- 1 | define(App\Models\Admin\User::class, function (Faker\Generator $faker) { 16 | static $password; 17 | 18 | return [ 19 | 'name' => $faker->name, 20 | 'email' => $faker->unique()->safeEmail, 21 | 'password' => $password ?: $password = bcrypt('secret'), 22 | 'remember_token' => str_random(10), 23 | ]; 24 | }); 25 | -------------------------------------------------------------------------------- /templates/crm/database/factories/ModelFactory.php: -------------------------------------------------------------------------------- 1 | define(App\Models\Admin\User::class, function (Faker\Generator $faker) { 16 | static $password; 17 | 18 | return [ 19 | 'name' => $faker->name, 20 | 'email' => $faker->unique()->safeEmail, 21 | 'password' => $password ?: $password = bcrypt('secret'), 22 | 'remember_token' => str_random(10), 23 | ]; 24 | }); 25 | -------------------------------------------------------------------------------- /templates/sandbox/database/factories/ModelFactory.php: -------------------------------------------------------------------------------- 1 | define(App\Models\Admin\User::class, function (Faker\Generator $faker) { 16 | static $password; 17 | 18 | return [ 19 | 'name' => $faker->name, 20 | 'email' => $faker->unique()->safeEmail, 21 | 'password' => $password ?: $password = bcrypt('secret'), 22 | 'remember_token' => str_random(10), 23 | ]; 24 | }); 25 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Crm/CompanyFilesController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index', 'show']]); 14 | $this->middleware('role:insert', ['only' => ['store']]); 15 | $this->middleware('role:update', ['only' => ['update', 'multipleUpdate']]); 16 | $this->middleware('role:delete', ['only' => ['destroy']]); 17 | } 18 | 19 | private $m = CompanyFile::class; 20 | private $pk = 'id'; 21 | 22 | public function index() 23 | { 24 | return CompanyFile 25 | ::orderBy('company_id', 'asc') 26 | ->with('company') 27 | ->get(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /templates/simple-crud/database/migrations/2017_12_27_090000_create_tasks_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 200)->unique(); 19 | $table->text('description'); 20 | $table->boolean('active')->default(true); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::dropIfExists('tasks'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_05_02_145951_create_messages_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('email'); 19 | $table->string('sender'); 20 | $table->string('content', 5000); 21 | $table->boolean('active')->default(true); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | // 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090000_create_company_comment_types_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 200)->unique(); 19 | $table->boolean('active')->default(true); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('company_comment_types'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090000_create_person_comment_types_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 200)->unique(); 19 | $table->boolean('active')->default(true); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('person_comment_types'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090000_create_languages_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 50)->unique(); 19 | $table->integer('priority')->unsigned(); 20 | $table->boolean('active')->default(true); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::dropIfExists('languages'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090000_create_company_types_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 200)->unique(); 19 | $table->char('code', 3)->unique(); 20 | $table->boolean('active')->default(true); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::dropIfExists('company_types'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Store/TransactionProduct.php: -------------------------------------------------------------------------------- 1 | 'required|exists:products,id', 22 | 'transaction_id' => 'required|exists:transactions,id', 23 | 'quantity' => 'integer', 24 | 'value' => 'numeric' 25 | ]; 26 | 27 | public function product() 28 | { 29 | return $this->belongsTo(Product::class, 'product_id'); 30 | } 31 | 32 | public function transaction() 33 | { 34 | return $this->belongsTo(Transaction::class, 'transaction_id'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Store/TransactionsController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index', 'show']]); 14 | } 15 | 16 | private $m = Transaction::class; 17 | private $pk = 'id'; 18 | 19 | public function index() 20 | { 21 | return Transaction 22 | ::with('customer') 23 | ->with('status') 24 | ->orderBy('id', 'desc') 25 | ->get(); 26 | } 27 | public function show($id) 28 | { 29 | $transactionInfo = Transaction 30 | ::where('id', $id) 31 | ->with('transactionProducts.product.section') 32 | ->first(); 33 | return $transactionInfo; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090000_create_street_prefixes_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 10)->unique(); 19 | $table->string('description', 100)->unique(); 20 | $table->boolean('active')->default(true); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::dropIfExists('street_prefixes'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->string('password'); 21 | $table->rememberToken(); 22 | $table->boolean('active')->default(true); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2017_12_27_090000_create_permissions_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name')->unique(); 19 | $table->string('code', 10)->unique(); 20 | $table->string('path', 10)->unique(); 21 | $table->boolean('active')->default(true); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('permissions'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090000_create_permissions_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name')->unique(); 19 | $table->string('code', 10)->unique(); 20 | $table->string('path', 10)->unique(); 21 | $table->boolean('active')->default(true); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('permissions'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /templates/sandbox/database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->string('password'); 21 | $table->rememberToken(); 22 | $table->boolean('active')->default(true); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /templates/sandbox/app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_05_02_145911_create_post_tags_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('post_id')->unsigned(); 19 | $table->foreign('post_id')->references('id')->on('posts'); 20 | $table->integer('tag_id')->unsigned(); 21 | $table->foreign('tag_id')->references('id')->on('tags'); 22 | $table->unique(['post_id', 'tag_id']); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | // 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Helpers/Functions.php: -------------------------------------------------------------------------------- 1 | command('inspire') 29 | // ->hourly(); 30 | } 31 | 32 | /** 33 | * Register the Closure based commands for the application. 34 | * 35 | * @return void 36 | */ 37 | protected function commands() 38 | { 39 | require base_path('routes/console.php'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Crm/PersonComment.php: -------------------------------------------------------------------------------- 1 | 'required|exists:people,id', 22 | 'person_comment_type_id' => 'required|exists:person_comment_types,id', 23 | 'content' => 'required|string|max:2000', 24 | 'active' => 'boolean' 25 | ]; 26 | 27 | public function person() 28 | { 29 | return $this->belongsTo(Person::class); 30 | } 31 | 32 | public function user() 33 | { 34 | return $this->belongsTo(User::class); 35 | } 36 | 37 | public function PersonCommentType() 38 | { 39 | return $this->belongsTo(PersonCommentType::class); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090000_create_sexes_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 50)->unique(); 19 | $table->char('code', 1)->unique(); 20 | $table->string('eng_name', 50)->unique(); 21 | $table->char('eng_code', 1)->unique(); 22 | $table->integer('priority')->unsigned(); 23 | $table->boolean('active')->default(true); 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('sexes'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Crm/CompanyComment.php: -------------------------------------------------------------------------------- 1 | 'required|exists:companies,id', 22 | 'company_comment_type_id' => 'required|exists:company_comment_types,id', 23 | 'content' => 'required|string|max:2000', 24 | 'active' => 'boolean' 25 | ]; 26 | 27 | public function company() 28 | { 29 | return $this->belongsTo(Company::class); 30 | } 31 | 32 | public function user() 33 | { 34 | return $this->belongsTo(User::class); 35 | } 36 | 37 | public function companyCommentType() 38 | { 39 | return $this->belongsTo(CompanyCommentType::class); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_11_07_112300_create_menu_items_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('text'); 19 | $table->string('path'); 20 | $table->integer('parent_menu_item_id')->unsigned()->nullable(); 21 | $table->foreign('parent_menu_item_id')->references('id')->on('menu_items')->onDelete('cascade');; 22 | $table->integer('order')->unsigned()->nullable(); 23 | $table->boolean('active')->default(true); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | // 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "axios": "^0.18.1", 14 | "bootstrap-sass": "^3.3.7", 15 | "cross-env": "^3.2.3", 16 | "jquery": "^3.1.1", 17 | "laravel-mix": "0.*", 18 | "lodash": "^4.17.4", 19 | "vue": "^2.1.10" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Szczepan Masny 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 | -------------------------------------------------------------------------------- /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' => realpath(storage_path('framework/views')), 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090002_create_company_files_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('file'); 19 | $table->string('file_2'); 20 | $table->integer('company_id')->unsigned(); 21 | $table->foreign('company_id')->references('id')->on('companies'); 22 | $table->string('description')->nullable(); 23 | $table->boolean('active')->default(true); 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('company_files'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | ], 21 | 22 | 'ses' => [ 23 | 'key' => env('SES_KEY'), 24 | 'secret' => env('SES_SECRET'), 25 | 'region' => 'us-east-1', 26 | ], 27 | 28 | 'sparkpost' => [ 29 | 'secret' => env('SPARKPOST_SECRET'), 30 | ], 31 | 32 | 'stripe' => [ 33 | 'model' => App\Models\Admin\User::class, 34 | 'key' => env('STRIPE_KEY'), 35 | 'secret' => env('STRIPE_SECRET'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /templates/sandbox/app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Admin/User.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:255', 30 | 'email' => 'required|string|max:255|unique:users,email', 31 | 'user_type_id' => 'exists:user_types,id', 32 | 'active' => 'nullable', 33 | ]; 34 | 35 | public function userPermissions() 36 | { 37 | return $this->hasMany(UserPermission::class); 38 | } 39 | 40 | public function userType() 41 | { 42 | return $this->belongsTo(UserType::class, 'user_type_id'); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Feature 14 | 15 | 16 | 17 | ./tests/Unit 18 | 19 | 20 | 21 | 22 | ./app 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /templates/sandbox/app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Http/Middleware/CheckPermission.php: -------------------------------------------------------------------------------- 1 | user()->id; 21 | $permissions = UserPermission 22 | ::where('user_id', '=', $userId) 23 | ->where('active', true) 24 | ->with('permission') 25 | ->get(); 26 | 27 | $found = false; 28 | foreach($permissions as $item) { 29 | if ($item->permission->code == $permission && $item->permission->active) { 30 | $found = true; 31 | break; 32 | } 33 | } 34 | if ($found){ 35 | return $next($request); 36 | }else{ 37 | abort(403, 'You do not have access to this module'); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2013_12_01_090003_create_user_types_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 255)->nullable(); 19 | $table->boolean('read')->default(true); 20 | $table->boolean('insert')->default(true); 21 | $table->boolean('update')->default(true); 22 | $table->boolean('delete')->default(true); 23 | $table->boolean('admin')->default(true); 24 | $table->boolean('active')->default(true); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::dropIfExists('user_types'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2018_12_01_090003_create_user_types_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 255)->nullable(); 19 | $table->boolean('read')->default(true); 20 | $table->boolean('insert')->default(true); 21 | $table->boolean('update')->default(true); 22 | $table->boolean('delete')->default(true); 23 | $table->boolean('admin')->default(true); 24 | $table->boolean('active')->default(true); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::dropIfExists('user_types'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /templates/sandbox/database/migrations/2018_12_01_090003_create_user_types_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 255)->nullable(); 19 | $table->boolean('read')->default(true); 20 | $table->boolean('insert')->default(true); 21 | $table->boolean('update')->default(true); 22 | $table->boolean('delete')->default(true); 23 | $table->boolean('admin')->default(true); 24 | $table->boolean('active')->default(true); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::dropIfExists('user_types'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Store/Customer.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:500', 25 | 'lastname' => 'required|string|max:500', 26 | 'company' => 'nullable|boolean', 27 | 'registration_number' => 'nullable|string', 28 | 'phone' => 'nullable|string|max:20', 29 | 'email' => 'required|string|max:200', 30 | 'street' => 'nullable|string|max:200', 31 | 'zip_code' => 'nullable|string|max:10', 32 | 'city' => 'nullable|string|max:100', 33 | 'comments' => 'nullable|string|max:2000' 34 | ]; 35 | 36 | public function transactions() 37 | { 38 | return $this->hasMany(Transaction::class, 'customer_id'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090003_create_position_tasks_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('position_id')->unsigned(); 19 | $table->foreign('position_id')->references('id')->on('positions'); 20 | $table->integer('task_id')->unsigned(); 21 | $table->foreign('task_id')->references('id')->on('tasks'); 22 | $table->unique(['position_id', 'task_id']); 23 | $table->boolean('active')->default(true); 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('position_tasks'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_05_02_150123_create_transaction_products_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('quantity')->default(1); 19 | $table->decimal('value'); 20 | $table->integer('transaction_id')->unsigned(); 21 | $table->foreign('transaction_id')->references('id')->on('transactions'); 22 | $table->integer('product_id')->unsigned(); 23 | $table->foreign('product_id')->references('id')->on('products'); 24 | $table->unique(['transaction_id', 'product_id']); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | // 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->string('password'); 21 | $table->rememberToken(); 22 | $table->boolean('active')->default(true); 23 | $table->string('initial_password')->nullable(); 24 | $table->integer('user_type_id')->unsigned(); 25 | $table->foreign('user_type_id')->references('id')->on('user_types'); 26 | $table->timestamps(); 27 | }); 28 | } 29 | 30 | /** 31 | * Reverse the migrations. 32 | * 33 | * @return void 34 | */ 35 | public function down() 36 | { 37 | Schema::dropIfExists('users'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2017_12_27_090001_create_user_permissions_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('user_id')->unsigned(); 19 | $table->foreign('user_id')->references('id')->on('users'); 20 | $table->integer('permission_id')->unsigned(); 21 | $table->foreign('permission_id')->references('id')->on('permissions'); 22 | $table->unique(['user_id', 'permission_id']); 23 | $table->boolean('active')->default(true); 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('user_permissions'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090001_create_user_permissions_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('user_id')->unsigned(); 19 | $table->foreign('user_id')->references('id')->on('users'); 20 | $table->integer('permission_id')->unsigned(); 21 | $table->foreign('permission_id')->references('id')->on('permissions'); 22 | $table->unique(['user_id', 'permission_id']); 23 | $table->boolean('active')->default(true); 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('user_permissions'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Crm/SexesController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index', 'show']]); 14 | $this->middleware('role:insert', ['only' => ['store']]); 15 | $this->middleware('role:update', ['only' => ['update', 'multipleUpdate']]); 16 | $this->middleware('role:delete', ['only' => ['destroy']]); 17 | } 18 | 19 | public function index() 20 | { 21 | return Sex::orderBy('id', 'asc')->get(); 22 | } 23 | public function create() 24 | { 25 | // 26 | } 27 | public function store(Request $request) 28 | { 29 | // 30 | } 31 | public function show(Sex $sex) 32 | { 33 | // 34 | } 35 | public function edit(Sex $sex) 36 | { 37 | // 38 | } 39 | public function update(Request $request, Sex $sex) 40 | { 41 | // 42 | } 43 | public function destroy(Sex $sex) 44 | { 45 | // 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Admin/User.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:255', 30 | 'email' => 'required|string|max:255|unique:users,email', 31 | 'login' => 'required|string|max:255|unique:users,login', 32 | 'user_type_id' => 'exists:user_types,id', 33 | 'active' => 'nullable', 34 | ]; 35 | 36 | public function userPermissions() 37 | { 38 | return $this->hasMany(UserPermission::class); 39 | } 40 | 41 | public function userType() 42 | { 43 | return $this->belongsTo(UserType::class, 'user_type_id'); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Store/Product.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:500', 25 | 'slug' => 'nullable|string|max:500', 26 | 'description' => 'required|string|max:2000', 27 | 'price' => 'required|numeric', 28 | 'quantity' => 'required|integer', 29 | 'image' => 'nullable|string', 30 | 'thumbnail' => 'required|string', 31 | 'section_id' => 'required|exists:sections,id', 32 | 'active' => 'boolean' 33 | ]; 34 | 35 | public function productTransactions() 36 | { 37 | return $this->hasMany(TransactionProduct::class, 'product_id'); 38 | } 39 | 40 | public function section() 41 | { 42 | return $this->belongsTo(Section::class, 'section_id'); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_05_02_150020_create_products_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 500); 19 | $table->string('slug', 500)->unique(); 20 | $table->string('description', 2000); 21 | $table->decimal('price'); 22 | $table->integer('quantity'); 23 | $table->string('image')->nullable(); 24 | $table->string('thumbnail')->nullable(); 25 | $table->integer('section_id')->unsigned(); 26 | $table->foreign('section_id')->references('id')->on('sections'); 27 | $table->boolean('active')->default(true); 28 | $table->timestamps(); 29 | }); 30 | } 31 | 32 | /** 33 | * Reverse the migrations. 34 | * 35 | * @return void 36 | */ 37 | public function down() 38 | { 39 | // 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Store/Transaction.php: -------------------------------------------------------------------------------- 1 | 'required|exists:categories,id', 24 | 'status_id' => 'required|exists:categories,id', 25 | 'accepted_at' => 'nullable|date', 26 | 'started_at' => 'nullable|date', 27 | 'sent_at' => 'nullable|date', 28 | 'delivered_at' => 'nullable|date', 29 | 'active' => 'boolean' 30 | ]; 31 | 32 | public function customer() 33 | { 34 | return $this->belongsTo(Customer::class, 'customer_id'); 35 | } 36 | 37 | public function status() 38 | { 39 | return $this->belongsTo(Status::class, 'status_id'); 40 | } 41 | 42 | public function transactionProducts() 43 | { 44 | return $this->hasMany(TransactionProduct::class, 'transaction_id'); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_05_02_150051_create_customers_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('firstname', 500); 19 | $table->string('lastname', 500); 20 | $table->boolean('company')->default(false); 21 | $table->string('registration_number')->nullable(); 22 | $table->string('phone', 20)->nullable(); 23 | $table->string('email', 200); 24 | $table->string('street', 200)->nullable(); 25 | $table->string('zip_code', 10)->nullable(); 26 | $table->string('city', 100)->nullable(); 27 | $table->string('comments', 2000)->nullable(); 28 | $table->timestamps(); 29 | }); 30 | } 31 | 32 | /** 33 | * Reverse the migrations. 34 | * 35 | * @return void 36 | */ 37 | public function down() 38 | { 39 | // 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Crm/StreetPrefixesController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index', 'show']]); 14 | $this->middleware('role:insert', ['only' => ['store']]); 15 | $this->middleware('role:update', ['only' => ['update', 'multipleUpdate']]); 16 | $this->middleware('role:delete', ['only' => ['destroy']]); 17 | } 18 | 19 | public function index() 20 | { 21 | return StreetPrefix::orderBy('id', 'asc')->get(); 22 | } 23 | public function create() 24 | { 25 | // 26 | } 27 | public function store(Request $request) 28 | { 29 | // 30 | } 31 | public function show(StreetPrefix $streetPrefix) 32 | { 33 | // 34 | } 35 | public function edit(StreetPrefix $streetPrefix) 36 | { 37 | // 38 | } 39 | public function update(Request $request, StreetPrefix $streetPrefix) 40 | { 41 | // 42 | } 43 | public function destroy(StreetPrefix $streetPrefix) 44 | { 45 | // 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Demo/TasksController.php: -------------------------------------------------------------------------------- 1 | rStore($this->m, $request, $this->pk); 22 | } 23 | public function show($id) 24 | { 25 | return Task::where('id', $id)->first(); 26 | } 27 | public function update(Request $request, $id) 28 | { 29 | $model = Task::where('id', $id)->first(); 30 | return $this->rUpdate($this->m, $model, $request->all(), $this->pk); 31 | } 32 | public function destroy($id) 33 | { 34 | $model = Task::where('id', $id)->first(); 35 | return $this->rDestroy($model); 36 | } 37 | public function multipleUpdate(Request $request) 38 | { 39 | return $this->rMultipleUpdate($this->m, $request, $this->pk); 40 | } 41 | public function multipleDelete(Request $request) 42 | { 43 | return $this->rMultipleDelete($this->m, $request, $this->pk); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_05_02_150104_create_transactions_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('customer_id')->unsigned(); 19 | $table->foreign('customer_id')->references('id')->on('customers'); 20 | $table->integer('status_id')->unsigned(); 21 | $table->foreign('status_id')->references('id')->on('statuses'); 22 | $table->dateTime('accepted_at')->nullable(); 23 | $table->dateTime('started_at')->nullable(); 24 | $table->dateTime('sent_at')->nullable(); 25 | $table->dateTime('delivered_at')->nullable(); 26 | $table->boolean('active')->default(true); 27 | $table->timestamps(); 28 | }); 29 | } 30 | 31 | /** 32 | * Reverse the migrations. 33 | * 34 | * @return void 35 | */ 36 | public function down() 37 | { 38 | // 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /templates/sandbox/app/Http/Controllers/Demo/TasksController.php: -------------------------------------------------------------------------------- 1 | rStore($this->m, $request, $this->pk); 22 | } 23 | public function show($id) 24 | { 25 | return Task::where('id', $id)->first(); 26 | } 27 | public function update(Request $request, $id) 28 | { 29 | $model = Task::where('id', $id)->first(); 30 | return $this->rUpdate($this->m, $model, $request->all(), $this->pk); 31 | } 32 | public function destroy($id) 33 | { 34 | $model = Task::where('id', $id)->first(); 35 | return $this->rDestroy($model); 36 | } 37 | public function multipleUpdate(Request $request) 38 | { 39 | return $this->rMultipleUpdate($this->m, $request, $this->pk); 40 | } 41 | public function multipleDelete(Request $request) 42 | { 43 | return $this->rMultipleDelete($this->m, $request, $this->pk); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /templates/simple-crud/app/Http/Controllers/Crud/TasksController.php: -------------------------------------------------------------------------------- 1 | rStore($this->m, $request, $this->pk); 22 | } 23 | public function show($id) 24 | { 25 | return Task::where('id', $id)->first(); 26 | } 27 | public function update(Request $request, $id) 28 | { 29 | $model = Task::where('id', $id)->first(); 30 | return $this->rUpdate($this->m, $model, $request->all(), $this->pk); 31 | } 32 | public function destroy($id) 33 | { 34 | $model = Task::where('id', $id)->first(); 35 | return $this->rDestroy($model); 36 | } 37 | public function multipleUpdate(Request $request) 38 | { 39 | return $this->rMultipleUpdate($this->m, $request, $this->pk); 40 | } 41 | public function multipleDelete(Request $request) 42 | { 43 | return $this->rMultipleDelete($this->m, $request, $this->pk); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090002_create_person_comments_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->text('content'); 19 | $table->integer('user_id')->unsigned(); 20 | $table->foreign('user_id')->references('id')->on('users'); 21 | $table->integer('person_id')->unsigned(); 22 | $table->foreign('person_id')->references('id')->on('people'); 23 | $table->integer('person_comment_type_id')->unsigned(); 24 | $table->foreign('person_comment_type_id')->references('id')->on('person_comment_types'); 25 | $table->boolean('active')->default(true); 26 | $table->timestamps(); 27 | }); 28 | } 29 | 30 | /** 31 | * Reverse the migrations. 32 | * 33 | * @return void 34 | */ 35 | public function down() 36 | { 37 | Schema::dropIfExists('person_comments'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090002_create_company_comments_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->text('content'); 19 | $table->integer('user_id')->unsigned(); 20 | $table->foreign('user_id')->references('id')->on('users'); 21 | $table->integer('company_id')->unsigned(); 22 | $table->foreign('company_id')->references('id')->on('companies'); 23 | $table->integer('company_comment_type_id')->unsigned(); 24 | $table->foreign('company_comment_type_id')->references('id')->on('company_comment_types'); 25 | $table->boolean('active')->default(true); 26 | $table->timestamps(); 27 | }); 28 | } 29 | 30 | /** 31 | * Reverse the migrations. 32 | * 33 | * @return void 34 | */ 35 | public function down() 36 | { 37 | Schema::dropIfExists('company_comments'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /templates/cms/app/Models/Blog/Post.php: -------------------------------------------------------------------------------- 1 | 'required|string|max:500', 26 | 'slug' => 'nullable|string|max:500', 27 | 'description' => 'required|string|max:2000', 28 | 'content' => 'required|string', 29 | 'image' => 'nullable|string', 30 | 'thumbnail' => 'required|string', 31 | 'active' => 'boolean', 32 | 'user_id' => 'nullable|exists:users,id', 33 | 'category_id' => 'required|exists:categories,id' 34 | ]; 35 | 36 | public function postTags() 37 | { 38 | return $this->hasMany(PostTag::class, 'post_id'); 39 | } 40 | 41 | public function category() 42 | { 43 | return $this->belongsTo(Category::class, 'category_id'); 44 | } 45 | 46 | public function user() 47 | { 48 | return $this->belongsTo(User::class, 'user_id'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /templates/cms/database/migrations/2019_05_02_145857_create_posts_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('title', 500); 19 | $table->string('slug', 500)->unique(); 20 | $table->string('description', 2000); 21 | $table->longText('content'); 22 | $table->string('image', 2000)->nullable(); 23 | $table->string('thumbnail', 2000); 24 | $table->boolean('active')->default(false); 25 | $table->integer('user_id')->unsigned(); 26 | $table->foreign('user_id')->references('id')->on('users'); 27 | $table->integer('category_id')->unsigned(); 28 | $table->foreign('category_id')->references('id')->on('categories'); 29 | $table->timestamps(); 30 | }); 31 | } 32 | 33 | /** 34 | * Reverse the migrations. 35 | * 36 | * @return void 37 | */ 38 | public function down() 39 | { 40 | // 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /templates/sandbox/routes/api.php: -------------------------------------------------------------------------------- 1 | 'auth', 'namespace' => 'Auth'], function () { 5 | 6 | //Route::post('/register', ['uses' => 'AuthController@register','as' => 'auth.register']); 7 | Route::post('/login', ['uses' => 'AuthController@login', 'as' => 'auth.login']); 8 | Route::post('/logout', ['uses' => 'AuthController@logout', 'as' => 'auth.logout']); 9 | 10 | // Middleware - authentication 11 | Route::group(['middleware' => ['auth.jwt']], function () { 12 | Route::get('/user', ['uses' => 'AuthController@getUser', 'as' => 'auth.getUser']); 13 | Route::post('/user', ['uses' => 'AuthController@editUser', 'as' => 'auth.editUser'])->middleware('role:update'); 14 | Route::post('/user-password', ['uses' => 'AuthController@editUserPassword', 'as' => 'auth.editUserPassword'])->middleware('role:update'); 15 | Route::post('/refresh-token', ['uses' => 'AuthController@refreshToken', 'as' => 'auth.refreshToken']); 16 | }); 17 | 18 | }); 19 | 20 | Route::apiResource('/demo/tasks', 'Demo\TasksController'); 21 | Route::post('/demo/tasks/multiple-update', ['uses' => 'Demo\TasksController@multipleUpdate']); 22 | Route::post('/demo/tasks/multiple-delete', ['uses' => 'Demo\TasksController@multipleDelete']); 23 | Route::post('/demo/tasks/multiple-add', ['uses' => 'Demo\TasksController@multipleAdd']); -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 |
2 |

the project is not supported

3 |

4 | If you want to contribute to this project please fork from this project or email me to add you to what-crud group 5 |

6 |
7 | 8 |

Laravel CRUD API

9 | 10 | ## About 11 | 12 | Laravel CRUD API is an API written using PHP and Laravel, dedicated to as a backend to the Vue CRUD project. The project includes templates withmigrations, models and controllers associated with the Vue CRUD templates. 13 | 14 | ## Requirements 15 | - PHP 7.x, 16 | - Composer 17 | 18 | ## Installation 19 | 20 | Follow these steps: 21 | 1. Clone or download this project, 22 | 2. Open command line and go to the project directory, 23 | 3. Type: 24 | ``` 25 | composer install 26 | ``` 27 | 4. Create database(s) for your project, 28 | 5. Create .env file based on .env.example and configure your project, 29 | 6. Type: 30 | ``` 31 | php artisan key:generate 32 | ``` 33 | 7. Type: 34 | ``` 35 | php artisan load-template 36 | ``` 37 | and select one of available templates 38 | 39 | 8. Type: 40 | ``` 41 | php artisan migrate 42 | ``` 43 | 9. Run seeders if available, 44 | 10. Type: 45 | ``` 46 | php artisan serve 47 | ``` 48 | 49 | ## License 50 | 51 | The Laravel CRUD API is application licensed under the [MIT license](http://opensource.org/licenses/MIT). 52 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Blog/TagsController.php: -------------------------------------------------------------------------------- 1 | middleware('role:insert', ['only' => ['store']]); 15 | $this->middleware('role:update', ['only' => ['update']]); 16 | } 17 | 18 | private $m = Tag::class; 19 | private $pk = 'id'; 20 | 21 | public function store(Request $request) 22 | { 23 | $initSlug = $request->get('name'); 24 | if ($request->has('slug')) { 25 | $initSlug = $request->get('slug'); 26 | } 27 | $computed = [ 28 | 'slug' => Functions::slugify($initSlug) 29 | ]; 30 | return $this->rStore($this->m, $request, $this->pk, $computed); 31 | } 32 | public function update(Request $request, $id) 33 | { 34 | $model = Tag::find($id); 35 | $initSlug = $request->get('name'); 36 | if ($request->has('slug')) { 37 | $initSlug = $request->get('slug'); 38 | } 39 | $computed = [ 40 | 'slug' => Functions::slugify($initSlug) 41 | ]; 42 | return $this->rUpdate($this->m, $model, $request->all(), $this->pk, $computed); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Blog/CategoriesController.php: -------------------------------------------------------------------------------- 1 | middleware('role:insert', ['only' => ['store']]); 15 | $this->middleware('role:update', ['only' => ['update']]); 16 | } 17 | 18 | private $m = Category::class; 19 | private $pk = 'id'; 20 | 21 | public function store(Request $request) 22 | { 23 | $initSlug = $request->get('name'); 24 | if ($request->has('slug')) { 25 | $initSlug = $request->get('slug'); 26 | } 27 | $computed = [ 28 | 'slug' => Functions::slugify($initSlug) 29 | ]; 30 | return $this->rStore($this->m, $request, $this->pk, $computed); 31 | } 32 | public function update(Request $request, $id) 33 | { 34 | $model = Category::find($id); 35 | $initSlug = $request->get('name'); 36 | if ($request->has('slug')) { 37 | $initSlug = $request->get('slug'); 38 | } 39 | $computed = [ 40 | 'slug' => Functions::slugify($initSlug) 41 | ]; 42 | return $this->rUpdate($this->m, $model, $request->all(), $this->pk, $computed); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Crm/Position.php: -------------------------------------------------------------------------------- 1 | 'required|exists:people,id', 27 | 'company_id' => 'required|exists:companies,id', 28 | 'name' => 'string|max:255|nullable', 29 | 'phone' => 'string|max:50|nullable', 30 | 'phone_2' => 'string|max:50|nullable', 31 | 'phone_3' => 'string|max:50|nullable', 32 | 'email' => 'string|max:255|nullable', 33 | 'email_2' => 'string|max:255|nullable', 34 | 'comment' => 'string|max:500|nullable', 35 | 'active' => 'boolean' 36 | ]; 37 | 38 | public function company() 39 | { 40 | return $this->belongsTo(Company::class); 41 | } 42 | 43 | public function person() 44 | { 45 | return $this->belongsTo(Person::class); 46 | } 47 | 48 | public function positionTasks() 49 | { 50 | return $this->hasMany(PositionTask::class); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090001_create_people_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('firstname'); 19 | $table->string('lastname'); 20 | $table->string('distinction')->nullable(); 21 | $table->unique(['firstname', 'lastname', 'distinction']); 22 | $table->integer('sex_id')->unsigned()->default(1); 23 | $table->foreign('sex_id')->references('id')->on('sexes'); 24 | $table->integer('language_id')->unsigned()->default(1); 25 | $table->foreign('language_id')->references('id')->on('languages'); 26 | $table->string('email')->nullable(); 27 | $table->string('phone')->nullable(); 28 | $table->boolean('active')->default(true); 29 | $table->timestamps(); 30 | }); 31 | } 32 | 33 | /** 34 | * Reverse the migrations. 35 | * 36 | * @return void 37 | */ 38 | public function down() 39 | { 40 | Schema::dropIfExists('people'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /templates/crm/database/migrations/2017_12_27_090002_create_positions_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('person_id')->unsigned(); 19 | $table->foreign('person_id')->references('id')->on('people'); 20 | $table->integer('company_id')->unsigned(); 21 | $table->foreign('company_id')->references('id')->on('companies'); 22 | $table->string('name', 255)->nullable(); 23 | $table->string('phone', 50)->nullable(); 24 | $table->string('phone_2', 50)->nullable(); 25 | $table->string('phone_3', 50)->nullable(); 26 | $table->string('email', 255)->nullable(); 27 | $table->string('email_2', 255)->nullable(); 28 | $table->string('comment', 500)->nullable(); 29 | $table->boolean('active')->default(true); 30 | $table->timestamps(); 31 | }); 32 | } 33 | 34 | /** 35 | * Reverse the migrations. 36 | * 37 | * @return void 38 | */ 39 | public function down() 40 | { 41 | Schema::dropIfExists('positions'); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /templates/crm/app/Models/Crm/Person.php: -------------------------------------------------------------------------------- 1 | lastname." ".$this->firstname; 28 | } 29 | 30 | public static $validator = [ 31 | 'firstname' => 'required|string', 32 | 'lastname' => 'required|string', 33 | 'distinction' => 'string|nullable', 34 | 'sex_id' => 'required|exists:sexes,id', 35 | 'language_id' => 'required|exists:languages,id', 36 | 'email' => 'string|nullable', 37 | 'phone' => 'string|nullable', 38 | 'active' => 'boolean' 39 | ]; 40 | 41 | public function positions() 42 | { 43 | return $this->hasMany(Position::class); 44 | } 45 | 46 | public function language() 47 | { 48 | return $this->belongsTo(Language::class); 49 | } 50 | public function sex() 51 | { 52 | return $this->belongsTo(Sex::class); 53 | } 54 | public function comments() 55 | { 56 | return $this->hasMany(PersonComment::class)->orderBy('id', 'desc'); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Store/ProductsController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index']]); 15 | $this->middleware('role:insert', ['only' => ['store']]); 16 | } 17 | 18 | private $m = Product::class; 19 | private $pk = 'id'; 20 | 21 | public function index() 22 | { 23 | return Product 24 | ::with('section') 25 | ->orderBy('name', 'asc') 26 | ->get(); 27 | } 28 | public function store(Request $request) 29 | { 30 | $initSlug = $request->get('name'); 31 | if ($request->has('slug')) { 32 | $initSlug = $request->get('slug'); 33 | } 34 | $computed = [ 35 | 'slug' => Functions::slugify($initSlug), 36 | ]; 37 | return $this->rStore($this->m, $request, $this->pk, $computed); 38 | } 39 | public function update(Request $request, $id) 40 | { 41 | $model = Product::find($id); 42 | $initSlug = $request->get('name'); 43 | if ($request->has('slug')) { 44 | $initSlug = $request->get('slug'); 45 | } 46 | $computed = [ 47 | 'slug' => Functions::slugify($initSlug) 48 | ]; 49 | return $this->rUpdate($this->m, $model, $request->all(), $this->pk, $computed); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Crm/PersonCommentsController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index', 'show']]); 15 | $this->middleware('role:insert', ['only' => ['store']]); 16 | $this->middleware('role:update', ['only' => ['update', 'multipleUpdate']]); 17 | $this->middleware('role:delete', ['only' => ['destroy']]); 18 | } 19 | 20 | private $m = PersonComment::class; 21 | private $pk = 'id'; 22 | 23 | public function index() 24 | { 25 | return PersonComment 26 | ::orderBy('id', 'desc') 27 | ->with('person') 28 | ->with('user') 29 | ->with('personCommentType') 30 | ->get(); 31 | } 32 | public function store(Request $request) 33 | { 34 | $userId = Auth::user()->id; 35 | $computed = [ 36 | 'user_id' => $userId 37 | ]; 38 | return $this->rStore($this->m, $request, $this->pk, $computed); 39 | } 40 | public function show(PersonComment $model) 41 | { 42 | return $model; 43 | } 44 | public function update(Request $request, PersonComment $model) 45 | { 46 | $userId = Auth::user()->id; 47 | $computed = [ 48 | 'user_id' => $userId 49 | ]; 50 | return $this->rUpdate($this->m, $model, $request->all(), $this->pk, $computed); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": ["framework", "laravel"], 5 | "license": "MIT", 6 | "type": "project", 7 | "require": { 8 | "php": ">=5.6.4", 9 | "barryvdh/laravel-cors": "^0.9.2", 10 | "barryvdh/laravel-debugbar": "^2.4", 11 | "doctrine/dbal": "^2.6", 12 | "laravel/framework": "5.4.*", 13 | "laravel/tinker": "~1.0", 14 | "tymon/jwt-auth": "^0.5.12" 15 | }, 16 | "require-dev": { 17 | "fzaninotto/faker": "~1.4", 18 | "mockery/mockery": "0.9.*", 19 | "phpunit/phpunit": "~5.7" 20 | }, 21 | "autoload": { 22 | "classmap": [ 23 | "database" 24 | ], 25 | "psr-4": { 26 | "App\\": "app/" 27 | } 28 | }, 29 | "autoload-dev": { 30 | "psr-4": { 31 | "Tests\\": "tests/" 32 | } 33 | }, 34 | "scripts": { 35 | "post-root-package-install": [ 36 | "php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 37 | ], 38 | "post-create-project-cmd": [ 39 | "php artisan key:generate" 40 | ], 41 | "post-install-cmd": [ 42 | "Illuminate\\Foundation\\ComposerScripts::postInstall", 43 | "php artisan optimize" 44 | ], 45 | "post-update-cmd": [ 46 | "Illuminate\\Foundation\\ComposerScripts::postUpdate", 47 | "php artisan optimize" 48 | ] 49 | }, 50 | "config": { 51 | "preferred-install": "dist", 52 | "sort-packages": true, 53 | "optimize-autoloader": true 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Crm/PersonCommentTypesController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index', 'show']]); 14 | $this->middleware('role:insert', ['only' => ['store']]); 15 | $this->middleware('role:update', ['only' => ['update', 'multipleUpdate']]); 16 | $this->middleware('role:delete', ['only' => ['destroy']]); 17 | } 18 | 19 | private $m = PersonCommentType::class; 20 | private $pk = 'id'; 21 | 22 | public function index() 23 | { 24 | return PersonCommentType::orderBy('name', 'asc')->get(); 25 | } 26 | public function store(Request $request) 27 | { 28 | return $this->rStore($this->m, $request, $this->pk); 29 | } 30 | public function show(PersonCommentType $model) 31 | { 32 | return $model; 33 | } 34 | public function update(Request $request, PersonCommentType $model) 35 | { 36 | return $this->rUpdate($this->m, $model, $request->all(), $this->pk); 37 | } 38 | public function destroy(PersonCommentType $model) 39 | { 40 | return $this->rDestroy($model); 41 | } 42 | public function multipleUpdate(Request $request) 43 | { 44 | return $this->rMultipleUpdate($this->m, $request, $this->pk); 45 | } 46 | public function multipleDelete(Request $request) 47 | { 48 | return $this->rMultipleDelete($this->m, $request, $this->pk); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Crm/CompanyCommentsController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index', 'show']]); 15 | $this->middleware('role:insert', ['only' => ['store']]); 16 | $this->middleware('role:update', ['only' => ['update', 'multipleUpdate']]); 17 | $this->middleware('role:delete', ['only' => ['destroy']]); 18 | } 19 | 20 | private $m = CompanyComment::class; 21 | private $pk = 'id'; 22 | 23 | public function index() 24 | { 25 | return CompanyComment 26 | ::orderBy('id', 'desc') 27 | ->with('company') 28 | ->with('user') 29 | ->with('companyCommentType') 30 | ->get(); 31 | } 32 | public function store(Request $request) 33 | { 34 | $userId = Auth::user()->id; 35 | $computed = [ 36 | 'user_id' => $userId 37 | ]; 38 | return $this->rStore($this->m, $request, $this->pk, $computed); 39 | } 40 | public function show($id) 41 | { 42 | return CompanyComment::find($id); 43 | } 44 | public function update(Request $request, $id) 45 | { 46 | $model = CompanyComment::find($id); 47 | $userId = Auth::user()->id; 48 | $computed = [ 49 | 'user_id' => $userId 50 | ]; 51 | return $this->rUpdate($this->m, $model, $request->all(), $this->pk, $computed); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Crm/CompaniesController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index', 'show']]); 14 | $this->middleware('role:insert', ['only' => ['store']]); 15 | $this->middleware('role:update', ['only' => ['update', 'multipleUpdate']]); 16 | $this->middleware('role:delete', ['only' => ['destroy']]); 17 | } 18 | 19 | private $m = Company::class; 20 | private $pk = 'id'; 21 | 22 | public function index() 23 | { 24 | return Company 25 | ::with('companyType') 26 | ->with('streetPrefix') 27 | ->orderBy('common_name', 'asc') 28 | ->get(); 29 | } 30 | public function show($id) 31 | { 32 | $companyInfo = Company 33 | ::where('id', $id) 34 | ->with('companyType') 35 | ->with('streetPrefix') 36 | ->with('files') 37 | ->with('positions', 'positions.person') 38 | ->with('positions.company') 39 | ->with( 40 | 'comments.companyCommentType', 41 | 'comments.user' 42 | ) 43 | ->with( 44 | ['comments' => function ($query) { 45 | $query->orderBy('created_at', 'desc'); 46 | }], 47 | 'comments.companyCommentType', 48 | 'comments.user' 49 | ) 50 | ->first(); 51 | return $companyInfo; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /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 | // 40 | ], 41 | ], 42 | 43 | 'redis' => [ 44 | 'driver' => 'redis', 45 | 'connection' => 'default', 46 | ], 47 | 48 | 'log' => [ 49 | 'driver' => 'log', 50 | ], 51 | 52 | 'null' => [ 53 | 'driver' => 'null', 54 | ], 55 | 56 | ], 57 | 58 | ]; 59 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/assets/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | 2 | window._ = require('lodash'); 3 | 4 | /** 5 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support 6 | * for JavaScript based Bootstrap features such as modals and tabs. This 7 | * code may be modified to fit the specific needs of your application. 8 | */ 9 | 10 | try { 11 | window.$ = window.jQuery = require('jquery'); 12 | 13 | require('bootstrap-sass'); 14 | } catch (e) {} 15 | 16 | /** 17 | * We'll load the axios HTTP library which allows us to easily issue requests 18 | * to our Laravel back-end. This library automatically handles sending the 19 | * CSRF token as a header based on the value of the "XSRF" token cookie. 20 | */ 21 | 22 | window.axios = require('axios'); 23 | 24 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 25 | 26 | /** 27 | * Next we will register the CSRF Token as a common header with Axios so that 28 | * all outgoing HTTP requests automatically have it attached. This is just 29 | * a simple convenience so we don't have to attach every token manually. 30 | */ 31 | 32 | let token = document.head.querySelector('meta[name="csrf-token"]'); 33 | 34 | if (token) { 35 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 36 | } else { 37 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 38 | } 39 | 40 | /** 41 | * Echo exposes an expressive API for subscribing to channels and listening 42 | * for events that are broadcast by Laravel. Echo and event broadcasting 43 | * allows your team to easily build robust real-time web applications. 44 | */ 45 | 46 | // import Echo from 'laravel-echo' 47 | 48 | // window.Pusher = require('pusher-js'); 49 | 50 | // window.Echo = new Echo({ 51 | // broadcaster: 'pusher', 52 | // key: 'your-pusher-key' 53 | // }); 54 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 32 | 33 | $status = $kernel->handle( 34 | $input = new Symfony\Component\Console\Input\ArgvInput, 35 | new Symfony\Component\Console\Output\ConsoleOutput 36 | ); 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Shutdown The Application 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Once Artisan has finished running, we will fire off the shutdown events 44 | | so that any final work may be done by the application before we shut 45 | | down the process. This is the last thing to happen to the request. 46 | | 47 | */ 48 | 49 | $kernel->terminate($input, $status); 50 | 51 | exit($status); 52 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Admin/UsersController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index', 'show', 'userPermissions']]); 16 | $this->middleware('role:insert', ['only' => ['store']]); 17 | } 18 | 19 | private $m = User::class; 20 | private $pk = 'id'; 21 | 22 | public function index() 23 | { 24 | return User::with('userType')->orderBy('id', 'asc')->get(); 25 | } 26 | public function store(Request $request) 27 | { 28 | $password = str_random(8); 29 | 30 | $computed = [ 31 | 'password' => bcrypt($password) 32 | ]; 33 | return $this->rStore($this->m, $request, $this->pk, $computed); 34 | } 35 | public function resetPassword(Request $request, $id) 36 | { 37 | $user = User::find($id); 38 | $password = str_random(8); 39 | 40 | $data = [ 41 | 'initial_password' => $password, 42 | 'password' => bcrypt($password) 43 | ]; 44 | $user->update($data); 45 | return ['status' => 0, 'id' => $user->id]; 46 | } 47 | public function userPermissions(Request $request, $id) 48 | { 49 | $userPermissions = Permission 50 | ::orderBy('id', 'asc') 51 | ->with( 52 | [ 53 | 'permissionUsers' => function($query) use($id) { 54 | $query->where('user_id', $id); 55 | }, 56 | ] 57 | ) 58 | ->get(); 59 | return $userPermissions; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Admin/UsersController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index', 'show', 'userPermissions']]); 16 | $this->middleware('role:insert', ['only' => ['store']]); 17 | } 18 | 19 | private $m = User::class; 20 | private $pk = 'id'; 21 | 22 | public function index() 23 | { 24 | return User::with('userType')->orderBy('id', 'asc')->get(); 25 | } 26 | public function store(Request $request) 27 | { 28 | $password = str_random(8); 29 | 30 | $computed = [ 31 | 'password' => bcrypt($password) 32 | ]; 33 | return $this->rStore($this->m, $request, $this->pk, $computed); 34 | } 35 | public function resetPassword(Request $request, $id) 36 | { 37 | $user = User::find($id); 38 | $password = str_random(8); 39 | 40 | $data = [ 41 | 'initial_password' => $password, 42 | 'password' => bcrypt($password) 43 | ]; 44 | $user->update($data); 45 | return ['status' => 0, 'id' => $user->id]; 46 | } 47 | public function userPermissions(Request $request, $id) 48 | { 49 | $userPermissions = Permission 50 | ::orderBy('id', 'asc') 51 | ->with( 52 | [ 53 | 'permissionUsers' => function($query) use($id) { 54 | $query->where('user_id', $id); 55 | }, 56 | ] 57 | ) 58 | ->get(); 59 | return $userPermissions; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | /* 11 | |-------------------------------------------------------------------------- 12 | | Register The Auto Loader 13 | |-------------------------------------------------------------------------- 14 | | 15 | | Composer provides a convenient, automatically generated class loader for 16 | | our application. We just need to utilize it! We'll simply require it 17 | | into the script here so that we don't have to worry about manual 18 | | loading any of our classes later on. It feels great to relax. 19 | | 20 | */ 21 | 22 | require __DIR__.'/../bootstrap/autoload.php'; 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Turn On The Lights 27 | |-------------------------------------------------------------------------- 28 | | 29 | | We need to illuminate PHP development, so let us turn on the lights. 30 | | This bootstraps the framework and gets it ready for use, then it 31 | | will load up this application so that we can run it and send 32 | | the responses back to the browser and delight our users. 33 | | 34 | */ 35 | 36 | $app = require_once __DIR__.'/../bootstrap/app.php'; 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Run The Application 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Once we have the application, we can handle the incoming request 44 | | through the kernel, and send the associated response back to 45 | | the client's browser allowing them to enjoy the creative 46 | | and wonderful application we have prepared for them. 47 | | 48 | */ 49 | 50 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 51 | 52 | $response = $kernel->handle( 53 | $request = Illuminate\Http\Request::capture() 54 | ); 55 | 56 | $response->send(); 57 | 58 | $kernel->terminate($request, $response); 59 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 60 | return response()->json(['error' => 'Unauthenticated.'], 401); 61 | } 62 | 63 | return redirect()->guest(route('login')); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 40 | } 41 | 42 | /** 43 | * Get a validator for an incoming registration request. 44 | * 45 | * @param array $data 46 | * @return \Illuminate\Contracts\Validation\Validator 47 | */ 48 | protected function validator(array $data) 49 | { 50 | return Validator::make($data, [ 51 | 'name' => 'required|string|max:255', 52 | 'email' => 'required|string|email|max:255|unique:users', 53 | 'password' => 'required|string|min:6|confirmed', 54 | ]); 55 | } 56 | 57 | /** 58 | * Create a new user instance after a valid registration. 59 | * 60 | * @param array $data 61 | * @return User 62 | */ 63 | protected function create(array $data) 64 | { 65 | return User::create([ 66 | 'name' => $data['name'], 67 | 'email' => $data['email'], 68 | 'password' => bcrypt($data['password']), 69 | ]); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 40 | } 41 | 42 | /** 43 | * Get a validator for an incoming registration request. 44 | * 45 | * @param array $data 46 | * @return \Illuminate\Contracts\Validation\Validator 47 | */ 48 | protected function validator(array $data) 49 | { 50 | return Validator::make($data, [ 51 | 'name' => 'required|string|max:255', 52 | 'email' => 'required|string|email|max:255|unique:users', 53 | 'password' => 'required|string|min:6|confirmed', 54 | ]); 55 | } 56 | 57 | /** 58 | * Create a new user instance after a valid registration. 59 | * 60 | * @param array $data 61 | * @return User 62 | */ 63 | protected function create(array $data) 64 | { 65 | return User::create([ 66 | 'name' => $data['name'], 67 | 'email' => $data['email'], 68 | 'password' => bcrypt($data['password']), 69 | ]); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/Console/Commands/LoadTemplate.php: -------------------------------------------------------------------------------- 1 | 'routes/api.php', 25 | 'type' => 'file' 26 | ], 27 | [ 28 | 'path' => 'database', 29 | 'type' => 'dir' 30 | ], 31 | [ 32 | 'path' => 'app/Models', 33 | 'type' => 'dir' 34 | ], 35 | [ 36 | 'path' => 'app/Http/Controllers', 37 | 'type' => 'dir' 38 | ], 39 | [ 40 | 'path' => 'app/Resources', 41 | 'type' => 'dir' 42 | ], 43 | ]; 44 | 45 | public function __construct() 46 | { 47 | parent::__construct(); 48 | } 49 | 50 | public function handle() 51 | { 52 | $template = $this->choice('Select template:', $this->templates); 53 | $this->line('"'.$template.'" template selected. Please wait...'); 54 | try { 55 | foreach ($this->resources as $resource) { 56 | if($resource['type'] === 'file'){ 57 | File::delete(base_path($resource['path'])); 58 | File::copy(base_path('templates/'.$template.'/'.$resource['path']), base_path($resource['path'])); 59 | } else if ($resource['type'] === 'dir') { 60 | File::deleteDirectory(base_path($resource['path'])); 61 | File::copyDirectory(base_path('templates/'.$template.'/'.$resource['path']), base_path($resource['path'])); 62 | } 63 | } 64 | $this->info('Template has been loaded'); 65 | } catch (Exception $e) { 66 | $this->error('Error! Template loading failed'); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /templates/sandbox/app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 40 | } 41 | 42 | /** 43 | * Get a validator for an incoming registration request. 44 | * 45 | * @param array $data 46 | * @return \Illuminate\Contracts\Validation\Validator 47 | */ 48 | protected function validator(array $data) 49 | { 50 | return Validator::make($data, [ 51 | 'name' => 'required|string|max:255', 52 | 'email' => 'required|string|email|max:255|unique:users', 53 | 'password' => 'required|string|min:6|confirmed', 54 | ]); 55 | } 56 | 57 | /** 58 | * Create a new user instance after a valid registration. 59 | * 60 | * @param array $data 61 | * @return User 62 | */ 63 | protected function create(array $data) 64 | { 65 | return User::create([ 66 | 'name' => $data['name'], 67 | 'email' => $data['email'], 68 | 'password' => bcrypt($data['password']), 69 | ]); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /templates/sandbox/database/seeds/InitSeeder.php: -------------------------------------------------------------------------------- 1 | name = 'admin'; 12 | $user->email = 'admin@admin.com'; 13 | $user->password = bcrypt('1234'); 14 | $user->save(); 15 | 16 | DB::table('permissions') 17 | ->insert([ 18 | [ 19 | 'name' => 'CRM', 20 | 'code' => 'CRM', 21 | ], 22 | [ 23 | 'name' => 'administracja', 24 | 'code' => 'ADMIN', 25 | ] 26 | ]); 27 | 28 | DB::table('user_permissions') 29 | ->insert([ 30 | ['user_id' => 1,'permission_id' => 1], 31 | ['user_id' => 1,'permission_id' => 2] 32 | ]); 33 | 34 | DB::table('company_types') 35 | ->insert([ 36 | ['name' => 'Media','code' => 'MED'], 37 | ['name' => 'Firmy IT','code' => 'FIT'], 38 | ['name' => 'Sklepy','code' => 'SKL'], 39 | ['name' => 'Organizacje','code' => 'ORG'], 40 | ]); 41 | 42 | DB::table('sexes') 43 | ->insert([ 44 | ['name' => '-','code' => '-', 'eng_name' => '-', 'eng_code' => '-', 'priority' => '1'], 45 | ['name' => 'Kobieta','code' => 'K', 'eng_name' => 'Female', 'eng_code' => 'F', 'priority' => '2'], 46 | ['name' => 'Mężczyzna','code' => 'M', 'eng_name' => 'Male', 'eng_code' => 'M', 'priority' => '3'], 47 | ]); 48 | 49 | DB::table('street_prefixes') 50 | ->insert([ 51 | ['name' => '','description' => '-'], 52 | ['name' => 'ul.','description' => 'Ulica'], 53 | ['name' => 'al.','description' => 'Aleja'], 54 | ['name' => 'pl.','description' => 'Plac'], 55 | ['name' => 'os.','description' => 'Osiedle'], 56 | ]); 57 | 58 | DB::table('languages') 59 | ->insert([ 60 | ['name' => 'Polski','priority' => 1], 61 | ['name' => 'Angielski','priority' => 2], 62 | ]); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /templates/cms/app/Http/Controllers/Blog/PostsController.php: -------------------------------------------------------------------------------- 1 | middleware('role:read', ['only' => ['index']]); 17 | $this->middleware('role:insert', ['only' => ['store']]); 18 | } 19 | 20 | private $m = Post::class; 21 | private $pk = 'id'; 22 | 23 | public function index() 24 | { 25 | return Post 26 | ::with('postTags.tag') 27 | ->with('category') 28 | ->with('user') 29 | ->orderBy('id', 'desc') 30 | ->get(); 31 | } 32 | public function store(Request $request) 33 | { 34 | $userId = Auth::user()->id; 35 | $initSlug = $request->get('title'); 36 | if ($request->has('slug')) { 37 | $initSlug = $request->get('slug'); 38 | } 39 | $computed = [ 40 | 'slug' => Functions::slugify($initSlug), 41 | 'user_id' => $userId 42 | ]; 43 | return $this->rStore($this->m, $request, $this->pk, $computed); 44 | } 45 | public function update(Request $request, $id) 46 | { 47 | $model = Post::find($id); 48 | $initSlug = $request->get('title'); 49 | if ($request->has('slug')) { 50 | $initSlug = $request->get('slug'); 51 | } 52 | $computed = [ 53 | 'slug' => Functions::slugify($initSlug) 54 | ]; 55 | return $this->rUpdate($this->m, $model, $request->all(), $this->pk, $computed); 56 | } 57 | public function postTags(Request $request, $id) 58 | { 59 | $postTags = Tag 60 | ::orderBy('id', 'asc') 61 | ->with( 62 | [ 63 | 'tagPosts' => function($query) use($id) { 64 | $query->where('post_id', $id); 65 | }, 66 | ] 67 | ) 68 | ->get(); 69 | return $postTags; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /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", "s3", "rackspace" 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_KEY'), 61 | 'secret' => env('AWS_SECRET'), 62 | 'region' => env('AWS_REGION'), 63 | 'bucket' => env('AWS_BUCKET'), 64 | ], 65 | 66 | ], 67 | 68 | ]; 69 | -------------------------------------------------------------------------------- /templates/crm/app/Http/Controllers/Files/FileController.php: -------------------------------------------------------------------------------- 1 | get('module'); 18 | $validator = Validator::make($request->all(), [ 19 | 'module' => 'required|exists:permissions,code', 20 | ]); 21 | if ($validator->fails()) { 22 | return ['status' => -2, 'msg' => $validator->errors()]; 23 | } 24 | 25 | // check user permissions to the module 26 | $userId = Auth::user()->id; 27 | $permission = UserPermission 28 | ::whereHas('permission', function ($query) use ($module) { 29 | $query->where('code', $module); 30 | }) 31 | ->where('user_id', $userId) 32 | ->first(); 33 | 34 | // user has permission to uploading files in the module 35 | if ($permission !== null) { 36 | 37 | // extension checking 38 | $file = $request->file('file'); 39 | $originalName = $file->getClientOriginalName(); 40 | $whitelist = array('jpg', 'png', 'gif', 'jpeg', 'svg', 'txt', 'gif', 'doc', 'docx', 'xls', 'xlsx', 'mp3', 'mp4', 'avi', 'json', 'pdf'); 41 | $explFilename = explode('.', $originalName); 42 | $fileExtension = strtolower(end($explFilename)); 43 | if(!in_array($fileExtension, $whitelist)) 44 | { 45 | return ['status' => -1, 'msg' => $fileExtension.' is invalid file extension. Allowed extensions: '.implode(', ', $whitelist)]; 46 | } 47 | 48 | $table = $request->get('table'); 49 | $field = $request->get('field'); 50 | $uniqueFolder = time().substr("000000".$userId,-6); 51 | $relativePath = 'files/'.$module.'/'.$table.'/'.$field.'/'.$uniqueFolder; 52 | $file->storeAs('public/'.$relativePath, $originalName); 53 | return ['status' => 0, 'path' => $relativePath]; 54 | } 55 | // user hasn't permissions 56 | else { 57 | return ['status' => -1, 'msg' => 'Error']; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /templates/empty/app/Http/Controllers/Files/FileController.php: -------------------------------------------------------------------------------- 1 | get('module'); 18 | $validator = Validator::make($request->all(), [ 19 | 'module' => 'required|exists:permissions,code', 20 | ]); 21 | if ($validator->fails()) { 22 | return ['status' => -2, 'msg' => $validator->errors()]; 23 | } 24 | 25 | // check user permissions to the module 26 | $userId = Auth::user()->id; 27 | $permission = UserPermission 28 | ::whereHas('permission', function ($query) use ($module) { 29 | $query->where('code', $module); 30 | }) 31 | ->where('user_id', $userId) 32 | ->first(); 33 | 34 | // user has permission to uploading files in the module 35 | if ($permission !== null) { 36 | 37 | // extension checking 38 | $file = $request->file('file'); 39 | $originalName = $file->getClientOriginalName(); 40 | $whitelist = array('jpg', 'png', 'gif', 'jpeg', 'svg', 'txt', 'gif', 'doc', 'docx', 'xls', 'xlsx', 'mp3', 'mp4', 'avi', 'json', 'pdf'); 41 | $explFilename = explode('.', $originalName); 42 | $fileExtension = strtolower(end($explFilename)); 43 | if(!in_array($fileExtension, $whitelist)) 44 | { 45 | return ['status' => -1, 'msg' => $fileExtension.' is invalid file extension. Allowed extensions: '.implode(', ', $whitelist)]; 46 | } 47 | 48 | $table = $request->get('table'); 49 | $field = $request->get('field'); 50 | $uniqueFolder = time().substr("000000".$userId,-6); 51 | $relativePath = 'files/'.$module.'/'.$table.'/'.$field.'/'.$uniqueFolder; 52 | $file->storeAs('public/'.$relativePath, $originalName); 53 | return ['status' => 0, 'path' => $relativePath]; 54 | } 55 | // user hasn't permissions 56 | else { 57 | return ['status' => -1, 'msg' => 'Error']; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /templates/sandbox/app/Http/Controllers/Files/FileController.php: -------------------------------------------------------------------------------- 1 | get('module'); 18 | $validator = Validator::make($request->all(), [ 19 | 'module' => 'required|exists:permissions,code', 20 | ]); 21 | if ($validator->fails()) { 22 | return ['status' => -2, 'msg' => $validator->errors()]; 23 | } 24 | 25 | // check user permissions to the module 26 | $userId = Auth::user()->id; 27 | $permission = UserPermission 28 | ::whereHas('permission', function ($query) use ($module) { 29 | $query->where('code', $module); 30 | }) 31 | ->where('user_id', $userId) 32 | ->first(); 33 | 34 | // user has permission to uploading files in the module 35 | if ($permission !== null) { 36 | 37 | // extension checking 38 | $file = $request->file('file'); 39 | $originalName = $file->getClientOriginalName(); 40 | $whitelist = array('jpg', 'png', 'gif', 'jpeg', 'svg', 'txt', 'gif', 'doc', 'docx', 'xls', 'xlsx', 'mp3', 'mp4', 'avi', 'json', 'pdf'); 41 | $explFilename = explode('.', $originalName); 42 | $fileExtension = strtolower(end($explFilename)); 43 | if(!in_array($fileExtension, $whitelist)) 44 | { 45 | return ['status' => -1, 'msg' => $fileExtension.' is invalid file extension. Allowed extensions: '.implode(', ', $whitelist)]; 46 | } 47 | 48 | $table = $request->get('table'); 49 | $field = $request->get('field'); 50 | $uniqueFolder = time().substr("000000".$userId,-6); 51 | $relativePath = 'files/'.$module.'/'.$table.'/'.$field.'/'.$uniqueFolder; 52 | $file->storeAs('public/'.$relativePath, $originalName); 53 | return ['status' => 0, 'path' => $relativePath]; 54 | } 55 | // user hasn't permissions 56 | else { 57 | return ['status' => -1, 'msg' => 'Error']; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /templates/simple-crud/app/Http/Controllers/Files/FileController.php: -------------------------------------------------------------------------------- 1 | get('module'); 18 | $validator = Validator::make($request->all(), [ 19 | 'module' => 'required|exists:permissions,code', 20 | ]); 21 | if ($validator->fails()) { 22 | return ['status' => -2, 'msg' => $validator->errors()]; 23 | } 24 | 25 | // check user permissions to the module 26 | $userId = Auth::user()->id; 27 | $permission = UserPermission 28 | ::whereHas('permission', function ($query) use ($module) { 29 | $query->where('code', $module); 30 | }) 31 | ->where('user_id', $userId) 32 | ->first(); 33 | 34 | // user has permission to uploading files in the module 35 | if ($permission !== null) { 36 | 37 | // extension checking 38 | $file = $request->file('file'); 39 | $originalName = $file->getClientOriginalName(); 40 | $whitelist = array('jpg', 'png', 'gif', 'jpeg', 'svg', 'txt', 'gif', 'doc', 'docx', 'xls', 'xlsx', 'mp3', 'mp4', 'avi', 'json', 'pdf'); 41 | $explFilename = explode('.', $originalName); 42 | $fileExtension = strtolower(end($explFilename)); 43 | if(!in_array($fileExtension, $whitelist)) 44 | { 45 | return ['status' => -1, 'msg' => $fileExtension.' is invalid file extension. Allowed extensions: '.implode(', ', $whitelist)]; 46 | } 47 | 48 | $table = $request->get('table'); 49 | $field = $request->get('field'); 50 | $uniqueFolder = time().substr("000000".$userId,-6); 51 | $relativePath = 'files/'.$module.'/'.$table.'/'.$field.'/'.$uniqueFolder; 52 | $file->storeAs('public/'.$relativePath, $originalName); 53 | return ['status' => 0, 'path' => $relativePath]; 54 | } 55 | // user hasn't permissions 56 | else { 57 | return ['status' => -1, 'msg' => 'Error']; 58 | } 59 | } 60 | } 61 | --------------------------------------------------------------------------------