├── .dockerignore ├── .env.local ├── .gitattributes ├── .gitignore ├── .htaccess ├── Dockerfile ├── Jenkinsfile ├── ansible ├── .gitignore ├── Vagrantfile ├── hosts-dev ├── hosts-prod ├── playbook.retry ├── playbook.yml ├── requirements.yml ├── roles │ └── deployment │ │ ├── defaults │ │ └── main.yml │ │ ├── tasks │ │ ├── deploy.yml │ │ ├── main.yml │ │ ├── migration.yml │ │ ├── seeding.yml │ │ └── undeploy.yml │ │ └── templates │ │ └── docker-compose.yml.j2 ├── vagrant │ ├── id_rsa │ └── id_rsa.pub └── vars │ ├── dev.yml │ └── prod.yml ├── app ├── Book.php ├── Category.php ├── Comment.php ├── Console │ ├── Commands │ │ └── Inspire.php │ └── Kernel.php ├── Events │ └── Event.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── AccessorController.php │ │ ├── Auth │ │ │ ├── AuthController.php │ │ │ └── PasswordController.php │ │ ├── BlogController.php │ │ ├── CategoryController.php │ │ ├── CommentsController.php │ │ ├── Controller.php │ │ ├── PagesController.php │ │ ├── PostController.php │ │ └── TagController.php │ ├── Kernel.php │ ├── Middleware │ │ ├── Authenticate.php │ │ ├── EncryptCookies.php │ │ ├── RedirectIfAuthenticated.php │ │ └── VerifyCsrfToken.php │ ├── Requests │ │ └── Request.php │ └── routes.php ├── Jobs │ └── Job.php ├── Listeners │ └── .gitkeep ├── Policies │ └── .gitkeep ├── Post.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ ├── OpenCensusProvider.php │ └── RouteServiceProvider.php ├── Tag.php └── User.php ├── artisan ├── bootstrap ├── app.php ├── autoload.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── compile.php ├── database.php ├── filesystems.php ├── mail.php ├── purifier.php ├── queue.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ └── ModelFactory.php ├── migrations │ ├── .gitkeep │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2016_02_06_175142_create_posts_table.php │ ├── 2016_03_20_162017_add_slug_to_users.php │ ├── 2016_04_28_021908_create_categories_table.php │ ├── 2016_04_28_022255_add_category_id_to_posts.php │ ├── 2016_05_30_153615_create_tags_table.php │ ├── 2016_05_30_155417_create_post_tag_table.php │ ├── 2016_07_16_173641_create_comments_table.php │ ├── 2016_08_15_000718_add_image_col_to_posts.php │ └── 2019_06_28_133124_create_books_table.php └── seeds │ ├── .gitkeep │ ├── BookTableSeeder.php │ ├── CategoryTableSeeder.php │ ├── DatabaseSeeder.php │ ├── PostsTableSeeder.php │ └── UsersTableSeeder.php ├── docker-compose.local.yml ├── docker-compose.yml ├── docker-local.sh ├── docker ├── mysql │ └── my.cnf ├── nginx │ └── conf.d │ │ └── laravel.conf ├── opencensus │ ├── agent.yml │ └── collector.yml ├── php │ └── local.ini └── prometheus │ └── prometheus.yml ├── gulpfile.js ├── laravel_blog (1).sql ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── css │ ├── parsley.css │ ├── select2.min.css │ └── styles.css ├── favicon.ico ├── index.php ├── js │ ├── parsley.min.js │ └── select2.min.js ├── robots.txt └── web.config ├── readme.md ├── resources ├── assets │ └── sass │ │ └── app.scss ├── lang │ └── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php └── views │ ├── auth │ ├── emails │ │ └── password.blade.php │ ├── login.blade.php │ ├── passwords │ │ ├── email.blade.php │ │ └── reset.blade.php │ └── register.blade.php │ ├── blog │ ├── index.blade.php │ └── single.blade.php │ ├── categories │ └── index.blade.php │ ├── comments │ ├── delete.blade.php │ └── edit.blade.php │ ├── emails │ └── contact.blade.php │ ├── errors │ └── 503.blade.php │ ├── main.blade.php │ ├── pages │ ├── about.blade.php │ ├── contact.blade.php │ └── welcome.blade.php │ ├── partials │ ├── _footer.blade.php │ ├── _head.blade.php │ ├── _javascript.blade.php │ ├── _messages.blade.php │ └── _nav.blade.php │ ├── posts │ ├── create.blade.php │ ├── edit.blade.php │ ├── index.blade.php │ └── show.blade.php │ ├── tags │ ├── edit.blade.php │ ├── index.blade.php │ └── show.blade.php │ └── vendor │ └── .gitkeep ├── server.php ├── sonar-project.properties ├── storage ├── app │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore └── tests ├── AccessorTest.php ├── BasicTest.php ├── BookTest.php ├── TestCase.php └── UserTest.php /.dockerignore: -------------------------------------------------------------------------------- 1 | docker-data 2 | *.tar 3 | ansible 4 | sonar-project.properties 5 | .git 6 | docker-compose.yml 7 | .env 8 | vendor -------------------------------------------------------------------------------- /.env.local: -------------------------------------------------------------------------------- 1 | APP_ENV=testlaravel 2 | APP_DEBUG=true 3 | APP_KEY=base64:oPD/hrRXGvA1hydZp17JAQH2PnflMgp4P5OMWoldWTM= 4 | 5 | DB_HOST=db 6 | DB_DATABASE=laravel 7 | DB_USERNAME=root 8 | DB_PASSWORD=your_mysql_root_password 9 | 10 | CACHE_DRIVER=file 11 | SESSION_DRIVER=file 12 | QUEUE_DRIVER=sync 13 | 14 | REDIS_HOST=localhost 15 | REDIS_PASSWORD=null 16 | REDIS_PORT=6379 17 | 18 | MAIL_DRIVER=smtp 19 | MAIL_HOST=mailtrap.io 20 | MAIL_PORT=2525 21 | MAIL_USERNAME=null 22 | MAIL_PASSWORD=null 23 | MAIL_ENCRYPTION=null 24 | 25 | JAEGER_HOST: jaeger 26 | JAEGER_PORT: 6831 27 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.less linguist-vendored 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /node_modules 3 | Homestead.yaml 4 | Homestead.json 5 | .env 6 | public/images 7 | .DS_Store 8 | docker-data -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | Options +FollowSymLinks 2 | RewriteEngine On 3 | RewriteBase /laravel_blog/ 4 | RewriteCond %{REQUEST_FILENAME} !-d 5 | RewriteCond %{REQUEST_FILENAME} !-f 6 | RewriteRule ^ /public/index.php [L] -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.2-fpm 2 | 3 | # Set working directory 4 | WORKDIR /var/www 5 | 6 | # Install dependencies 7 | RUN apt-get update && apt-get install -y \ 8 | build-essential \ 9 | mysql-client \ 10 | libpng-dev \ 11 | libjpeg62-turbo-dev \ 12 | libfreetype6-dev \ 13 | locales \ 14 | zip \ 15 | jpegoptim optipng pngquant gifsicle \ 16 | vim \ 17 | unzip \ 18 | git \ 19 | curl \ 20 | libgmp-dev 21 | 22 | # Clear cache 23 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 24 | 25 | ## Opencensus 26 | RUN pecl install opencensus-alpha 27 | 28 | RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/ 29 | 30 | # Install extensions 31 | RUN docker-php-ext-install pdo_mysql \ 32 | mbstring \ 33 | zip \ 34 | exif \ 35 | pcntl \ 36 | gd \ 37 | sockets \ 38 | gmp 39 | 40 | # Install composer 41 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 42 | 43 | # Add user for laravel application 44 | RUN groupadd -g 1000 www 45 | RUN useradd -u 1000 -ms /bin/bash -g www www 46 | 47 | # Copy composer.lock and composer.json 48 | COPY composer.lock composer.json /var/www/ 49 | 50 | RUN composer install --prefer-source --no-dev --no-autoloader --no-scripts --no-progress --no-suggest 51 | 52 | # Copy existing application directory contents 53 | COPY . /var/www 54 | 55 | RUN composer install --prefer-dist --no-dev -o 56 | 57 | # Copy existing application directory permissions 58 | COPY --chown=www:www . /var/www 59 | 60 | ADD ./docker/php/local.ini /usr/local/etc/php/conf.d 61 | 62 | # Change current user to www 63 | USER www 64 | 65 | # Expose port 9000 and start php-fpm server 66 | EXPOSE 9000 67 | CMD ["php-fpm"] -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | def getdockertag(){ 2 | return "${env.GIT_BRANCH}".replace("/",".") + "."+"${env.BUILD_ID}" 3 | } 4 | pipeline { 5 | agent any 6 | environment { 7 | DOCKER_REGISTRY = "varunpalekar1/php-test" 8 | DOCKER_TAG = getdockertag() 9 | } 10 | stages { 11 | stage('Build') { 12 | steps { 13 | script { 14 | echo "install compose.json" 15 | sh 'composer install --prefer-source' 16 | sh 'printenv' 17 | dir('ansible') { 18 | sh 'ansible-galaxy install -r requirements.yml' 19 | } 20 | } 21 | } 22 | } 23 | stage('UnitTest') { 24 | environment { 25 | DB_HOST = "localhost" 26 | DB_DATABASE = "laravel_test" 27 | DB_USERNAME = "laravel_test" 28 | DB_PASSWORD = "my_pass" 29 | } 30 | steps { 31 | script { 32 | try{ 33 | echo "Running Test cases" 34 | sh './vendor/bin/phpunit --colors tests --log-junit reports/junit.xml' 35 | } 36 | catch(Exception e){ 37 | if ( GIT_BRANCH ==~ /.*master|.*hotfix\/.*|.*release\/.*/ ) 38 | error "Test case failed" 39 | else 40 | echo "Skipped test if from personal or feature branch" 41 | } 42 | try{ 43 | echo "Running Test code coverage" 44 | sh './vendor/bin/phpunit --coverage-clover reports/codeCoverage.xml' 45 | } 46 | catch(Exception e){ 47 | if ( GIT_BRANCH ==~ /.*master|.*hotfix\/.*|.*release\/.*/ ) 48 | error "Code coverage failed" 49 | else 50 | echo "Skipped code coverage if from personal or feature branch" 51 | } 52 | } 53 | } 54 | } 55 | stage('CodeAnalysis') { 56 | when { 57 | expression { 58 | GIT_BRANCH ==~ /.*master|.*feature\/.*|.*develop|.*hotfix\/.*|.*release\/.*/ 59 | } 60 | } 61 | steps { 62 | script { 63 | scannerHome = tool name: 'sonar-scanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation' 64 | } 65 | withSonarQubeEnv('sonarqube.io') { 66 | sh "${scannerHome}/bin/sonar-scanner -Dsonar.branch.name=${GIT_BRANCH} -Dsonar.projectKey=varunpalekar_php-test -Dsonar.organization=varunpalekar-github" 67 | } 68 | } 69 | } 70 | stage('DockerPush') { 71 | when { 72 | expression { 73 | GIT_BRANCH ==~ /.*master|.*release\/.*|.*develop|.*hotfix\/.*/ 74 | } 75 | } 76 | steps { 77 | script{ 78 | docker.withRegistry('', 'public-docker-hub') { 79 | 80 | def customImage = docker.build("${env.DOCKER_REGISTRY}:${env.DOCKER_TAG}") 81 | customImage.push() 82 | 83 | if ( GIT_BRANCH ==~ /.*master|.*hotfix\/.*|.*release\/.*/ ) 84 | customImage.push('latest') 85 | } 86 | } 87 | } 88 | } 89 | stage('Deploy_Dev') { 90 | when { 91 | expression { 92 | GIT_BRANCH ==~ /.*develop/ 93 | } 94 | } 95 | steps { 96 | script{ 97 | echo "Deploy application on developmment environment" 98 | dir("ansible") { 99 | ansiblePlaybook installation: 'ansible', inventory: 'hosts-dev', playbook: 'playbook.yml', extraVars: [ 100 | deployment_app_image: "${env.DOCKER_REGISTRY}:${env.DOCKER_TAG}" 101 | ] 102 | } 103 | } 104 | 105 | input message: "Do you want to run migration?" 106 | 107 | script{ 108 | echo "Deploy application on developmment environment" 109 | dir("ansible") { 110 | ansiblePlaybook installation: 'ansible', inventory: 'hosts-dev', playbook: 'playbook.yml', tags: 'migration' 111 | } 112 | } 113 | 114 | input message: "Do you want to run seeding?" 115 | 116 | script{ 117 | echo "Deploy application on developmment environment" 118 | dir("ansible") { 119 | ansiblePlaybook installation: 'ansible', inventory: 'hosts-dev', playbook: 'playbook.yml', tags: 'seeding' 120 | } 121 | } 122 | } 123 | } 124 | 125 | stage('Undeploy_Dev'){ 126 | when { 127 | expression { 128 | GIT_BRANCH ==~ /.*develop/ 129 | } 130 | } 131 | // timeout(time:5, unit:'DAYS') { 132 | // input message:'Approve deployment?', submitter: 'it-ops' 133 | // } 134 | steps { 135 | input message: "Do you want to undeploy DEV?" 136 | script { 137 | echo "Undeploy application on developmment environment" 138 | dir("ansible") { 139 | ansiblePlaybook installation: 'ansible', inventory: 'hosts-dev', playbook: 'playbook.yml', tags: 'undeploy' 140 | } 141 | } 142 | } 143 | } 144 | stage('Deploy_Prod') { 145 | when { 146 | expression { 147 | GIT_BRANCH ==~ /.*master|.*release\/.*|.*hotfix\/.*/ 148 | } 149 | } 150 | steps { 151 | input message: "Do you want to proceed for production deployment?" 152 | script{ 153 | echo "Deploy application on stage environment" 154 | dir("ansible") { 155 | ansiblePlaybook installation: 'ansible', inventory: 'hosts-prod', playbook: 'playbook.yml', credentialsId: 'ansible-hospice-prod' 156 | } 157 | } 158 | 159 | input message: "Do you want to proceed for production migration?" 160 | script{ 161 | echo "Deploy application on stage environment" 162 | dir("ansible") { 163 | ansiblePlaybook installation: 'ansible', inventory: 'hosts-prod', playbook: 'playbook.yml', tags: 'migration', credentialsId: 'ansible-hospice-prod' 164 | } 165 | } 166 | } 167 | } 168 | 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /ansible/.gitignore: -------------------------------------------------------------------------------- 1 | *-console.log 2 | .vagrant -------------------------------------------------------------------------------- /ansible/Vagrantfile: -------------------------------------------------------------------------------- 1 | servers=[ 2 | { 3 | :hostname => "dev", 4 | :ip => "192.168.94.41", 5 | :box => "ubuntu/bionic64", 6 | :ram => 1024, 7 | :cpu => 1 8 | }, 9 | { 10 | :hostname => "prod", 11 | :ip => "192.168.94.42", 12 | :box => "ubuntu/bionic64", 13 | :ram => 1024, 14 | :cpu => 1 15 | } 16 | ] 17 | 18 | $initialize = <<-SCRIPT 19 | cat /vagrant/vagrant/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys 20 | apt-get update && apt install -y python 21 | SCRIPT 22 | 23 | Vagrant.configure("2") do |config| 24 | 25 | if Vagrant.has_plugin?("vagrant-hostmanager") 26 | config.hostmanager.enabled = true 27 | config.hostmanager.manage_guest = true 28 | end 29 | 30 | if Vagrant.has_plugin?("vagrant-cachier") 31 | config.cache.scope = :box 32 | end 33 | 34 | config.vm.provision "shell", inline: $initialize 35 | 36 | servers.each do |machine| 37 | config.vm.define machine[:hostname] do |node| 38 | node.vm.box = machine[:box] 39 | node.vm.hostname = machine[:hostname] 40 | node.vm.network "private_network", ip: machine[:ip] 41 | node.vm.provider "virtualbox" do |vb| 42 | vb.memory = machine[:ram] 43 | vb.cpus = machine[:cpu] 44 | vb.linked_clone = true 45 | end 46 | end 47 | end 48 | end -------------------------------------------------------------------------------- /ansible/hosts-dev: -------------------------------------------------------------------------------- 1 | [hospice] 2 | 192.168.94.41 ansible_user=vagrant 3 | 4 | [all:vars] 5 | env=dev -------------------------------------------------------------------------------- /ansible/hosts-prod: -------------------------------------------------------------------------------- 1 | [hospice] 2 | 192.168.94.42 ansible_user=vagrant 3 | 4 | [all:vars] 5 | env=prod -------------------------------------------------------------------------------- /ansible/playbook.retry: -------------------------------------------------------------------------------- 1 | 192.168.94.41 2 | -------------------------------------------------------------------------------- /ansible/playbook.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: all 3 | become: yes 4 | vars_files: 5 | - "vars/{{ env }}.yml" 6 | roles: 7 | - role: mysql 8 | when: env == 'prod' 9 | - role: docker 10 | docker_install_compose: true 11 | - role: deployment 12 | -------------------------------------------------------------------------------- /ansible/requirements.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: docker 4 | src: geerlingguy.docker 5 | 6 | - name: mysql 7 | src: geerlingguy.mysql -------------------------------------------------------------------------------- /ansible/roles/deployment/defaults/main.yml: -------------------------------------------------------------------------------- 1 | deployment_project_dir: '/data/hospice/docker_compose' 2 | 3 | deployment_webserver: 4 | ports: 5 | - "80" 6 | - "443" 7 | volumes: 8 | - ./:/var/www 9 | - ./docker/nginx/conf.d/:/etc/nginx/conf.d/ 10 | 11 | deployment_app: 12 | build: 13 | context: . 14 | dockerfile: Dockerfile 15 | image: varun/laravel-php-fpm 16 | environment: 17 | APP_ENV: dev 18 | APP_DEBUG: true 19 | APP_KEY: base64:oPD/hrRXGvA1hydZp17JAQH2PnflMgp4P5OMWoldWTM= 20 | 21 | DB_HOST: db 22 | DB_DATABASE: 23 | DB_USERNAME: root 24 | DB_PASSWORD: your_mysql_root_password 25 | 26 | JAEGER_HOST: jaeger 27 | JAEGER_PORT: 6831 28 | JAEGER_ENABLE: "false" 29 | 30 | working_dir: /var/www 31 | volumes: 32 | - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini 33 | 34 | deployment_db: 35 | volumes: 36 | - ./docker-data/mysql:/var/lib/mysql 37 | - ./docker/mysql/my.cnf:/etc/mysql/my.cnf 38 | environment: 39 | MYSQL_DATABASE: laravel 40 | MYSQL_ROOT_PASSWORD: your_mysql_root_password 41 | SERVICE_TAGS: dev 42 | SERVICE_NAME: mysql -------------------------------------------------------------------------------- /ansible/roles/deployment/tasks/deploy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: create project directory {{ deployment_project_dir }} 4 | file: path={{ deployment_project_dir }} state=directory 5 | 6 | - name: push project code 7 | synchronize: 8 | src: "{{ playbook_dir }}/../{{ item }}" 9 | dest: "{{ deployment_project_dir }}" 10 | dirs: yes 11 | rsync_opts: 12 | - "--exclude=docker-data" 13 | loop: 14 | - public 15 | - docker-compose.yml 16 | - docker 17 | 18 | - name: create override docker-compose file 19 | template: 20 | src: docker-compose.yml.j2 21 | dest: "{{ deployment_project_dir }}/docker-compose.{{env}}.yml" 22 | 23 | - name: docker pull deployable image 24 | docker_image: 25 | name: "{{ deployment_app_image }}" 26 | pull: yes 27 | 28 | - name: start project 29 | docker_service: 30 | project_src: "{{ deployment_project_dir }}" 31 | build: no 32 | files: 33 | - docker-compose.yml 34 | - "docker-compose.{{env}}.yml" 35 | state: present 36 | restarted: yes 37 | register: deployment_service_out 38 | 39 | - name: get docker-port of webserver 40 | shell: docker-compose -f docker-compose.yml -f docker-compose.{{env}}.yml port webserver 80 41 | args: 42 | chdir: "{{ deployment_project_dir }}" 43 | register: deployment_webserver_port 44 | 45 | - debug: 46 | msg: "Webserver dynamic URL: http://{{ ansible_ssh_host }}:{{ deployment_webserver_port.stdout | regex_search('(?<=:).*') }}" 47 | -------------------------------------------------------------------------------- /ansible/roles/deployment/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: install required packages 4 | package: 5 | name: "{{ item }}" 6 | loop: 7 | - python-pip 8 | 9 | - name: install docker python module 10 | pip: 11 | name: "{{ item }}" 12 | loop: 13 | - docker 14 | - docker-compose 15 | 16 | - name: Deploy-application 17 | include_tasks: deploy.yml 18 | 19 | - name: Undeploy-application 20 | include_tasks: undeploy.yml 21 | tags: 22 | - never 23 | - undeploy 24 | 25 | - name: migration update 26 | include_tasks: migration.yml 27 | tags: 28 | - never 29 | - migration 30 | 31 | - name: seeding 32 | include_tasks: seeding.yml 33 | tags: 34 | - never 35 | - seeding -------------------------------------------------------------------------------- /ansible/roles/deployment/tasks/migration.yml: -------------------------------------------------------------------------------- 1 | 2 | - name: docker-compose exec migration 3 | shell: "docker-compose -f docker-compose.yml -f docker-compose.{{env}}.yml exec -T app php artisan migrate" 4 | args: 5 | chdir: "{{ deployment_project_dir }}" 6 | register: deployment_migration_output 7 | loop: 8 | - migrate 9 | - status 10 | tags: 11 | - migration 12 | 13 | - debug: 14 | msg: "{{ item.key }}: {{ item.value }}" 15 | loop: 16 | - key: "{{ deployment_migration_output.results[0].item }}" 17 | value: "{{ deployment_migration_output.results[0].stdout }}" 18 | - key: "{{deployment_migration_output.results[1].item}}" 19 | value: "{{deployment_migration_output.results[1].stdout}}" 20 | tags: 21 | - migration -------------------------------------------------------------------------------- /ansible/roles/deployment/tasks/seeding.yml: -------------------------------------------------------------------------------- 1 | - name: docker-compose exec seeding 2 | shell: "docker-compose -f docker-compose.yml -f docker-compose.{{env}}.yml exec -T app php artisan {{ item }}" 3 | args: 4 | chdir: "{{ deployment_project_dir }}" 5 | register: deployment_seeding_out 6 | loop: 7 | - db:seed --class=UsersTableSeeder 8 | - db:seed --class=PostsTableSeeder 9 | - db:seed --class=PostsTableSeeder 10 | tags: 11 | - seeding 12 | -------------------------------------------------------------------------------- /ansible/roles/deployment/tasks/undeploy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: stop docker compose 4 | docker_service: 5 | project_src: "{{ deployment_project_dir }}" 6 | files: 7 | - docker-compose.yml 8 | - "docker-compose.{{env}}.yml" 9 | state: absent 10 | tags: 11 | - undeploy 12 | 13 | - name: delete project folder 14 | file: 15 | state: absent 16 | path: "{{ deployment_project_dir }}" 17 | tags: 18 | - undeploy -------------------------------------------------------------------------------- /ansible/roles/deployment/templates/docker-compose.yml.j2: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | {% if deployment_webserver %} 5 | webserver: 6 | {% if deployment_webserver.ports is defined %} 7 | ports: 8 | {% for val in deployment_webserver.ports %} 9 | - {{ val }} 10 | {% endfor %} 11 | {% endif %} 12 | 13 | {% if deployment_webserver.volumes is defined %} 14 | volumes: 15 | {% for val in deployment_webserver.volumes %} 16 | - {{ val }} 17 | {% endfor %} 18 | {% endif %} 19 | 20 | {% if deployment_webserver.environment is defined %} 21 | environment: 22 | {% for key, val in deployment_webserver.environment.iteritems() %} 23 | {{ key }} : "{{ val }}" 24 | {% endfor %} 25 | {% endif %} 26 | {% endif %} 27 | 28 | {% if deployment_app %} 29 | # PHP-fpm server 30 | app: 31 | {% if deployment_app.ports is defined %} 32 | ports: 33 | {% for val in deployment_app.ports %} 34 | - {{ val }} 35 | {% endfor %} 36 | {% endif %} 37 | 38 | {% if deployment_app.image is defined %} 39 | image: {{ deployment_app.image }} 40 | {% endif %} 41 | 42 | {% if deployment_app.volumes is defined %} 43 | volumes: 44 | {% for val in deployment_app.volumes %} 45 | - {{ val }} 46 | {% endfor %} 47 | {% endif %} 48 | 49 | {% if deployment_app.environment is defined %} 50 | environment: 51 | {% for key, val in deployment_app.environment.iteritems() %} 52 | {{ key }} : "{{ val }}" 53 | {% endfor %} 54 | {% endif %} 55 | {% endif %} 56 | 57 | {% if deployment_db %} 58 | ## MYSQL db 59 | db: 60 | {% if deployment_db.ports is defined %} 61 | ports: 62 | {% for val in deployment_db.ports %} 63 | - {{ val }} 64 | {% endfor %} 65 | {% endif %} 66 | 67 | {% if deployment_db.volumes is defined %} 68 | volumes: 69 | {% for val in deployment_db.volumes %} 70 | - {{ val }} 71 | {% endfor %} 72 | {% endif %} 73 | image: mysql:5.7.22 74 | container_name: db 75 | restart: unless-stopped 76 | networks: 77 | - app-network 78 | {% if deployment_db.environment is defined %} 79 | environment: 80 | {% for key, val in deployment_db.environment.iteritems() %} 81 | {{ key }} : "{{ val }}" 82 | {% endfor %} 83 | {% endif %} 84 | {% endif %} -------------------------------------------------------------------------------- /ansible/vagrant/id_rsa: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEAtTZwqqxn8VR0QgQCUMGyaql1Ht1GXSmcCT343b528k55jIr4 3 | cuaWwiZ+r3FebRh713TG7BVw+8JMiFsz41jW6j+VQTZzakoT3qQfu/IdTOkxbI6Z 4 | 5AmqOTOGv7iyV5DMpwsugSwsTCVCSiGIsTf/n5sMzUqjzlO6jVFG6leBEdq1Hds6 5 | ZuHlLxPUI4CwSeSrXcn03Usymxe8h1FoLLQVA2fsDrhcrPqXFa7byXqpCnQQhnL8 6 | VUx1cwmuglgRoBuIPvDh7eH/tj1J/U4Kwux22j8NwxxaEPnCsye212WdsMK5qJ6G 7 | XHf6OwADpNHzQ0FF+r4D+rs6qIicPS7ULHFmrQIDAQABAoIBAQCels1VYNr6xkmU 8 | eMO5/zpwxGr+nvJ0l/S51eWV0plwh6Myj3DNxeYMdfoK+rGD0piXP9jTRhSCEFJA 9 | R2kKv3YevZSW5NtvGvN2trYbGtHvvGmHsukVPCwgMWrtIOvbXJruWgfR/mGqJjV0 10 | gRKK3hI1kVFL3NWsvXQXNxlT/06y2vcDaAfc+DUJyx0DvfZJmLpEOR5SlGn3c1mU 11 | gg6k0XF4lGlGLXKtWwVKoMJNHFbiLxCXSo9gI+qja7M8vlR29yvjtKTPIkkBPWkd 12 | MJTt2qvOFxGbRouVU1XbpvPOYd/u0sl05dBc6Kmkew0hJszAysNnXGqFsp8+z8Cu 13 | q344ZiY1AoGBANkJGI5bLlK2EFzdd5h639kmyMkhjOdrJPlFW4EjIxn3Yv5TbQRi 14 | u5AVie00o11eXrE9W3fSoHLymlkkpw3xoIWy5/JF2oTD2ea5h4jbfhhNoLthW9ub 15 | Ggyt1UKrautxKAGuhZSzNz8J8rLtcRW4nt72InI1V990+Uj53f9LlEgDAoGBANW+ 16 | 7tYj63IBduCuvR7vLF4kwsUH/SLny6iSSl9JhJkJ8uESGa93VSiaUwRmNEhBXhmv 17 | iAdduzRLUY4Tit1RK2/DYi4dN1UCgh8QuVyzC682pPlCTm+mv7CGv75H9R2XP+Cw 18 | dWTSxYUu+A2icNTd0ANpW2Yy04gLJeIph5yZdw+PAoGAfWipHNEJMlfrmo2KJryR 19 | jlu/16CgV7Rst/Dgz/zqsn1lYUn5i3g1oyse+Mbawv/dvZKTwOgfOGyAzZPFR+Rf 20 | +gGHz1GX0/GLfquj6mvSL97jSoMWXg4AfmUP/qcocAWBtX8Pxv3LpYxtBgD3wDJe 21 | 8rzM6Kt0LDXeOdHP+k3Ez9sCgYBoD1ZzhnU/wZrAdBG6l7I/+yGfju4cKkEqRl5S 22 | 2ZXmc8N887TxieU5qTg1chSOANTxKFXPUECtiuWfh8AZU0UUWkjYLn0bs+bpfNjh 23 | WoGbwby7ZR6OmN3F8TQ0TQ/2YgZFO2NLvJlQ57b33FeWKo70ujw3GxOErfi5jIJr 24 | KQOf3QKBgQDSY6t/lfr5U1+GtuWZb0fhCamsqC9D90zzf80kkGKhPflGy7AXJc0z 25 | vaJOP8Np1I8EmotgbXcp0PapkVNbp6U2uvtaSriMQjyFde6CU6+AH+aPipoQ9dO/ 26 | Va42rZioyzqcn9azo+t6O3BbUn+0e1wHrOdsntKkC+mIdB0Xv5Ecig== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /ansible/vagrant/id_rsa.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1NnCqrGfxVHRCBAJQwbJqqXUe3UZdKZwJPfjdvnbyTnmMivhy5pbCJn6vcV5tGHvXdMbsFXD7wkyIWzPjWNbqP5VBNnNqShPepB+78h1M6TFsjpnkCao5M4a/uLJXkMynCy6BLCxMJUJKIYixN/+fmwzNSqPOU7qNUUbqV4ER2rUd2zpm4eUvE9QjgLBJ5KtdyfTdSzKbF7yHUWgstBUDZ+wOuFys+pcVrtvJeqkKdBCGcvxVTHVzCa6CWBGgG4g+8OHt4f+2PUn9TgrC7HbaPw3DHFoQ+cKzJ7bXZZ2wwrmonoZcd/o7AAOk0fNDQUX6vgP6uzqoiJw9LtQscWat varun@DESKTOP-HICNS5Q 2 | -------------------------------------------------------------------------------- /ansible/vars/dev.yml: -------------------------------------------------------------------------------- 1 | deployment_mysql_hospice_username: hospice_user 2 | deployment_mysql_hospoce_password: dev@password 3 | deployment_app_image: varunpalekar1/php-test:latest 4 | 5 | deployment_webserver: 6 | ports: 7 | - "80" 8 | - "443" 9 | volumes: 10 | - ./:/var/www 11 | - ./docker/nginx/conf.d/:/etc/nginx/conf.d/ 12 | 13 | deployment_app: 14 | image: "{{ deployment_app_image }}" 15 | environment: 16 | APP_ENV: dev 17 | APP_DEBUG: "true" 18 | APP_KEY: base64:oPD/hrRXGvA1hydZp17JAQH2PnflMgp4P5OMWoldWTM= 19 | 20 | DB_HOST: db 21 | DB_DATABASE: laravel 22 | DB_USERNAME: root 23 | DB_PASSWORD: your_mysql_root_password 24 | 25 | JAEGER_HOST: jaeger 26 | JAEGER_PORT: 6831 27 | JAEGER_ENABLE: "false" 28 | volumes: 29 | - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini 30 | 31 | deployment_db: 32 | volumes: 33 | - ./docker-data/mysql:/var/lib/mysql 34 | - ./docker/mysql/my.cnf:/etc/mysql/my.cnf 35 | environment: 36 | MYSQL_DATABASE: laravel 37 | MYSQL_ROOT_PASSWORD: your_mysql_root_password -------------------------------------------------------------------------------- /ansible/vars/prod.yml: -------------------------------------------------------------------------------- 1 | --- 2 | mysql_root_password: !vault | 3 | $ANSIBLE_VAULT;1.1;AES256 4 | 61313835633639326662623933393862353361653161346634363638333366353765323631343866 5 | 6232366537616336333262663236643965653266643461320a643166336261363662393037303837 6 | 31313833326439616265393066373730383439613366626462643335633966633436353436633936 7 | 3361623431323365650a326163366662316431366364366230326137336630616233613166383364 8 | 3565 9 | 10 | mysql_root_username: root 11 | 12 | deployment_mysql_hospice_name: hospice 13 | deployment_mysql_hospice_username: hospice_user 14 | deployment_mysql_hospoce_password: !vault | 15 | $ANSIBLE_VAULT;1.1;AES256 16 | 33343136386364626234333131386135353238643462643939666137386235663131663834353561 17 | 3565623930363030636334633230396639303835643034390a306130373830303332653837613835 18 | 36346233396535643433383139366564643064343037373135333934376530623932653163303266 19 | 3466653231353838350a616466356430306463353239396361363737373339383664666663653963 20 | 3664 21 | 22 | deployment_db: false 23 | deployment_app_image: varunpalekar1/php-test:latest 24 | deployment_webserver: 25 | ports: 26 | - "80" 27 | - "443" 28 | volumes: 29 | - ./:/var/www 30 | - ./docker/nginx/conf.d/:/etc/nginx/conf.d/ 31 | 32 | deployment_app: 33 | image: "{{ deployment_app_image }}" 34 | environment: 35 | APP_ENV: prod 36 | APP_DEBUG: "true" 37 | APP_KEY: base64:oPD/hrRXGvA1hydZp17JAQH2PnflMgp4P5OMWoldWTM= 38 | 39 | DB_HOST: localhost 40 | DB_DATABASE: "{{ deployment_mysql_hospice_name }}" 41 | DB_USERNAME: "{{ deployment_mysql_hospice_username }}" 42 | DB_PASSWORD: "{{ deployment_mysql_hospoce_password }}" 43 | 44 | volumes: 45 | - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini 46 | 47 | mysql_databases: 48 | - name: "{{ deployment_mysql_hospice_name }}" 49 | encoding: latin1 50 | collation: latin1_general_ci 51 | mysql_users: 52 | - name: "{{ deployment_mysql_hospice_username }}" 53 | host: "%" 54 | priv: "hospice.*:ALL" 55 | password: "{{ deployment_mysql_hospoce_password }}" -------------------------------------------------------------------------------- /app/Book.php: -------------------------------------------------------------------------------- 1 | hasMany('App\Post'); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/Comment.php: -------------------------------------------------------------------------------- 1 | belongsTo('App\Post'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/Console/Commands/Inspire.php: -------------------------------------------------------------------------------- 1 | comment(PHP_EOL.Inspiring::quote().PHP_EOL); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | ->hourly(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Events/Event.php: -------------------------------------------------------------------------------- 1 | get("id", 0); 15 | 16 | // load the requested post 17 | $post = Post::find($post_id); 18 | 19 | // check the name property 20 | return $post->title; 21 | } 22 | } -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/AuthController.php: -------------------------------------------------------------------------------- 1 | middleware('guest', ['except' => 'getLogout']); 41 | } 42 | 43 | /** 44 | * Get a validator for an incoming registration request. 45 | * 46 | * @param array $data 47 | * @return \Illuminate\Contracts\Validation\Validator 48 | */ 49 | protected function validator(array $data) 50 | { 51 | return Validator::make($data, [ 52 | 'name' => 'required|max:255', 53 | 'email' => 'required|email|max:255|unique:users', 54 | 'password' => 'required|confirmed|min:6', 55 | ]); 56 | } 57 | 58 | /** 59 | * Create a new user instance after a valid registration. 60 | * 61 | * @param array $data 62 | * @return User 63 | */ 64 | protected function create(array $data) 65 | { 66 | return User::create([ 67 | 'name' => $data['name'], 68 | 'email' => $data['email'], 69 | 'password' => bcrypt($data['password']), 70 | ]); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/Http/Controllers/BlogController.php: -------------------------------------------------------------------------------- 1 | withPosts($posts); 17 | } 18 | 19 | public function getSingle($slug) { 20 | // fetch from the DB based on slug 21 | $post = Post::where('slug', '=', $slug)->first(); 22 | 23 | // return the view and pass in the post object 24 | return view('blog.single')->withPost($post); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Controllers/CategoryController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 16 | } 17 | 18 | /** 19 | * Display a listing of the resource. 20 | * 21 | * @return \Illuminate\Http\Response 22 | */ 23 | public function index() 24 | { 25 | // display a view of all of our categories 26 | // it will also have a form to create a new category 27 | 28 | $categories = Category::all(); 29 | return view('categories.index')->withCategories($categories); 30 | 31 | } 32 | 33 | /** 34 | * Store a newly created resource in storage. 35 | * 36 | * @param \Illuminate\Http\Request $request 37 | * @return \Illuminate\Http\Response 38 | */ 39 | public function store(Request $request) 40 | { 41 | // Save a new category and then redirect back to index 42 | $this->validate($request, array( 43 | 'name' => 'required|max:255' 44 | )); 45 | 46 | $category = new Category; 47 | 48 | $category->name = $request->name; 49 | $category->save(); 50 | 51 | Session::flash('success', 'New Category has been created'); 52 | 53 | return redirect()->route('categories.index'); 54 | } 55 | 56 | /** 57 | * Display the specified resource. 58 | * 59 | * @param int $id 60 | * @return \Illuminate\Http\Response 61 | */ 62 | public function show($id) 63 | { 64 | // Display the category and all the posts in that category 65 | } 66 | 67 | /** 68 | * Show the form for editing the specified resource. 69 | * 70 | * @param int $id 71 | * @return \Illuminate\Http\Response 72 | */ 73 | public function edit($id) 74 | { 75 | // 76 | } 77 | 78 | /** 79 | * Update the specified resource in storage. 80 | * 81 | * @param \Illuminate\Http\Request $request 82 | * @param int $id 83 | * @return \Illuminate\Http\Response 84 | */ 85 | public function update(Request $request, $id) 86 | { 87 | // 88 | } 89 | 90 | /** 91 | * Remove the specified resource from storage. 92 | * 93 | * @param int $id 94 | * @return \Illuminate\Http\Response 95 | */ 96 | public function destroy($id) 97 | { 98 | // 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /app/Http/Controllers/CommentsController.php: -------------------------------------------------------------------------------- 1 | middleware('auth', ['except' => 'store']); 17 | } 18 | 19 | /** 20 | * Store a newly created resource in storage. 21 | * 22 | * @param \Illuminate\Http\Request $request 23 | * @return \Illuminate\Http\Response 24 | */ 25 | public function store(Request $request, $post_id) 26 | { 27 | $this->validate($request, array( 28 | 'name' => 'required|max:255', 29 | 'email' => 'required|email|max:255', 30 | 'comment' => 'required|min:5|max:2000' 31 | )); 32 | 33 | $post = Post::find($post_id); 34 | 35 | $comment = new Comment(); 36 | $comment->name = $request->name; 37 | $comment->email = $request->email; 38 | $comment->comment = $request->comment; 39 | $comment->approved = true; 40 | $comment->post()->associate($post); 41 | 42 | $comment->save(); 43 | 44 | Session::flash('success', 'Comment was added'); 45 | 46 | return redirect()->route('blog.single', [$post->slug]); 47 | } 48 | 49 | 50 | /** 51 | * Show the form for editing the specified resource. 52 | * 53 | * @param int $id 54 | * @return \Illuminate\Http\Response 55 | */ 56 | public function edit($id) 57 | { 58 | $comment = Comment::find($id); 59 | return view('comments.edit')->withComment($comment); 60 | } 61 | 62 | /** 63 | * Update the specified resource in storage. 64 | * 65 | * @param \Illuminate\Http\Request $request 66 | * @param int $id 67 | * @return \Illuminate\Http\Response 68 | */ 69 | public function update(Request $request, $id) 70 | { 71 | $comment = Comment::find($id); 72 | 73 | $this->validate($request, array('comment' => 'required')); 74 | 75 | $comment->comment = $request->comment; 76 | $comment->save(); 77 | 78 | Session::flash('success', 'Comment updated'); 79 | 80 | return redirect()->route('posts.show', $comment->post->id); 81 | } 82 | 83 | public function delete($id) 84 | { 85 | $comment = Comment::find($id); 86 | return view('comments.delete')->withComment($comment); 87 | } 88 | 89 | /** 90 | * Remove the specified resource from storage. 91 | * 92 | * @param int $id 93 | * @return \Illuminate\Http\Response 94 | */ 95 | public function destroy($id) 96 | { 97 | $comment = Comment::find($id); 98 | $post_id = $comment->post->id; 99 | $comment->delete(); 100 | 101 | Session::flash('success', 'Deleted Comment'); 102 | 103 | return redirect()->route('posts.show', $post_id); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | limit(4)->get(); 16 | return view('pages.welcome')->withPosts($posts); 17 | } 18 | 19 | public function getAbout() { 20 | $first = 'Alex'; 21 | $last = 'Curtis'; 22 | 23 | $fullname = $first . " " . $last; 24 | $email = 'alex@jacurtis.com'; 25 | $data = []; 26 | $data['email'] = $email; 27 | $data['fullname'] = $fullname; 28 | return view('pages.about')->withData($data); 29 | } 30 | 31 | public function getContact() { 32 | return view('pages.contact'); 33 | } 34 | 35 | public function postContact(Request $request) { 36 | $this->validate($request, [ 37 | 'email' => 'required|email', 38 | 'subject' => 'min:3', 39 | 'message' => 'min:10']); 40 | 41 | $data = array( 42 | 'email' => $request->email, 43 | 'subject' => $request->subject, 44 | 'bodyMessage' => $request->message 45 | ); 46 | 47 | Mail::send('emails.contact', $data, function($message) use ($data){ 48 | $message->from($data['email']); 49 | $message->to('hello@devmarketer.io'); 50 | $message->subject($data['subject']); 51 | }); 52 | 53 | Session::flash('success', 'Your Email was Sent!'); 54 | 55 | return redirect('/'); 56 | } 57 | 58 | 59 | } -------------------------------------------------------------------------------- /app/Http/Controllers/PostController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 21 | } 22 | /** 23 | * Display a listing of the resource. 24 | * 25 | * @return \Illuminate\Http\Response 26 | */ 27 | public function index() 28 | { 29 | $posts = Post::orderBy('id', 'desc')->paginate(10); 30 | return view('posts.index')->withPosts($posts); 31 | } 32 | 33 | /** 34 | * Show the form for creating a new resource. 35 | * 36 | * @return \Illuminate\Http\Response 37 | */ 38 | public function create() 39 | { 40 | $categories = Category::all(); 41 | $tags = Tag::all(); 42 | return view('posts.create')->withCategories($categories)->withTags($tags); 43 | } 44 | 45 | /** 46 | * Store a newly created resource in storage. 47 | * 48 | * @param \Illuminate\Http\Request $request 49 | * @return \Illuminate\Http\Response 50 | */ 51 | public function store(Request $request) 52 | { 53 | // validate the data 54 | $this->validate($request, array( 55 | 'title' => 'required|max:255', 56 | 'slug' => 'required|alpha_dash|min:5|max:255|unique:posts,slug', 57 | 'category_id' => 'required|integer', 58 | 'body' => 'required' 59 | )); 60 | 61 | // store in the database 62 | $post = new Post; 63 | 64 | $post->title = $request->title; 65 | $post->slug = $request->slug; 66 | $post->category_id = $request->category_id; 67 | $post->body = Purifier::clean($request->body); 68 | 69 | if ($request->hasFile('featured_img')) { 70 | $image = $request->file('featured_img'); 71 | $filename = time() . '.' . $image->getClientOriginalExtension(); 72 | $location = public_path('images/' . $filename); 73 | Image::make($image)->resize(800, 400)->save($location); 74 | 75 | $post->image = $filename; 76 | } 77 | 78 | $post->save(); 79 | 80 | $post->tags()->sync($request->tags, false); 81 | 82 | Session::flash('success', 'The blog post was successfully save!'); 83 | 84 | return redirect()->route('posts.show', $post->id); 85 | } 86 | 87 | /** 88 | * Display the specified resource. 89 | * 90 | * @param int $id 91 | * @return \Illuminate\Http\Response 92 | */ 93 | public function show($id) 94 | { 95 | $post = Post::find($id); 96 | return view('posts.show')->withPost($post); 97 | } 98 | 99 | /** 100 | * Show the form for editing the specified resource. 101 | * 102 | * @param int $id 103 | * @return \Illuminate\Http\Response 104 | */ 105 | public function edit($id) 106 | { 107 | // find the post in the database and save as a var 108 | $post = Post::find($id); 109 | $categories = Category::all(); 110 | $cats = array(); 111 | foreach ($categories as $category) { 112 | $cats[$category->id] = $category->name; 113 | } 114 | 115 | $tags = Tag::all(); 116 | $tags2 = array(); 117 | foreach ($tags as $tag) { 118 | $tags2[$tag->id] = $tag->name; 119 | } 120 | // return the view and pass in the var we previously created 121 | return view('posts.edit')->withPost($post)->withCategories($cats)->withTags($tags2); 122 | } 123 | 124 | /** 125 | * Update the specified resource in storage. 126 | * 127 | * @param \Illuminate\Http\Request $request 128 | * @param int $id 129 | * @return \Illuminate\Http\Response 130 | */ 131 | public function update(Request $request, $id) 132 | { 133 | // Validate the data 134 | $post = Post::find($id); 135 | 136 | if ($request->input('slug') == $post->slug) { 137 | $this->validate($request, array( 138 | 'title' => 'required|max:255', 139 | 'category_id' => 'required|integer', 140 | 'body' => 'required' 141 | )); 142 | } else { 143 | $this->validate($request, array( 144 | 'title' => 'required|max:255', 145 | 'slug' => 'required|alpha_dash|min:5|max:255|unique:posts,slug', 146 | 'category_id' => 'required|integer', 147 | 'body' => 'required' 148 | )); 149 | } 150 | 151 | // Save the data to the database 152 | $post = Post::find($id); 153 | 154 | $post->title = $request->input('title'); 155 | $post->slug = $request->input('slug'); 156 | $post->category_id = $request->input('category_id'); 157 | $post->body = Purifier::clean($request->input('body')); 158 | 159 | $post->save(); 160 | 161 | if (isset($request->tags)) { 162 | $post->tags()->sync($request->tags); 163 | } else { 164 | $post->tags()->sync(array()); 165 | } 166 | 167 | 168 | // set flash data with success message 169 | Session::flash('success', 'This post was successfully saved.'); 170 | 171 | // redirect with flash data to posts.show 172 | return redirect()->route('posts.show', $post->id); 173 | } 174 | 175 | /** 176 | * Remove the specified resource from storage. 177 | * 178 | * @param int $id 179 | * @return \Illuminate\Http\Response 180 | */ 181 | public function destroy($id) 182 | { 183 | $post = Post::find($id); 184 | $post->tags()->detach(); 185 | 186 | $post->tags()->detach(); 187 | 188 | $post->delete(); 189 | 190 | Session::flash('success', 'The post was successfully deleted.'); 191 | return redirect()->route('posts.index'); 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /app/Http/Controllers/TagController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 16 | } 17 | 18 | /** 19 | * Display a listing of the resource. 20 | * 21 | * @return \Illuminate\Http\Response 22 | */ 23 | public function index() 24 | { 25 | $tags = Tag::all(); 26 | return view('tags.index')->withTags($tags); 27 | } 28 | 29 | /** 30 | * Store a newly created resource in storage. 31 | * 32 | * @param \Illuminate\Http\Request $request 33 | * @return \Illuminate\Http\Response 34 | */ 35 | public function store(Request $request) 36 | { 37 | $this->validate($request, array('name' => 'required|max:255')); 38 | $tag = new Tag; 39 | $tag->name = $request->name; 40 | $tag->save(); 41 | 42 | Session::flash('success', 'New Tag was successfully created!'); 43 | 44 | return redirect()->route('tags.index'); 45 | } 46 | 47 | /** 48 | * Display the specified resource. 49 | * 50 | * @param int $id 51 | * @return \Illuminate\Http\Response 52 | */ 53 | public function show($id) 54 | { 55 | $tag = Tag::find($id); 56 | return view('tags.show')->withTag($tag); 57 | } 58 | 59 | /** 60 | * Show the form for editing the specified resource. 61 | * 62 | * @param int $id 63 | * @return \Illuminate\Http\Response 64 | */ 65 | public function edit($id) 66 | { 67 | $tag = Tag::find($id); 68 | return view('tags.edit')->withTag($tag); 69 | } 70 | 71 | /** 72 | * Update the specified resource in storage. 73 | * 74 | * @param \Illuminate\Http\Request $request 75 | * @param int $id 76 | * @return \Illuminate\Http\Response 77 | */ 78 | public function update(Request $request, $id) 79 | { 80 | $tag = Tag::find($id); 81 | 82 | $this->validate($request, ['name' => 'required|max:255']); 83 | 84 | $tag->name = $request->name; 85 | $tag->save(); 86 | 87 | Session::flash('success', 'Successfully saved your new tag!'); 88 | 89 | return redirect()->route('tags.show', $tag->id); 90 | } 91 | 92 | /** 93 | * Remove the specified resource from storage. 94 | * 95 | * @param int $id 96 | * @return \Illuminate\Http\Response 97 | */ 98 | public function destroy($id) 99 | { 100 | $tag = Tag::find($id); 101 | $tag->posts()->detach(); 102 | 103 | $tag->delete(); 104 | 105 | Session::flash('success', 'Tag was deleted successfully'); 106 | 107 | return redirect()->route('tags.index'); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | [ 27 | \App\Http\Middleware\EncryptCookies::class, 28 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 29 | \Illuminate\Session\Middleware\StartSession::class, 30 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 31 | \App\Http\Middleware\VerifyCsrfToken::class, 32 | ], 33 | 34 | 'api' => [ 35 | 'throttle:60,1', 36 | ], 37 | ]; 38 | 39 | /** 40 | * The application's route middleware. 41 | * 42 | * These middleware may be assigned to groups or used individually. 43 | * 44 | * @var array 45 | */ 46 | protected $routeMiddleware = [ 47 | 'auth' => \App\Http\Middleware\Authenticate::class, 48 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 49 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 50 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 51 | ]; 52 | } 53 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | guest()) { 21 | if ($request->ajax()) { 22 | return response('Unauthorized.', 401); 23 | } else { 24 | return redirect()->guest('auth/login'); 25 | } 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | ['web']], function () { 27 | // Authentication Routes 28 | Route::get('auth/login', ['as' => 'login', 'uses' => 'Auth\AuthController@getLogin']); 29 | Route::post('auth/login', 'Auth\AuthController@postLogin'); 30 | Route::get('auth/logout', ['as' => 'logout', 'uses' => 'Auth\AuthController@getLogout']); 31 | 32 | // Registration Routes 33 | Route::get('auth/register', 'Auth\AuthController@getRegister'); 34 | Route::post('auth/register', 'Auth\AuthController@postRegister'); 35 | 36 | // Password Reset Routes 37 | Route::get('password/reset/{token?}', 'Auth\PasswordController@showResetForm'); 38 | Route::post('password/email', 'Auth\PasswordController@sendResetLinkEmail'); 39 | Route::post('password/reset', 'Auth\PasswordController@reset'); 40 | 41 | // Categories 42 | Route::resource('categories', 'CategoryController', ['except' => ['create']]); 43 | Route::resource('tags', 'TagController', ['except' => ['create']]); 44 | 45 | // Comments 46 | Route::post('comments/{post_id}', ['uses' => 'CommentsController@store', 'as' => 'comments.store']); 47 | Route::get('comments/{id}/edit', ['uses' => 'CommentsController@edit', 'as' => 'comments.edit']); 48 | Route::put('comments/{id}', ['uses' => 'CommentsController@update', 'as' => 'comments.update']); 49 | Route::delete('comments/{id}', ['uses' => 'CommentsController@destroy', 'as' => 'comments.destroy']); 50 | Route::get('comments/{id}/delete', ['uses' => 'CommentsController@delete', 'as' => 'comments.delete']); 51 | 52 | 53 | Route::get('blog/{slug}', ['as' => 'blog.single', 'uses' => 'BlogController@getSingle'])->where('slug', '[\w\d\-\_]+'); 54 | Route::get('blog', ['uses' => 'BlogController@getIndex', 'as' => 'blog.index']); 55 | Route::get('contact', 'PagesController@getContact'); 56 | Route::post('contact', 'PagesController@postContact'); 57 | Route::get('about', 'PagesController@getAbout'); 58 | Route::get('/', 'PagesController@getIndex'); 59 | Route::resource('posts', 'PostController'); 60 | Route::get('accessor/index', 'AccessorController@index'); 61 | }); 62 | -------------------------------------------------------------------------------- /app/Jobs/Job.php: -------------------------------------------------------------------------------- 1 | belongsTo('App\Category'); 12 | } 13 | 14 | public function tags() 15 | { 16 | return $this->belongsToMany('App\Tag'); 17 | } 18 | 19 | public function comments() 20 | { 21 | return $this->hasMany('App\Comment'); 22 | } 23 | 24 | protected $fillable = ['title','body','slug']; 25 | 26 | 27 | /** 28 | * Get the post title. 29 | * 30 | * @param string $value 31 | * @return string 32 | */ 33 | /*public function getNameAttribute($value) 34 | { 35 | return ucfirst($value); 36 | }*/ 37 | } -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any application authentication / authorization services. 21 | * 22 | * @param \Illuminate\Contracts\Auth\Access\Gate $gate 23 | * @return void 24 | */ 25 | public function boot(GateContract $gate) 26 | { 27 | $this->registerPolicies($gate); 28 | 29 | // 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'App\Listeners\EventListener', 18 | ], 19 | ]; 20 | 21 | /** 22 | * Register any other events for your application. 23 | * 24 | * @param \Illuminate\Contracts\Events\Dispatcher $events 25 | * @return void 26 | */ 27 | public function boot(DispatcherContract $events) 28 | { 29 | parent::boot($events); 30 | 31 | // 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Providers/OpenCensusProvider.php: -------------------------------------------------------------------------------- 1 | env('JAEGER_HOST', 'jaeger'), 27 | "port" => env('JAEGER_PORT', '6831'), 28 | "tags" => [], 29 | 'client' => null 30 | ]; 31 | 32 | // Start the request tracing for this request 33 | $exporter = new JaegerExporter( env('APP_NAME', 'Laravel') ,$options); 34 | 35 | // $exporter = new EchoExporter(); 36 | // $exporter = new FileExporter('/var/www/opentrace.log'); 37 | Tracer::start($exporter); 38 | 39 | // Create a span that starts from when Laravel first boots (public/index.php) 40 | Tracer::inSpan(['name' => 'bootstrap', 'startTime' => LARAVEL_START], function () {}); 41 | } 42 | 43 | public function register() 44 | { 45 | // 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | group(['namespace' => $this->namespace], function ($router) { 41 | require app_path('Http/routes.php'); 42 | }); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/Tag.php: -------------------------------------------------------------------------------- 1 | belongsToMany('App\Post'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/User.php: -------------------------------------------------------------------------------- 1 | hasMany(Book::class); 29 | //} 30 | 31 | //public function posts(){ 32 | // return $this->hasMany(Post::class); 33 | // } 34 | } 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/autoload.php: -------------------------------------------------------------------------------- 1 | =5.5.9", 9 | "laravel/framework": "5.2.*", 10 | "laravelcollective/html": "5.2.*", 11 | "mews/purifier": "^2.0", 12 | "intervention/image": "^2.3", 13 | "opencensus/opencensus": "^0.5.2", 14 | "opencensus/opencensus-exporter-jaeger": "~0.1" 15 | }, 16 | "require-dev": { 17 | "fzaninotto/faker": "~1.4", 18 | "mockery/mockery": "0.9.*", 19 | "phpunit/phpunit": "~4.0", 20 | "symfony/css-selector": "2.8.*|3.0.*", 21 | "symfony/dom-crawler": "2.8.*|3.0.*", 22 | "doctrine/dbal" : "*" 23 | }, 24 | "autoload": { 25 | "classmap": [ 26 | "database" 27 | ], 28 | "psr-4": { 29 | "App\\": "app/" 30 | } 31 | }, 32 | "autoload-dev": { 33 | "classmap": [ 34 | "tests/TestCase.php" 35 | ] 36 | }, 37 | "scripts": { 38 | "post-root-package-install": [ 39 | "php -r \"copy('.env.example', '.env');\"" 40 | ], 41 | "post-create-project-cmd": [ 42 | "php artisan key:generate" 43 | ], 44 | "post-install-cmd": [ 45 | "php artisan clear-compiled", 46 | "php artisan optimize" 47 | ], 48 | "pre-update-cmd": [ 49 | "php artisan clear-compiled" 50 | ], 51 | "post-update-cmd": [ 52 | "php artisan optimize" 53 | ] 54 | }, 55 | "config": { 56 | "preferred-install": "dist" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_ENV', 'production'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Debug Mode 21 | |-------------------------------------------------------------------------- 22 | | 23 | | When your application is in debug mode, detailed error messages with 24 | | stack traces will be shown on every error that occurs within your 25 | | application. If disabled, a simple generic error page is shown. 26 | | 27 | */ 28 | 29 | 'debug' => env('APP_DEBUG', false), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application URL 34 | |-------------------------------------------------------------------------- 35 | | 36 | | This URL is used by the console to properly generate URLs when using 37 | | the Artisan command line tool. You should set this to the root of 38 | | your application so that it is used when running Artisan tasks. 39 | | 40 | */ 41 | 42 | 'url' => 'http://localhost/laravel_blog/public/', 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application Timezone 47 | |-------------------------------------------------------------------------- 48 | | 49 | | Here you may specify the default timezone for your application, which 50 | | will be used by the PHP date and date-time functions. We have gone 51 | | ahead and set this to a sensible default for you out of the box. 52 | | 53 | */ 54 | 55 | 'timezone' => 'UTC', 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Locale Configuration 60 | |-------------------------------------------------------------------------- 61 | | 62 | | The application locale determines the default locale that will be used 63 | | by the translation service provider. You are free to set this value 64 | | to any of the locales which will be supported by the application. 65 | | 66 | */ 67 | 68 | 'locale' => 'en', 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Application Fallback Locale 73 | |-------------------------------------------------------------------------- 74 | | 75 | | The fallback locale determines the locale to use when the current one 76 | | is not available. You may change the value to correspond to any of 77 | | the language folders that are provided through your application. 78 | | 79 | */ 80 | 81 | 'fallback_locale' => 'en', 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Encryption Key 86 | |-------------------------------------------------------------------------- 87 | | 88 | | This key is used by the Illuminate encrypter service and should be set 89 | | to a random, 32 character string, otherwise these encrypted strings 90 | | will not be safe. Please do this before deploying an application! 91 | | 92 | */ 93 | 94 | 'key' => env('APP_KEY'), 95 | 96 | 'cipher' => 'AES-256-CBC', 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Logging Configuration 101 | |-------------------------------------------------------------------------- 102 | | 103 | | Here you may configure the log settings for your application. Out of 104 | | the box, Laravel uses the Monolog PHP logging library. This gives 105 | | you a variety of powerful log handlers / formatters to utilize. 106 | | 107 | | Available Settings: "single", "daily", "syslog", "errorlog" 108 | | 109 | */ 110 | 111 | 'log' => env('APP_LOG', 'single'), 112 | 113 | /* 114 | |-------------------------------------------------------------------------- 115 | | Autoloaded Service Providers 116 | |-------------------------------------------------------------------------- 117 | | 118 | | The service providers listed here will be automatically loaded on the 119 | | request to your application. Feel free to add your own services to 120 | | this array to grant expanded functionality to your applications. 121 | | 122 | */ 123 | 124 | 'providers' => [ 125 | 126 | /* 127 | * Laravel Framework Service Providers... 128 | */ 129 | Illuminate\Auth\AuthServiceProvider::class, 130 | Illuminate\Broadcasting\BroadcastServiceProvider::class, 131 | Illuminate\Bus\BusServiceProvider::class, 132 | Illuminate\Cache\CacheServiceProvider::class, 133 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, 134 | Illuminate\Cookie\CookieServiceProvider::class, 135 | Illuminate\Database\DatabaseServiceProvider::class, 136 | Illuminate\Encryption\EncryptionServiceProvider::class, 137 | Illuminate\Filesystem\FilesystemServiceProvider::class, 138 | Illuminate\Foundation\Providers\FoundationServiceProvider::class, 139 | Illuminate\Hashing\HashServiceProvider::class, 140 | Illuminate\Mail\MailServiceProvider::class, 141 | Illuminate\Pagination\PaginationServiceProvider::class, 142 | Illuminate\Pipeline\PipelineServiceProvider::class, 143 | Illuminate\Queue\QueueServiceProvider::class, 144 | Illuminate\Redis\RedisServiceProvider::class, 145 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, 146 | Illuminate\Session\SessionServiceProvider::class, 147 | Illuminate\Translation\TranslationServiceProvider::class, 148 | Illuminate\Validation\ValidationServiceProvider::class, 149 | Illuminate\View\ViewServiceProvider::class, 150 | Collective\Html\HtmlServiceProvider::class, 151 | Mews\Purifier\PurifierServiceProvider::class, 152 | 153 | /* 154 | * Application Service Providers... 155 | */ 156 | App\Providers\AppServiceProvider::class, 157 | App\Providers\AuthServiceProvider::class, 158 | App\Providers\EventServiceProvider::class, 159 | App\Providers\RouteServiceProvider::class, 160 | 161 | Intervention\Image\ImageServiceProvider::class, 162 | 163 | // Opencensus 164 | App\Providers\OpenCensusProvider::class, 165 | 166 | ], 167 | 168 | /* 169 | |-------------------------------------------------------------------------- 170 | | Class Aliases 171 | |-------------------------------------------------------------------------- 172 | | 173 | | This array of class aliases will be registered when this application 174 | | is started. However, feel free to register as many as you wish as 175 | | the aliases are "lazy" loaded so they don't hinder performance. 176 | | 177 | */ 178 | 179 | 'aliases' => [ 180 | 181 | 'App' => Illuminate\Support\Facades\App::class, 182 | 'Artisan' => Illuminate\Support\Facades\Artisan::class, 183 | 'Auth' => Illuminate\Support\Facades\Auth::class, 184 | 'Blade' => Illuminate\Support\Facades\Blade::class, 185 | 'Cache' => Illuminate\Support\Facades\Cache::class, 186 | 'Config' => Illuminate\Support\Facades\Config::class, 187 | 'Cookie' => Illuminate\Support\Facades\Cookie::class, 188 | 'Crypt' => Illuminate\Support\Facades\Crypt::class, 189 | 'DB' => Illuminate\Support\Facades\DB::class, 190 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 191 | 'Event' => Illuminate\Support\Facades\Event::class, 192 | 'File' => Illuminate\Support\Facades\File::class, 193 | 'Gate' => Illuminate\Support\Facades\Gate::class, 194 | 'Hash' => Illuminate\Support\Facades\Hash::class, 195 | 'Lang' => Illuminate\Support\Facades\Lang::class, 196 | 'Log' => Illuminate\Support\Facades\Log::class, 197 | 'Mail' => Illuminate\Support\Facades\Mail::class, 198 | 'Password' => Illuminate\Support\Facades\Password::class, 199 | 'Queue' => Illuminate\Support\Facades\Queue::class, 200 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, 201 | 'Redis' => Illuminate\Support\Facades\Redis::class, 202 | 'Request' => Illuminate\Support\Facades\Request::class, 203 | 'Response' => Illuminate\Support\Facades\Response::class, 204 | 'Route' => Illuminate\Support\Facades\Route::class, 205 | 'Schema' => Illuminate\Support\Facades\Schema::class, 206 | 'Session' => Illuminate\Support\Facades\Session::class, 207 | 'Storage' => Illuminate\Support\Facades\Storage::class, 208 | 'URL' => Illuminate\Support\Facades\URL::class, 209 | 'Validator' => Illuminate\Support\Facades\Validator::class, 210 | 'View' => Illuminate\Support\Facades\View::class, 211 | 'Form' => Collective\Html\FormFacade::class, 212 | 'Html' => Collective\Html\HtmlFacade::class, 213 | 'Purifier' => Mews\Purifier\Facades\Purifier::class, 214 | 'Image' => Intervention\Image\Facades\Image::class 215 | ], 216 | 217 | ]; 218 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'token', 46 | 'provider' => 'users', 47 | ], 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | User Providers 53 | |-------------------------------------------------------------------------- 54 | | 55 | | All authentication drivers have a user provider. This defines how the 56 | | users are actually retrieved out of your database or other storage 57 | | mechanisms used by this application to persist your user's data. 58 | | 59 | | If you have multiple user tables or models you may configure multiple 60 | | sources which represent each model / table. These sources may then 61 | | be assigned to any extra authentication guards you have defined. 62 | | 63 | | Supported: "database", "eloquent" 64 | | 65 | */ 66 | 67 | 'providers' => [ 68 | 'users' => [ 69 | 'driver' => 'eloquent', 70 | 'model' => App\User::class, 71 | ], 72 | 73 | // 'users' => [ 74 | // 'driver' => 'database', 75 | // 'table' => 'users', 76 | // ], 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Resetting Passwords 82 | |-------------------------------------------------------------------------- 83 | | 84 | | Here you may set the options for resetting passwords including the view 85 | | that is your password reset e-mail. You may also set the name of the 86 | | table that maintains all of the reset tokens for your application. 87 | | 88 | | You may specify multiple password reset configurations if you have more 89 | | than one user table or model in the application and you want to have 90 | | separate password reset settings based on the specific user types. 91 | | 92 | | The expire time is the number of minutes that the reset token should be 93 | | considered valid. This security feature keeps tokens short-lived so 94 | | they have less time to be guessed. You may change this as needed. 95 | | 96 | */ 97 | 98 | 'passwords' => [ 99 | 'users' => [ 100 | 'provider' => 'users', 101 | 'email' => 'auth.emails.password', 102 | 'table' => 'password_resets', 103 | 'expire' => 60, 104 | ], 105 | ], 106 | 107 | ]; 108 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'pusher'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Broadcast Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may define all of the broadcast connections that will be used 24 | | to broadcast events to other systems or over websockets. Samples of 25 | | each available type of connection are provided inside this array. 26 | | 27 | */ 28 | 29 | 'connections' => [ 30 | 31 | 'pusher' => [ 32 | 'driver' => 'pusher', 33 | 'key' => env('PUSHER_KEY'), 34 | 'secret' => env('PUSHER_SECRET'), 35 | 'app_id' => env('PUSHER_APP_ID'), 36 | 'options' => [ 37 | // 38 | ], 39 | ], 40 | 41 | 'redis' => [ 42 | 'driver' => 'redis', 43 | 'connection' => 'default', 44 | ], 45 | 46 | 'log' => [ 47 | 'driver' => 'log', 48 | ], 49 | 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Cache Stores 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may define all of the cache "stores" for your application as 24 | | well as their drivers. You may even define multiple stores for the 25 | | same cache driver to group types of items stored in your caches. 26 | | 27 | */ 28 | 29 | 'stores' => [ 30 | 31 | 'apc' => [ 32 | 'driver' => 'apc', 33 | ], 34 | 35 | 'array' => [ 36 | 'driver' => 'array', 37 | ], 38 | 39 | 'database' => [ 40 | 'driver' => 'database', 41 | 'table' => 'cache', 42 | 'connection' => null, 43 | ], 44 | 45 | 'file' => [ 46 | 'driver' => 'file', 47 | 'path' => storage_path('framework/cache'), 48 | ], 49 | 50 | 'memcached' => [ 51 | 'driver' => 'memcached', 52 | 'servers' => [ 53 | [ 54 | 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100, 55 | ], 56 | ], 57 | ], 58 | 59 | 'redis' => [ 60 | 'driver' => 'redis', 61 | 'connection' => 'default', 62 | ], 63 | 64 | ], 65 | 66 | /* 67 | |-------------------------------------------------------------------------- 68 | | Cache Key Prefix 69 | |-------------------------------------------------------------------------- 70 | | 71 | | When utilizing a RAM based store such as APC or Memcached, there might 72 | | be other applications utilizing the same cache. So, we'll specify a 73 | | value to get prefixed to all our keys so we can avoid collisions. 74 | | 75 | */ 76 | 77 | 'prefix' => 'laravel', 78 | 79 | ]; 80 | -------------------------------------------------------------------------------- /config/compile.php: -------------------------------------------------------------------------------- 1 | [ 17 | // 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled File Providers 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may list service providers which define a "compiles" function 26 | | that returns additional files that should be compiled, providing an 27 | | easy way to get common files from any packages you are utilizing. 28 | | 29 | */ 30 | 31 | 'providers' => [ 32 | // 33 | ], 34 | 35 | ]; 36 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | PDO::FETCH_CLASS, 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Database Connection Name 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may specify which of the database connections below you wish 24 | | to use as your default connection for all database work. Of course 25 | | you may use many connections at once using the Database library. 26 | | 27 | */ 28 | 29 | 'default' => env('DB_CONNECTION', 'mysql'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Database Connections 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here are each of the database connections setup for your application. 37 | | Of course, examples of configuring each database platform that is 38 | | supported by Laravel is shown below to make development simple. 39 | | 40 | | 41 | | All database work in Laravel is done through the PHP PDO facilities 42 | | so make sure you have the driver for your particular database of 43 | | choice installed on your machine before you begin development. 44 | | 45 | */ 46 | 47 | 'connections' => [ 48 | 49 | 'sqlite' => [ 50 | 'driver' => 'sqlite', 51 | 'database' => database_path('database.sqlite'), 52 | 'prefix' => '', 53 | ], 54 | 55 | 'mysql' => [ 56 | 'driver' => 'mysql', 57 | 'host' => env('DB_HOST', 'localhost'), 58 | 'database' => env('DB_DATABASE', 'forge'), 59 | 'username' => env('DB_USERNAME', 'forge'), 60 | 'password' => env('DB_PASSWORD', ''), 61 | 'charset' => 'utf8', 62 | 'collation' => 'utf8_unicode_ci', 63 | 'prefix' => '', 64 | 'strict' => false, 65 | ], 66 | 67 | 'pgsql' => [ 68 | 'driver' => 'pgsql', 69 | 'host' => env('DB_HOST', 'localhost'), 70 | 'database' => env('DB_DATABASE', 'forge'), 71 | 'username' => env('DB_USERNAME', 'forge'), 72 | 'password' => env('DB_PASSWORD', ''), 73 | 'charset' => 'utf8', 74 | 'prefix' => '', 75 | 'schema' => 'public', 76 | ], 77 | 78 | 'sqlsrv' => [ 79 | 'driver' => 'sqlsrv', 80 | 'host' => env('DB_HOST', 'localhost'), 81 | 'database' => env('DB_DATABASE', 'forge'), 82 | 'username' => env('DB_USERNAME', 'forge'), 83 | 'password' => env('DB_PASSWORD', ''), 84 | 'charset' => 'utf8', 85 | 'prefix' => '', 86 | ], 87 | 88 | ], 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Migration Repository Table 93 | |-------------------------------------------------------------------------- 94 | | 95 | | This table keeps track of all the migrations that have already run for 96 | | your application. Using this information, we can determine which of 97 | | the migrations on disk haven't actually been run in the database. 98 | | 99 | */ 100 | 101 | 'migrations' => 'migrations', 102 | 103 | /* 104 | |-------------------------------------------------------------------------- 105 | | Redis Databases 106 | |-------------------------------------------------------------------------- 107 | | 108 | | Redis is an open source, fast, and advanced key-value store that also 109 | | provides a richer set of commands than a typical key-value systems 110 | | such as APC or Memcached. Laravel makes it easy to dig right in. 111 | | 112 | */ 113 | 114 | 'redis' => [ 115 | 116 | 'cluster' => false, 117 | 118 | 'default' => [ 119 | 'host' => env('REDIS_HOST', 'localhost'), 120 | 'password' => env('REDIS_PASSWORD', null), 121 | 'port' => env('REDIS_PORT', 6379), 122 | 'database' => 0, 123 | ], 124 | 125 | ], 126 | 127 | ]; 128 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | 'local', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Default Cloud Filesystem Disk 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Many applications store files both locally and in the cloud. For this 26 | | reason, you may specify a default "cloud" driver here. This driver 27 | | will be bound as the Cloud disk implementation in the container. 28 | | 29 | */ 30 | 31 | 'cloud' => 's3', 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Filesystem Disks 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Here you may configure as many filesystem "disks" as you wish, and you 39 | | may even configure multiple disks of the same driver. Defaults have 40 | | been setup for each driver as an example of the required options. 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'ftp' => [ 52 | 'driver' => 'ftp', 53 | 'host' => 'ftp.example.com', 54 | 'username' => 'your-username', 55 | 'password' => 'your-password', 56 | 57 | // Optional FTP Settings... 58 | // 'port' => 21, 59 | // 'root' => '', 60 | // 'passive' => true, 61 | // 'ssl' => true, 62 | // 'timeout' => 30, 63 | ], 64 | 65 | 's3' => [ 66 | 'driver' => 's3', 67 | 'key' => 'your-key', 68 | 'secret' => 'your-secret', 69 | 'region' => 'your-region', 70 | 'bucket' => 'your-bucket', 71 | ], 72 | 73 | 'rackspace' => [ 74 | 'driver' => 'rackspace', 75 | 'username' => 'your-username', 76 | 'key' => 'your-key', 77 | 'container' => 'your-container', 78 | 'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/', 79 | 'region' => 'IAD', 80 | 'url_type' => 'publicURL', 81 | ], 82 | 83 | ], 84 | 85 | ]; 86 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_DRIVER', 'smtp'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | SMTP Host Address 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may provide the host address of the SMTP server used by your 26 | | applications. A default option is provided that is compatible with 27 | | the Mailgun mail service which will provide reliable deliveries. 28 | | 29 | */ 30 | 31 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | SMTP Host Port 36 | |-------------------------------------------------------------------------- 37 | | 38 | | This is the SMTP port used by your application to deliver e-mails to 39 | | users of the application. Like the host we have set this value to 40 | | stay compatible with the Mailgun e-mail application by default. 41 | | 42 | */ 43 | 44 | 'port' => env('MAIL_PORT', 587), 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Global "From" Address 49 | |-------------------------------------------------------------------------- 50 | | 51 | | You may wish for all e-mails sent by your application to be sent from 52 | | the same address. Here, you may specify a name and address that is 53 | | used globally for all e-mails that are sent by your application. 54 | | 55 | */ 56 | 57 | 'from' => ['address' => 'noreply@jacurtis.com', 'name' => 'Laravel Application'], 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | E-Mail Encryption Protocol 62 | |-------------------------------------------------------------------------- 63 | | 64 | | Here you may specify the encryption protocol that should be used when 65 | | the application send e-mail messages. A sensible default using the 66 | | transport layer security protocol should provide great security. 67 | | 68 | */ 69 | 70 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 71 | 72 | /* 73 | |-------------------------------------------------------------------------- 74 | | SMTP Server Username 75 | |-------------------------------------------------------------------------- 76 | | 77 | | If your SMTP server requires a username for authentication, you should 78 | | set it here. This will get used to authenticate with your server on 79 | | connection. You may also set the "password" value below this one. 80 | | 81 | */ 82 | 83 | 'username' => env('MAIL_USERNAME'), 84 | 85 | /* 86 | |-------------------------------------------------------------------------- 87 | | SMTP Server Password 88 | |-------------------------------------------------------------------------- 89 | | 90 | | Here you may set the password required by your SMTP server to send out 91 | | messages from your application. This will be given to the server on 92 | | connection so that the application will be able to send messages. 93 | | 94 | */ 95 | 96 | 'password' => env('MAIL_PASSWORD'), 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Sendmail System Path 101 | |-------------------------------------------------------------------------- 102 | | 103 | | When using the "sendmail" driver to send e-mails, we will need to know 104 | | the path to where Sendmail lives on this server. A default path has 105 | | been provided here, which will work well on most of your systems. 106 | | 107 | */ 108 | 109 | 'sendmail' => '/usr/sbin/sendmail -bs', 110 | 111 | ]; 112 | -------------------------------------------------------------------------------- /config/purifier.php: -------------------------------------------------------------------------------- 1 | set('Core.Encoding', $this->config->get('purifier.encoding')); 7 | * $config->set('Cache.SerializerPath', $this->config->get('purifier.cachePath')); 8 | * if ( ! $this->config->get('purifier.finalize')) { 9 | * $config->autoFinalize = false; 10 | * } 11 | * $config->loadArray($this->getConfig()); 12 | * 13 | * You must NOT delete the default settings 14 | * anything in settings should be compacted with params that needed to instance HTMLPurifier_Config. 15 | * 16 | * @link http://htmlpurifier.org/live/configdoc/plain.html 17 | */ 18 | 19 | return [ 20 | 'encoding' => 'UTF-8', 21 | 'finalize' => true, 22 | 'cachePath' => storage_path('app/purifier'), 23 | 'cacheFileMode' => 0755, 24 | 'settings' => [ 25 | 'default' => [ 26 | 'HTML.Doctype' => 'XHTML 1.0 Strict', 27 | 'HTML.Allowed' => 'div,b,strong,i,em,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src],h1,h2,h3,h4,h5,h6', 28 | 'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align', 29 | 'AutoFormat.AutoParagraph' => false, 30 | 'AutoFormat.RemoveEmpty' => true, 31 | ], 32 | 'test' => [ 33 | 'Attr.EnableID' => true 34 | ], 35 | "youtube" => [ 36 | "HTML.SafeIframe" => 'true', 37 | "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%", 38 | ], 39 | ], 40 | 41 | ]; 42 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_DRIVER', 'sync'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Queue Connections 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may configure the connection information for each server that 27 | | is used by your application. A default configuration has been added 28 | | for each back-end shipped with Laravel. You are free to add more. 29 | | 30 | */ 31 | 32 | 'connections' => [ 33 | 34 | 'sync' => [ 35 | 'driver' => 'sync', 36 | ], 37 | 38 | 'database' => [ 39 | 'driver' => 'database', 40 | 'table' => 'jobs', 41 | 'queue' => 'default', 42 | 'expire' => 60, 43 | ], 44 | 45 | 'beanstalkd' => [ 46 | 'driver' => 'beanstalkd', 47 | 'host' => 'localhost', 48 | 'queue' => 'default', 49 | 'ttr' => 60, 50 | ], 51 | 52 | 'sqs' => [ 53 | 'driver' => 'sqs', 54 | 'key' => 'your-public-key', 55 | 'secret' => 'your-secret-key', 56 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', 57 | 'queue' => 'your-queue-name', 58 | 'region' => 'us-east-1', 59 | ], 60 | 61 | 'redis' => [ 62 | 'driver' => 'redis', 63 | 'connection' => 'default', 64 | 'queue' => 'default', 65 | 'expire' => 60, 66 | ], 67 | 68 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Failed Queue Jobs 73 | |-------------------------------------------------------------------------- 74 | | 75 | | These options configure the behavior of failed queue job logging so you 76 | | can control which database and table are used to store the jobs that 77 | | have failed. You may change them to any database / table you wish. 78 | | 79 | */ 80 | 81 | 'failed' => [ 82 | 'database' => env('DB_CONNECTION', 'mysql'), 83 | 'table' => 'failed_jobs', 84 | ], 85 | 86 | ]; 87 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | ], 21 | 22 | 'mandrill' => [ 23 | 'secret' => env('MANDRILL_SECRET'), 24 | ], 25 | 26 | 'ses' => [ 27 | 'key' => env('SES_KEY'), 28 | 'secret' => env('SES_SECRET'), 29 | 'region' => 'us-east-1', 30 | ], 31 | 32 | 'stripe' => [ 33 | 'model' => App\User::class, 34 | 'key' => env('STRIPE_KEY'), 35 | 'secret' => env('STRIPE_SECRET'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Session Lifetime 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify the number of minutes that you wish the session 27 | | to be allowed to remain idle before it expires. If you want them 28 | | to immediately expire on the browser closing, set that option. 29 | | 30 | */ 31 | 32 | 'lifetime' => 120, 33 | 34 | 'expire_on_close' => false, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Session Encryption 39 | |-------------------------------------------------------------------------- 40 | | 41 | | This option allows you to easily specify that all of your session data 42 | | should be encrypted before it is stored. All encryption will be run 43 | | automatically by Laravel and you can use the Session like normal. 44 | | 45 | */ 46 | 47 | 'encrypt' => false, 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Session File Location 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When using the native session driver, we need a location where session 55 | | files may be stored. A default has been set for you but a different 56 | | location may be specified. This is only needed for file sessions. 57 | | 58 | */ 59 | 60 | 'files' => storage_path('framework/sessions'), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Session Database Connection 65 | |-------------------------------------------------------------------------- 66 | | 67 | | When using the "database" or "redis" session drivers, you may specify a 68 | | connection that should be used to manage these sessions. This should 69 | | correspond to a connection in your database configuration options. 70 | | 71 | */ 72 | 73 | 'connection' => null, 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Session Database Table 78 | |-------------------------------------------------------------------------- 79 | | 80 | | When using the "database" session driver, you may specify the table we 81 | | should use to manage the sessions. Of course, a sensible default is 82 | | provided for you; however, you are free to change this as needed. 83 | | 84 | */ 85 | 86 | 'table' => 'sessions', 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Session Sweeping Lottery 91 | |-------------------------------------------------------------------------- 92 | | 93 | | Some session drivers must manually sweep their storage location to get 94 | | rid of old sessions from storage. Here are the chances that it will 95 | | happen on a given request. By default, the odds are 2 out of 100. 96 | | 97 | */ 98 | 99 | 'lottery' => [2, 100], 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Session Cookie Name 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Here you may change the name of the cookie used to identify a session 107 | | instance by ID. The name specified here will get used every time a 108 | | new session cookie is created by the framework for every driver. 109 | | 110 | */ 111 | 112 | 'cookie' => 'laravel_session', 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Session Cookie Path 117 | |-------------------------------------------------------------------------- 118 | | 119 | | The session cookie path determines the path for which the cookie will 120 | | be regarded as available. Typically, this will be the root path of 121 | | your application but you are free to change this when necessary. 122 | | 123 | */ 124 | 125 | 'path' => '/', 126 | 127 | /* 128 | |-------------------------------------------------------------------------- 129 | | Session Cookie Domain 130 | |-------------------------------------------------------------------------- 131 | | 132 | | Here you may change the domain of the cookie used to identify a session 133 | | in your application. This will determine which domains the cookie is 134 | | available to in your application. A sensible default has been set. 135 | | 136 | */ 137 | 138 | 'domain' => null, 139 | 140 | /* 141 | |-------------------------------------------------------------------------- 142 | | HTTPS Only Cookies 143 | |-------------------------------------------------------------------------- 144 | | 145 | | By setting this option to true, session cookies will only be sent back 146 | | to the server if the browser has a HTTPS connection. This will keep 147 | | the cookie from being sent to you if it can not be done securely. 148 | | 149 | */ 150 | 151 | 'secure' => false, 152 | 153 | ]; 154 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | realpath(base_path('resources/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 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /database/factories/ModelFactory.php: -------------------------------------------------------------------------------- 1 | define(App\User::class, function (Faker\Generator $faker) { 15 | return [ 16 | 'name' => $faker->name, 17 | 'email' => $faker->email, 18 | 'password' => bcrypt(str_random(10)), 19 | 'remember_token' => str_random(10), 20 | ]; 21 | }); 22 | 23 | $factory->define(App\Category::class, function (Faker\Generator $faker) { 24 | return [ 25 | 'name' => $faker->name, 26 | ]; 27 | }); 28 | 29 | $factory->define(App\Post::class, function (Faker\Generator $faker) { 30 | return [ 31 | 'title' => $faker->sentence, 32 | 'body' => $faker->paragraph, 33 | 'slug' => $faker->slug, 34 | // 'image'=> $faker->imageUrl, 35 | 'category_id'=> $faker->randomDigitNotNull, 36 | ]; 37 | }); 38 | 39 | $factory->define(App\Book::class, function (Faker\Generator $faker) { 40 | return [ 41 | 'name' => $faker->name, 42 | 'price'=> $faker->randomDigitNotNull, 43 | ]; 44 | }); 45 | -------------------------------------------------------------------------------- /database/migrations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunpalekar/php-ci-cd/0bfa7420b97efde6e33c8690e59e02858d94c5b2/database/migrations/.gitkeep -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->string('email')->unique(); 19 | $table->string('password', 60); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::drop('users'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 17 | $table->string('token')->index(); 18 | $table->timestamp('created_at'); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('password_resets'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_02_06_175142_create_posts_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('title'); 18 | $table->text('body'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::drop('posts'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2016_03_20_162017_add_slug_to_users.php: -------------------------------------------------------------------------------- 1 | string('slug')->unique()->after('body'); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | * 23 | * @return void 24 | */ 25 | public function down() 26 | { 27 | Schema::table('posts', function($table) { 28 | $table->dropColumn('slug'); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_04_28_021908_create_categories_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('categories'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_04_28_022255_add_category_id_to_posts.php: -------------------------------------------------------------------------------- 1 | integer('category_id')->nullable()->after('slug')->unsigned(); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | * 23 | * @return void 24 | */ 25 | public function down() 26 | { 27 | Schema::table('posts', function (Blueprint $table) { 28 | $table->dropColumn('category_id'); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_05_30_153615_create_tags_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('tags'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_05_30_155417_create_post_tag_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->integer('post_id')->unsigned(); 18 | $table->foreign('post_id')->references('id')->on('posts'); 19 | 20 | $table->integer('tag_id')->unsigned(); 21 | $table->foreign('tag_id')->references('id')->on('tags'); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::drop('post_tag'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2016_07_16_173641_create_comments_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->string('email'); 19 | $table->text('comment'); 20 | $table->boolean('approved'); 21 | $table->integer('post_id')->unsigned(); 22 | $table->timestamps(); 23 | }); 24 | 25 | Schema::table('comments', function ($table){ 26 | $table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade'); 27 | }); 28 | } 29 | 30 | /** 31 | * Reverse the migrations. 32 | * 33 | * @return void 34 | */ 35 | public function down() 36 | { 37 | Schema::dropForeign(['post_id']); 38 | Schema::drop('comments'); 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /database/migrations/2016_08_15_000718_add_image_col_to_posts.php: -------------------------------------------------------------------------------- 1 | string('image')->nullable()->after('slug'); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | * 23 | * @return void 24 | */ 25 | public function down() 26 | { 27 | Schema::table('posts', function (Blueprint $table) { 28 | $table->dropColumn('image'); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2019_06_28_133124_create_books_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->integer('price'); 19 | $table->integer('user_id')->unsigned(); 20 | $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::drop('books'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/seeds/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunpalekar/php-ci-cd/0bfa7420b97efde6e33c8690e59e02858d94c5b2/database/seeds/.gitkeep -------------------------------------------------------------------------------- /database/seeds/BookTableSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /database/seeds/CategoryTableSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UserTableSeeder::class); 18 | 19 | $this->call([ 20 | UsersTableSeeder::class, 21 | CategoryTableSeeder::class, 22 | PostsTableSeeder::class, 23 | ]); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /database/seeds/PostsTableSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 15 | factory(App\Post::class, 10)->create(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /database/seeds/UsersTableSeeder.php: -------------------------------------------------------------------------------- 1 | create()->each(function ($user) { 15 | // $user->posts()->save(factory(App\Post::class)->make()); 16 | //}); 17 | 18 | factory(App\User::class, 10)->create(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /docker-compose.local.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | # Nginx web server 5 | webserver: 6 | image: nginx:alpine 7 | container_name: webserver 8 | restart: unless-stopped 9 | tty: true 10 | ports: 11 | - "80:80" 12 | - "443:443" 13 | volumes: 14 | - ./:/var/www 15 | - ./docker/nginx/conf.d/:/etc/nginx/conf.d/ 16 | networks: 17 | - app-network 18 | 19 | # PHP-fpm server 20 | app: 21 | build: 22 | context: . 23 | dockerfile: Dockerfile 24 | image: varun/laravel-php-fpm 25 | container_name: app 26 | restart: unless-stopped 27 | tty: true 28 | environment: 29 | SERVICE_NAME: app 30 | SERVICE_TAGS: dev 31 | TERM: xterm 32 | APP_ENV: local 33 | XDEBUG_CONFIG: idekey=PHPSTORM 34 | working_dir: /var/www 35 | volumes: 36 | - ./:/var/www 37 | - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini 38 | networks: 39 | - app-network 40 | 41 | ## MYSQL db 42 | db: 43 | image: mysql:5.7.22 44 | container_name: db 45 | restart: unless-stopped 46 | tty: true 47 | # ports: 48 | # - "3306:3306" 49 | volumes: 50 | - ./docker-data/mysql:/var/lib/mysql 51 | - ./docker/mysql/my.cnf:/etc/mysql/my.cnf 52 | environment: 53 | MYSQL_DATABASE: laravel 54 | MYSQL_ROOT_PASSWORD: your_mysql_root_password 55 | SERVICE_TAGS: dev 56 | SERVICE_NAME: mysql 57 | networks: 58 | - app-network 59 | 60 | phpmyadmin: 61 | image: phpmyadmin/phpmyadmin 62 | restart: always 63 | environment: 64 | PMA_HOST: db 65 | ports: 66 | - 8001:80 67 | networks: 68 | - app-network 69 | 70 | # # You can enable this if don't want to host jaeger outside 71 | jaeger: 72 | # container_name: laravel_jaeger 73 | image: jaegertracing/all-in-one:1.6 74 | restart: always 75 | ports: 76 | # - 5775:5775/udp 77 | - 6831:6831/udp 78 | - 6832:6832/udp 79 | # - 5778:5778 80 | - 16686:16686 81 | # - 14268:14268 82 | # - 9411:9411 83 | environment: 84 | COLLECTOR_ZIPKIN_HTTP_PORT: 9411 85 | networks: 86 | - app-network 87 | 88 | networks: 89 | app-network: 90 | driver: bridge 91 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | # Nginx web server 5 | webserver: 6 | image: nginx:alpine 7 | container_name: webserver 8 | restart: unless-stopped 9 | tty: true 10 | networks: 11 | - app-network 12 | 13 | # PHP-fpm server 14 | app: 15 | build: 16 | context: . 17 | dockerfile: Dockerfile 18 | image: varun/laravel-php-fpm 19 | container_name: app 20 | restart: unless-stopped 21 | tty: true 22 | working_dir: /var/www 23 | networks: 24 | - app-network 25 | 26 | networks: 27 | app-network: 28 | driver: bridge 29 | -------------------------------------------------------------------------------- /docker-local.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | docker-compose -f docker-compose.yml -f docker-compose.local.yml $@ -------------------------------------------------------------------------------- /docker/mysql/my.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | general_log = 1 3 | general_log_file = /var/lib/mysql/general.log 4 | -------------------------------------------------------------------------------- /docker/nginx/conf.d/laravel.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | index index.php index.html; 4 | error_log /var/log/nginx/error.log; 5 | access_log /var/log/nginx/access.log; 6 | root /var/www/public; 7 | location ~ \.php$ { 8 | try_files $uri =404; 9 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 10 | fastcgi_pass app:9000; 11 | fastcgi_index index.php; 12 | include fastcgi_params; 13 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 14 | fastcgi_param PATH_INFO $fastcgi_path_info; 15 | } 16 | location / { 17 | try_files $uri $uri/ /index.php?$query_string; 18 | gzip_static on; 19 | } 20 | } -------------------------------------------------------------------------------- /docker/opencensus/agent.yml: -------------------------------------------------------------------------------- 1 | receivers: 2 | jaeger: 3 | collector_thrift_port: 14267 4 | collector_http_port: 14268 -------------------------------------------------------------------------------- /docker/opencensus/collector.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunpalekar/php-ci-cd/0bfa7420b97efde6e33c8690e59e02858d94c5b2/docker/opencensus/collector.yml -------------------------------------------------------------------------------- /docker/php/local.ini: -------------------------------------------------------------------------------- 1 | upload_max_filesize=40M 2 | post_max_size=40M 3 | extension=opencensus.so 4 | log_errors=on -------------------------------------------------------------------------------- /docker/prometheus/prometheus.yml: -------------------------------------------------------------------------------- 1 | scrape_configs: 2 | # Scrape Prometheus itself every 5 seconds. 3 | - job_name: 'prometheus' 4 | scrape_interval: 5s 5 | static_configs: 6 | - targets: 7 | - localhost:9090 8 | 9 | # Scrape the Node Exporter every 5 seconds. 10 | - job_name: 'jaeger' 11 | scrape_interval: 5s 12 | static_configs: 13 | - targets: 14 | - jaeger:16686 15 | - job_name: nginx 16 | scrape_interval: 5s 17 | static_configs: 18 | - targets: 19 | - nginx_exporter:9113 -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var elixir = require('laravel-elixir'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Elixir Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Elixir provides a clean, fluent API for defining some basic Gulp tasks 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for our application, as well as publishing vendor resources. 11 | | 12 | */ 13 | 14 | elixir(function(mix) { 15 | mix.sass('app.scss'); 16 | }); 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "devDependencies": { 4 | "gulp": "^3.8.8" 5 | }, 6 | "dependencies": { 7 | "laravel-elixir": "^4.0.0", 8 | "bootstrap-sass": "^3.0.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/ 14 | 15 | 16 | 17 | 18 | app/ 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | Options +FollowSymLinks 2 | RewriteEngine On 3 | 4 | RewriteCond %{REQUEST_FILENAME} !-d 5 | RewriteCond %{REQUEST_FILENAME} !-f 6 | RewriteRule ^ index.php [L] -------------------------------------------------------------------------------- /public/css/parsley.css: -------------------------------------------------------------------------------- 1 | input.parsley-success, 2 | select.parsley-success, 3 | textarea.parsley-success { 4 | color: #468847; 5 | background-color: #DFF0D8; 6 | border: 1px solid #D6E9C6; 7 | } 8 | 9 | input.parsley-error, 10 | select.parsley-error, 11 | textarea.parsley-error { 12 | color: #B94A48; 13 | background-color: #F2DEDE; 14 | border: 1px solid #EED3D7; 15 | } 16 | 17 | .parsley-errors-list { 18 | margin: 2px 0 3px; 19 | padding: 0; 20 | list-style-type: none; 21 | font-size: 0.9em; 22 | line-height: 0.9em; 23 | opacity: 0; 24 | 25 | transition: all .3s ease-in; 26 | -o-transition: all .3s ease-in; 27 | -moz-transition: all .3s ease-in; 28 | -webkit-transition: all .3s ease-in; 29 | } 30 | 31 | .parsley-errors-list.filled { 32 | opacity: 1; 33 | } 34 | -------------------------------------------------------------------------------- /public/css/select2.min.css: -------------------------------------------------------------------------------- 1 | .select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb} 2 | -------------------------------------------------------------------------------- /public/css/styles.css: -------------------------------------------------------------------------------- 1 | .btn-h1-spacing { 2 | margin-top: 18px; 3 | } 4 | 5 | .form-spacing-top { 6 | margin-top: 30px; 7 | } 8 | 9 | .comment { 10 | margin-bottom: 45px; 11 | } 12 | 13 | .author-image { 14 | width: 50px; 15 | height: 50px; 16 | border-radius: 50%; 17 | float: left; 18 | } 19 | 20 | .author-name { 21 | float: left; 22 | margin-left: 15px; 23 | } 24 | 25 | .author-name>h4 { 26 | margin: 5px 0px; 27 | 28 | } 29 | 30 | .author-time { 31 | font-size: 11px; 32 | font-style: italic; 33 | color: #aaa; 34 | } 35 | 36 | .comment-content { 37 | clear: both; 38 | margin-left: 65px; 39 | font-size: 16px; 40 | line-height: 1.3em; 41 | } 42 | 43 | .comments-title { 44 | margin-bottom:45px; 45 | } 46 | 47 | .comments-title>span { 48 | margin-right: 15px; 49 | } 50 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunpalekar/php-ci-cd/0bfa7420b97efde6e33c8690e59e02858d94c5b2/public/favicon.ico -------------------------------------------------------------------------------- /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 nice 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 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Introduction 2 | =========== 3 | 4 | This repository shows complete CI/CD of sample PHP project. We are going to use following tools/technologies: 5 | 6 | 1. Jenkins: For integration various tools and technologies 7 | 2. PHP project in Laravel: We are having one blog project by using PHP laravel framework 8 | 3. Ansible: For deployment on dev and prod 9 | 4. Docker with docker-compose: For using deployment on local, dev and prod env 10 | 5. Sonarqube: Using sonarqube.io server of static code analysis and code coverage report 11 | 6. Branching: Following git-flow branching strategy 12 | 7. Using opencensus for distributed tracing 13 | 14 | Folder structure 15 | ================ 16 | 17 | ``` 18 | ├── ansible => ansible folder 19 | │   ├── hosts-dev => ansible hosts file for dev 20 | │   ├── hosts-prod => ansible hosts file for prod 21 | │   ├── playbook.yml => ansible playbook 22 | │   ├── requirements.yml => ansible-galaxy requirement file for other role 23 | │   ├── roles => ansible role folder 24 | │   │   └── deployment => ansible main role for deployment 25 | │   ├── vagrant => vagrant file need to share if you are using vagrant 26 | │   ├── Vagrantfile => vagrantfile for creating dev and prod env if you want to create in an automated way 27 | │   └── vars => ansible folder having some extra variable 28 | │   ├── dev.yml => ansible variable file for dev env 29 | │   └── prod.yml => ansible variable file for prod env 30 | ├── app => Laravel app folder 31 | ├── artisan => Laravel artisan file 32 | ├── bootstrap => Laravel bootstrap folder 33 | ├── composer.json => PHP composer file 34 | ├── composer.lock => PHP composer lock file 35 | ├── config => Laravel config folder 36 | ├── database => Laravel database folder 37 | │   ├── factories => Laravel factories folder which used for seeding 38 | │   │   └── ModelFactory.php 39 | │   ├── migrations => Laravel migration folder used for database migration 40 | │   │   ├── 2014_10_12_000000_create_users_table.php 41 | │   │   ├── 2014_10_12_100000_create_password_resets_table.php 42 | │   │   ├── 2016_02_06_175142_create_posts_table.php 43 | │   │   ├── 2016_03_20_162017_add_slug_to_users.php 44 | │   │   ├── 2016_04_28_021908_create_categories_table.php 45 | │   │   ├── 2016_04_28_022255_add_category_id_to_posts.php 46 | │   │   ├── 2016_05_30_153615_create_tags_table.php 47 | │   │   ├── 2016_05_30_155417_create_post_tag_table.php 48 | │   │   ├── 2016_07_16_173641_create_comments_table.php 49 | │   │   ├── 2016_08_15_000718_add_image_col_to_posts.php 50 | │   │   └── 2019_06_28_133124_create_books_table.php 51 | │   └── seeds => Laravel seeds folder used for database seeding 52 | │   ├── BookTableSeeder.php 53 | │   ├── CategoryTableSeeder.php 54 | │   ├── DatabaseSeeder.php 55 | │   ├── PostsTableSeeder.php 56 | │   └── UsersTableSeeder.php 57 | ├── docker => Folder contains some configuration file used by docker container 58 | │   ├── mysql 59 | │   │   └── my.cnf => default configuration file for mysql used in local and dev env only, in prodution we prefer to use standalone managed mysql database 60 | │   ├── nginx 61 | │   │   └── conf.d 62 | │   │   └── laravel.conf => Nginx configuration used for docker container (all env) 63 | │   ├── php 64 | │   │   └── local.ini => Php configuration used for docker container (all env) 65 | ├── docker-compose.local.yml => Docker-compose override file for local deployment using docker 66 | ├── docker-compose.yml => Default docker-compose file shared by all env 67 | ├── Dockerfile => Dockerfile used to build default php application docker container 68 | ├── gulpfile.js => Laravel gulpfile 69 | ├── Jenkinsfile => Jenkinsfile in which all CI/CD defined for this project 70 | ├── package.json => Default composer package.json 71 | ├── phpunit.xml 72 | ├── public => Laravel public folder 73 | ├── resources => Laravel resources folder 74 | ├── server.php => Laravel server file 75 | ├── sonar-project.properties => sonar-scanner properties file related to project 76 | ├── storage => Laravel storage folder 77 | └── tests => Php unit test folder 78 | ``` 79 | 80 | Jenkins 81 | ======= 82 | 83 | You can directly use jenkinsfile for all CI/CD. I am suggesting to use jenkins ocean blue to add pipeline by git project simply. Just go to new pipeline and add by using git URL. 84 | 85 | Deployment 86 | ========== 87 | 88 | ### Local deployment 89 | 90 | 1. Requirement: 91 | 1. docker 92 | 2. docker-compose 93 | 3. php-cli with composer 94 | 95 | 2. Deployment 96 | 97 | Run following command to deploy the project on local system by using docker-compose 98 | 99 | ``` 100 | docker-compose -f docker-compose.yml -f docker-compose.local.yml up -d 101 | ``` 102 | 103 | 3. Install project dependencies 104 | 105 | ``` 106 | composer install 107 | ``` 108 | 109 | 4. Run migration 110 | 111 | ``` 112 | docker-compose -f docker-compose.yml -f docker-compose.local.yml exec app php artisan migrate 113 | ``` 114 | 115 | 5. Run seeding 116 | 117 | ``` 118 | docker-compose -f docker-compose.yml -f docker-compose.local.yml exec app php db:seed --class=UsersTableSeeder 119 | docker-compose -f docker-compose.yml -f docker-compose.local.yml exec app php db:seed --class=PostsTableSeeder 120 | docker-compose -f docker-compose.yml -f docker-compose.local.yml exec app php db:seed --class=PostsTableSeeder 121 | 122 | ``` 123 | 124 | 6. Application access 125 | 126 | Now you can access your application by using URL `http://localhost/` 127 | 128 | 7. Distributed tracing in Jaeger UI 129 | 130 | You can access Jaeger UI to see distributed tracing of you running application `http://localhost:16686` 131 | 132 | ### Dev deployment 133 | 134 | Please use jenkins-pipeline for deployment on dev. 135 | 136 | We are using ansible for deployment on dev. Please change `ansible/hosts-dev` for changing deployment node for dev. By default it run ansible playbook on all hosts. 137 | 138 | ### Prod deployment 139 | 140 | Please use jenkins-pipeline for deployment on prod 141 | 142 | We are using ansible for deployment on dev. Please change `ansible/hosts-prod` for changing deployment node for dev. By default it run ansible playbook on all hosts. 143 | -------------------------------------------------------------------------------- /resources/assets/sass/app.scss: -------------------------------------------------------------------------------- 1 | // @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap"; 2 | 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => 'The :attribute is not a valid URL.', 18 | 'after' => 'The :attribute must be a date after :date.', 19 | 'alpha' => 'The :attribute may only contain letters.', 20 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', 21 | 'alpha_num' => 'The :attribute may only contain letters and numbers.', 22 | 'array' => 'The :attribute must be an array.', 23 | 'before' => 'The :attribute must be a date before :date.', 24 | 'between' => [ 25 | 'numeric' => 'The :attribute must be between :min and :max.', 26 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 27 | 'string' => 'The :attribute must be between :min and :max characters.', 28 | 'array' => 'The :attribute must have between :min and :max items.', 29 | ], 30 | 'boolean' => 'The :attribute field must be true or false.', 31 | 'confirmed' => 'The :attribute confirmation does not match.', 32 | 'date' => 'The :attribute is not a valid date.', 33 | 'date_format' => 'The :attribute does not match the format :format.', 34 | 'different' => 'The :attribute and :other must be different.', 35 | 'digits' => 'The :attribute must be :digits digits.', 36 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 37 | 'email' => 'The :attribute must be a valid email address.', 38 | 'exists' => 'The selected :attribute is invalid.', 39 | 'filled' => 'The :attribute field is required.', 40 | 'image' => 'The :attribute must be an image.', 41 | 'in' => 'The selected :attribute is invalid.', 42 | 'integer' => 'The :attribute must be an integer.', 43 | 'ip' => 'The :attribute must be a valid IP address.', 44 | 'json' => 'The :attribute must be a valid JSON string.', 45 | 'max' => [ 46 | 'numeric' => 'The :attribute may not be greater than :max.', 47 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 48 | 'string' => 'The :attribute may not be greater than :max characters.', 49 | 'array' => 'The :attribute may not have more than :max items.', 50 | ], 51 | 'mimes' => 'The :attribute must be a file of type: :values.', 52 | 'min' => [ 53 | 'numeric' => 'The :attribute must be at least :min.', 54 | 'file' => 'The :attribute must be at least :min kilobytes.', 55 | 'string' => 'The :attribute must be at least :min characters.', 56 | 'array' => 'The :attribute must have at least :min items.', 57 | ], 58 | 'not_in' => 'The selected :attribute is invalid.', 59 | 'numeric' => 'The :attribute must be a number.', 60 | 'regex' => 'The :attribute format is invalid.', 61 | 'required' => 'The :attribute field is required.', 62 | 'required_if' => 'The :attribute field is required when :other is :value.', 63 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 64 | 'required_with' => 'The :attribute field is required when :values is present.', 65 | 'required_with_all' => 'The :attribute field is required when :values is present.', 66 | 'required_without' => 'The :attribute field is required when :values is not present.', 67 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 68 | 'same' => 'The :attribute and :other must match.', 69 | 'size' => [ 70 | 'numeric' => 'The :attribute must be :size.', 71 | 'file' => 'The :attribute must be :size kilobytes.', 72 | 'string' => 'The :attribute must be :size characters.', 73 | 'array' => 'The :attribute must contain :size items.', 74 | ], 75 | 'string' => 'The :attribute must be a string.', 76 | 'timezone' => 'The :attribute must be a valid zone.', 77 | 'unique' => 'The :attribute has already been taken.', 78 | 'url' => 'The :attribute format is invalid.', 79 | 80 | /* 81 | |-------------------------------------------------------------------------- 82 | | Custom Validation Language Lines 83 | |-------------------------------------------------------------------------- 84 | | 85 | | Here you may specify custom validation messages for attributes using the 86 | | convention "attribute.rule" to name the lines. This makes it quick to 87 | | specify a specific custom language line for a given attribute rule. 88 | | 89 | */ 90 | 91 | 'custom' => [ 92 | 'attribute-name' => [ 93 | 'rule-name' => 'custom-message', 94 | ], 95 | ], 96 | 97 | /* 98 | |-------------------------------------------------------------------------- 99 | | Custom Validation Attributes 100 | |-------------------------------------------------------------------------- 101 | | 102 | | The following language lines are used to swap attribute place-holders 103 | | with something more reader friendly such as E-Mail Address instead 104 | | of "email". This simply helps us make messages a little cleaner. 105 | | 106 | */ 107 | 108 | 'attributes' => [], 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /resources/views/auth/emails/password.blade.php: -------------------------------------------------------------------------------- 1 | Click Here to Reset your Password:
2 | {{ $link }} -------------------------------------------------------------------------------- /resources/views/auth/login.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Login') 4 | 5 | @section('content') 6 | 7 |
8 |
9 | {!! Form::open() !!} 10 | 11 | {{ Form::label('email', 'Email:') }} 12 | {{ Form::email('email', null, ['class' => 'form-control']) }} 13 | 14 | {{ Form::label('password', "Password:") }} 15 | {{ Form::password('password', ['class' => 'form-control']) }} 16 | 17 |
18 | {{ Form::checkbox('remember') }}{{ Form::label('remember', "Remember Me") }} 19 | 20 |
21 | {{ Form::submit('Login', ['class' => 'btn btn-primary btn-block']) }} 22 | 23 |

Forgot My Password 24 | 25 | 26 | {!! Form::close() !!} 27 |

28 |
29 | 30 | @endsection -------------------------------------------------------------------------------- /resources/views/auth/passwords/email.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Forgot my Password') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |
10 |
Reset Password
11 | 12 |
13 | @if (session('status')) 14 |
15 | {{ session('status') }} 16 |
17 | @endif 18 | 19 | {!! Form::open(['url' => 'password/email', 'method' => "POST"]) !!} 20 | 21 | {{ Form::label('email', 'Email Address:') }} 22 | {{ Form::email('email', null, ['class' => 'form-control']) }} 23 | 24 | {{ Form::submit('Reset Password', ['class' => 'btn btn-primary']) }} 25 | 26 | {{ Form::close() }} 27 | 28 |
29 |
30 |
31 |
32 | 33 | @endsection -------------------------------------------------------------------------------- /resources/views/auth/passwords/reset.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Forgot my Password') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |
10 |
Reset Password
11 | 12 |
13 | 14 | {!! Form::open(['url' => 'password/reset', 'method' => "POST"]) !!} 15 | 16 | {{ Form::hidden('token', $token) }} 17 | 18 | {{ Form::label('email', 'Email Address:') }} 19 | {{ Form::email('email', $email, ['class' => 'form-control']) }} 20 | 21 | {{ Form::label('password', 'New Password:') }} 22 | {{ Form::password('password', ['class' => 'form-control']) }} 23 | 24 | {{ Form::label('password_confirmation', 'Confirm New Password:') }} 25 | {{ Form::password('password_confirmation', ['class' => 'form-control']) }} 26 | 27 | {{ Form::submit('Reset Password', ['class' => 'btn btn-primary']) }} 28 | 29 | {!! Form::close() !!} 30 | 31 |
32 |
33 |
34 |
35 | 36 | @endsection -------------------------------------------------------------------------------- /resources/views/auth/register.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Register') 4 | 5 | @section('content') 6 | 7 |
8 |
9 | {!! Form::open() !!} 10 | 11 | {{ Form::label('name', "Name:") }} 12 | {{ Form::text('name', null, ['class' => 'form-control']) }} 13 | 14 | {{ Form::label('email', 'Email:') }} 15 | {{ Form::email('email', null, ['class' => 'form-control']) }} 16 | 17 | {{ Form::label('password', 'Password:') }} 18 | {{ Form::password('password', ['class' => 'form-control']) }} 19 | 20 | {{ Form::label('password_confirmation', 'Confirm Password:') }} 21 | {{ Form::password('password_confirmation', ['class' => 'form-control']) }} 22 | 23 | {{ Form::submit('Register', ['class' => 'btn btn-primary btn-block form-spacing-top']) }} 24 | 25 | {!! Form::close() !!} 26 |
27 |
28 | 29 | @endsection -------------------------------------------------------------------------------- /resources/views/blog/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Blog') 4 | 5 | @section('content') 6 | 7 | 8 |
9 |
10 |

Blog

11 |
12 |
13 | 14 | @foreach ($posts as $post) 15 |
16 |
17 |

{{ $post->title }}

18 |
Published: {{ date('M j, Y', strtotime($post->created_at)) }}
19 | 20 |

{{ substr(strip_tags($post->body), 0, 250) }}{{ strlen(strip_tags($post->body)) > 250 ? '...' : "" }}

21 | 22 | Read More 23 |
24 |
25 |
26 | @endforeach 27 | 28 |
29 |
30 |
31 | {!! $posts->links() !!} 32 |
33 |
34 |
35 | 36 | 37 | @endsection 38 | -------------------------------------------------------------------------------- /resources/views/blog/single.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | title); ?> 3 | @section('title', "| $titleTag") 4 | 5 | @section('content') 6 | 7 |
8 |
9 | @if(!empty($post->image)) 10 | 11 | @endif 12 |

{{ $post->title }}

13 |

{!! $post->body !!}

14 |
15 |

Posted In: {{ $post->category->name }}

16 |
17 |
18 | 19 |
20 |
21 |

{{ $post->comments()->count() }} Comments

22 | @foreach($post->comments as $comment) 23 |
24 |
25 | 26 | email))) . "?s=50&d=monsterid" }}" class="author-image"> 27 |
28 |

{{ $comment->name }}

29 |

{{ date('F dS, Y - g:iA' ,strtotime($comment->created_at)) }}

30 |
31 | 32 |
33 | 34 |
35 | {{ $comment->comment }} 36 |
37 | 38 |
39 | @endforeach 40 |
41 |
42 | 43 |
44 |
45 | {{ Form::open(['route' => ['comments.store', $post->id], 'method' => 'POST']) }} 46 | 47 |
48 |
49 | {{ Form::label('name', "Name:") }} 50 | {{ Form::text('name', null, ['class' => 'form-control']) }} 51 |
52 | 53 |
54 | {{ Form::label('email', 'Email:') }} 55 | {{ Form::text('email', null, ['class' => 'form-control']) }} 56 |
57 | 58 |
59 | {{ Form::label('comment', "Comment:") }} 60 | {{ Form::textarea('comment', null, ['class' => 'form-control', 'rows' => '5']) }} 61 | 62 | {{ Form::submit('Add Comment', ['class' => 'btn btn-success btn-block', 'style' => 'margin-top:15px;']) }} 63 |
64 |
65 | 66 | {{ Form::close() }} 67 |
68 |
69 | 70 | @endsection 71 | -------------------------------------------------------------------------------- /resources/views/categories/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| All Categories') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

Categories

10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | @foreach ($categories as $category) 20 | 21 | 22 | 23 | 24 | @endforeach 25 | 26 |
#Name
{{ $category->id }}{{ $category->name }}
27 |
28 | 29 |
30 |
31 | {!! Form::open(['route' => 'categories.store', 'method' => 'POST']) !!} 32 |

New Category

33 | {{ Form::label('name', 'Name:') }} 34 | {{ Form::text('name', null, ['class' => 'form-control']) }} 35 | 36 | {{ Form::submit('Create New Category', ['class' => 'btn btn-primary btn-block btn-h1-spacing']) }} 37 | 38 | {!! Form::close() !!} 39 |
40 |
41 |
42 | 43 | @endsection -------------------------------------------------------------------------------- /resources/views/comments/delete.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| DELETE COMMENT?') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

DELETE THIS COMMENT?

10 |

11 | Name: {{ $comment->name }}
12 | Email: {{ $comment->email }}
13 | Comment: {{ $comment->comment }} 14 |

15 | 16 | {{ Form::open(['route' => ['comments.destroy', $comment->id], 'method' => 'DELETE']) }} 17 | {{ Form::submit('YES DELETE THIS COMMENT', ['class' => 'btn btn-lg btn-block btn-danger']) }} 18 | {{ Form::close() }} 19 |
20 |
21 | 22 | @endsection -------------------------------------------------------------------------------- /resources/views/comments/edit.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Edit Comment') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

Edit Comment

10 | 11 | {{ Form::model($comment, ['route' => ['comments.update', $comment->id], 'method' => 'PUT']) }} 12 | 13 | {{ Form::label('name', 'Name:') }} 14 | {{ Form::text('name', null, ['class' => 'form-control', 'disabled' => '']) }} 15 | 16 | {{ Form::label('email', 'Email:') }} 17 | {{ Form::text('email', null, ['class' => 'form-control', 'disabled' => '']) }} 18 | 19 | {{ Form::label('comment', 'Comment:') }} 20 | {{ Form::textarea('comment', null, ['class' => 'form-control']) }} 21 | 22 | {{ Form::submit('Update Comment', ['class' => 'btn btn-block btn-success', 'style' => 'margin-top: 15px;']) }} 23 | 24 | {{ Form::close() }} 25 |
26 |
27 | 28 | @endsection -------------------------------------------------------------------------------- /resources/views/emails/contact.blade.php: -------------------------------------------------------------------------------- 1 |

You Have a New Contact Via the Contact Form

2 | 3 |
4 | {{ $bodyMessage }} 5 |
6 | 7 |

Sent via {{ $email }}

-------------------------------------------------------------------------------- /resources/views/errors/503.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Be right back. 5 | 6 | 7 | 8 | 39 | 40 | 41 |
42 |
43 |
Be right back.
44 |
45 |
46 | 47 | 48 | -------------------------------------------------------------------------------- /resources/views/main.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @include('partials._head') 5 | 6 | 7 | 8 | 9 | @include('partials._nav') 10 | 11 |
12 | @include('partials._messages') 13 | 14 | @yield('content') 15 | 16 | @include('partials._footer') 17 | 18 |
19 | 20 | @include('partials._javascript') 21 | 22 | @yield('scripts') 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /resources/views/pages/about.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| About') 4 | 5 | @section('content') 6 |
7 |
8 |

About Me

9 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis aspernatur quas quibusdam veniam sunt animi, est quos optio explicabo deleniti inventore unde minus, tempore enim ratione praesentium, cumque, dolores nesciunt?

10 |
11 |
12 | 13 | @endsection 14 | -------------------------------------------------------------------------------- /resources/views/pages/contact.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Contact') 4 | 5 | @section('content') 6 |
7 |
8 |

Contact Me

9 |
10 |
11 | {{ csrf_field() }} 12 |
13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 |
21 | 22 |
23 | 24 | 25 |
26 | 27 | 28 |
29 |
30 |
31 | @endsection -------------------------------------------------------------------------------- /resources/views/pages/welcome.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Homepage') 4 | 5 | @section('content') 6 |
7 |
8 |
9 |

Welcome to My Blog!

10 |

Thank you so much for visiting. This is my test website built with Laravel. Please read my popular post!

11 |

Popular Post

12 |
13 |
14 |
15 | 16 |
17 |
18 | 19 | @foreach($posts as $post) 20 | 21 |
22 |

{{ $post->title }}

23 |

{{ substr(strip_tags($post->body), 0, 300) }}{{ strlen(strip_tags($post->body)) > 300 ? "..." : "" }}

24 | Read More 25 |
26 | 27 |
28 | 29 | @endforeach 30 | 31 |
32 | 33 |
34 |

Sidebar

35 |
36 |
37 | @stop -------------------------------------------------------------------------------- /resources/views/partials/_footer.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 |

Copyright asdasdas - All Rights Reserved

-------------------------------------------------------------------------------- /resources/views/partials/_head.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Laravel Blog @yield('title') 7 | 8 | 9 | 10 | {{ Html::style('css/styles.css') }} 11 | 12 | @yield('stylesheets') 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /resources/views/partials/_javascript.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/views/partials/_messages.blade.php: -------------------------------------------------------------------------------- 1 | @if (Session::has('success')) 2 | 3 | 6 | 7 | @endif 8 | 9 | @if (count($errors) > 0) 10 | 11 | 19 | 20 | @endif -------------------------------------------------------------------------------- /resources/views/partials/_nav.blade.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /resources/views/posts/create.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Create New Post') 4 | 5 | @section('stylesheets') 6 | 7 | {!! Html::style('css/parsley.css') !!} 8 | {!! Html::style('css/select2.min.css') !!} 9 | 10 | 11 | 18 | 19 | @endsection 20 | 21 | @section('content') 22 | 23 |
24 |
25 |

Create New Post

26 |
27 | {!! Form::open(array('route' => 'posts.store', 'data-parsley-validate' => '', 'files' => true)) !!} 28 | {{ Form::label('title', 'Title:') }} 29 | {{ Form::text('title', null, array('class' => 'form-control', 'required' => '', 'maxlength' => '255')) }} 30 | 31 | {{ Form::label('slug', 'Slug:') }} 32 | {{ Form::text('slug', null, array('class' => 'form-control', 'required' => '', 'minlength' => '5', 'maxlength' => '255') ) }} 33 | 34 | {{ Form::label('category_id', 'Category:') }} 35 | 41 | 42 | 43 | {{ Form::label('tags', 'Tags:') }} 44 | 50 | 51 | {{ Form::label('featured_img', 'Upload a Featured Image') }} 52 | {{ Form::file('featured_img') }} 53 | 54 | {{ Form::label('body', "Post Body:") }} 55 | {{ Form::textarea('body', null, array('class' => 'form-control')) }} 56 | 57 | {{ Form::submit('Create Post', array('class' => 'btn btn-success btn-lg btn-block', 'style' => 'margin-top: 20px;')) }} 58 | {!! Form::close() !!} 59 |
60 |
61 | 62 | @endsection 63 | 64 | 65 | @section('scripts') 66 | 67 | {!! Html::script('js/parsley.min.js') !!} 68 | {!! Html::script('js/select2.min.js') !!} 69 | 70 | 73 | 74 | @endsection 75 | -------------------------------------------------------------------------------- /resources/views/posts/edit.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| Edit Blog Post') 4 | 5 | @section('stylesheets') 6 | 7 | {!! Html::style('css/select2.min.css') !!} 8 | 9 | 10 | 11 | 18 | 19 | @endsection 20 | 21 | @section('content') 22 | 23 |
24 | {!! Form::model($post, ['route' => ['posts.update', $post->id], 'method' => 'PUT']) !!} 25 |
26 | {{ Form::label('title', 'Title:') }} 27 | {{ Form::text('title', null, ["class" => 'form-control input-lg']) }} 28 | 29 | {{ Form::label('slug', 'Slug:', ['class' => 'form-spacing-top']) }} 30 | {{ Form::text('slug', null, ['class' => 'form-control']) }} 31 | 32 | {{ Form::label('category_id', "Category:", ['class' => 'form-spacing-top']) }} 33 | {{ Form::select('category_id', $categories, null, ['class' => 'form-control']) }} 34 | 35 | {{ Form::label('tags', 'Tags:', ['class' => 'form-spacing-top']) }} 36 | {{ Form::select('tags[]', $tags, null, ['class' => 'form-control select2-multi', 'multiple' => 'multiple']) }} 37 | 38 | {{ Form::label('body', "Body:", ['class' => 'form-spacing-top']) }} 39 | {{ Form::textarea('body', null, ['class' => 'form-control']) }} 40 |
41 | 42 |
43 |
44 |
45 |
Created At:
46 |
{{ date('M j, Y h:ia', strtotime($post->created_at)) }}
47 |
48 | 49 |
50 |
Last Updated:
51 |
{{ date('M j, Y h:ia', strtotime($post->updated_at)) }}
52 |
53 |
54 |
55 |
56 | {!! Html::linkRoute('posts.show', 'Cancel', array($post->id), array('class' => 'btn btn-danger btn-block')) !!} 57 |
58 |
59 | {{ Form::submit('Save Changes', ['class' => 'btn btn-success btn-block']) }} 60 |
61 |
62 | 63 |
64 |
65 | {!! Form::close() !!} 66 |
67 | 68 | @stop 69 | 70 | @section('scripts') 71 | 72 | {!! Html::script('js/select2.min.js') !!} 73 | 74 | 80 | 81 | @endsection -------------------------------------------------------------------------------- /resources/views/posts/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| All Posts') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

All Posts

10 |
11 | 12 |
13 | Create New Post 14 |
15 |
16 |
17 |
18 |
19 | 20 |
21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | @foreach ($posts as $post) 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | @endforeach 44 | 45 | 46 |
#TitleBodyCreated At
{{ $post->id }}{{ $post->title }}{{ substr(strip_tags($post->body), 0, 50) }}{{ strlen(strip_tags($post->body)) > 50 ? "..." : "" }}{{ date('M j, Y', strtotime($post->created_at)) }}View Edit
47 | 48 |
49 | {!! $posts->links(); !!} 50 |
51 |
52 |
53 | 54 | @stop -------------------------------------------------------------------------------- /resources/views/posts/show.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| View Post') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

{{ $post->title }}

10 | 11 |

{!! $post->body !!}

12 | 13 |
14 | 15 |
16 | @foreach ($post->tags as $tag) 17 | {{ $tag->name }} 18 | @endforeach 19 |
20 | 21 |
22 |

Comments {{ $post->comments()->count() }} total

23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | @foreach ($post->comments as $comment) 36 | 37 | 38 | 39 | 40 | 44 | 45 | @endforeach 46 | 47 |
NameEmailComment
{{ $comment->name }}{{ $comment->email }}{{ $comment->comment }} 41 | 42 | 43 |
48 |
49 |
50 | 51 |
52 |
53 |
54 | 55 |

{{ route('blog.single', $post->slug) }}

56 |
57 | 58 |
59 | 60 |

{{ $post->category->name }}

61 |
62 | 63 |
64 | 65 |

{{ date('M j, Y h:ia', strtotime($post->created_at)) }}

66 |
67 | 68 |
69 | 70 |

{{ date('M j, Y h:ia', strtotime($post->updated_at)) }}

71 |
72 |
73 |
74 |
75 | {!! Html::linkRoute('posts.edit', 'Edit', array($post->id), array('class' => 'btn btn-primary btn-block')) !!} 76 |
77 |
78 | {!! Form::open(['route' => ['posts.destroy', $post->id], 'method' => 'DELETE']) !!} 79 | 80 | {!! Form::submit('Delete', ['class' => 'btn btn-danger btn-block']) !!} 81 | 82 | {!! Form::close() !!} 83 |
84 |
85 | 86 |
87 |
88 | {{ Html::linkRoute('posts.index', '<< See All Posts', array(), ['class' => 'btn btn-default btn-block btn-h1-spacing']) }} 89 |
90 |
91 | 92 |
93 |
94 |
95 | 96 | @endsection -------------------------------------------------------------------------------- /resources/views/tags/edit.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', "| Edit Tag") 4 | 5 | @section('content') 6 | 7 | {{ Form::model($tag, ['route' => ['tags.update', $tag->id], 'method' => "PUT"]) }} 8 | 9 | {{ Form::label('name', "Title:") }} 10 | {{ Form::text('name', null, ['class' => 'form-control']) }} 11 | 12 | {{ Form::submit('Save Changes', ['class' => 'btn btn-success', 'style' => 'margin-top:20px;']) }} 13 | {{ Form::close() }} 14 | 15 | @endsection -------------------------------------------------------------------------------- /resources/views/tags/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', '| All Tags') 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

Tags

10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | @foreach ($tags as $tag) 20 | 21 | 22 | 23 | 24 | @endforeach 25 | 26 |
#Name
{{ $tag->id }}{{ $tag->name }}
27 |
28 | 29 |
30 |
31 | {!! Form::open(['route' => 'tags.store', 'method' => 'POST']) !!} 32 |

New Tag

33 | {{ Form::label('name', 'Name:') }} 34 | {{ Form::text('name', null, ['class' => 'form-control']) }} 35 | 36 | {{ Form::submit('Create New Tag', ['class' => 'btn btn-primary btn-block btn-h1-spacing']) }} 37 | 38 | {!! Form::close() !!} 39 |
40 |
41 |
42 | 43 | @endsection -------------------------------------------------------------------------------- /resources/views/tags/show.blade.php: -------------------------------------------------------------------------------- 1 | @extends('main') 2 | 3 | @section('title', "| $tag->name Tag") 4 | 5 | @section('content') 6 | 7 |
8 |
9 |

{{ $tag->name }} Tag {{ $tag->posts()->count() }} Posts

10 |
11 |
12 | Edit 13 |
14 |
15 | {{ Form::open(['route' => ['tags.destroy', $tag->id], 'method' => 'DELETE']) }} 16 | {{ Form::submit('Delete', ['class' => 'btn btn-danger btn-block', 'style' => 'margin-top:20px;']) }} 17 | {{ Form::close() }} 18 |
19 |
20 | 21 |
22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | @foreach ($tag->posts as $post) 35 | 36 | 37 | 38 | 42 | 43 | 44 | @endforeach 45 | 46 |
#TitleTags
{{ $post->id }}{{ $post->title }}@foreach ($post->tags as $tag) 39 | {{ $tag->name }} 40 | @endforeach 41 | View
47 |
48 |
49 | 50 | @endsection -------------------------------------------------------------------------------- /resources/views/vendor/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunpalekar/php-ci-cd/0bfa7420b97efde6e33c8690e59e02858d94c5b2/resources/views/vendor/.gitkeep -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | # Required metadata 2 | sonar.projectKey=php-test 3 | sonar.projectName=php-test 4 | sonar.projectVersion=1.0.0 5 | 6 | # Path to the parent source code directory. 7 | sonar.sources=app 8 | 9 | # Language 10 | # We've commented this out, because we want to analyse both PHP and Javascript 11 | #sonar.language=php 12 | 13 | # Encoding of the source code 14 | sonar.sourceEncoding=UTF-8 15 | 16 | # Reusing PHPUnit reports 17 | sonar.php.coverage.reportPath=reports/codeCoverage.xml 18 | sonar.php.tests.reportPath=reports/junit.xml 19 | 20 | # Here, you can exclude all the directories that you don't want to analyse. 21 | # As an example, I'm excluding the Providers directory 22 | sonar.exclusions=app/Providers/** 23 | 24 | # Additional parameters 25 | #sonar.my.property=value -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | compiled.php 4 | services.json 5 | events.scanned.php 6 | routes.scanned.php 7 | down 8 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/AccessorTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 21 | } 22 | 23 | /** 24 | * Test accessor method 25 | * 26 | * @return void 27 | */ 28 | /*public function testAccessorTest() 29 | { 30 | // load post manually first 31 | $db_post = DB::select('select title from posts where id = 1'); 32 | //echo "
title";
33 |         //print($db_post[0]);
34 |         $db_post_title = ucfirst($db_post[0]->title);
35 |          //exit;
36 |         // load post using Eloquent
37 |         $model_post = Post::find(1);
38 |         $model_post_title = $model_post->title;
39 |          
40 |         $this->assertEquals($db_post_title, $model_post_title);
41 |     }*/
42 | 
43 |     /**
44 |      * A basic test example.
45 |      *
46 |      * @return void
47 |      */
48 |     /*public function testBasicTest()
49 |     {
50 |         // load post manually first
51 |         $db_post = DB::select('select title from posts where id = 1');
52 |         $db_post_title = ucfirst($db_post[0]->title);
53 |  
54 |         //$response = $this->get('http://localhost/laravel_blog/public/accessor/index?id=1');
55 | 
56 |         $response = $this->get('/accessor/index?id=1');
57 |  
58 |         $response->assertStatus(200);
59 |         $response->assertSeeText($db_post_title);
60 |     }*/
61 | }
62 | 


--------------------------------------------------------------------------------
/tests/BasicTest.php:
--------------------------------------------------------------------------------
 1 | assertTrue(true);
17 | 
18 |          
19 |     }
20 | }
21 | 


--------------------------------------------------------------------------------
/tests/BookTest.php:
--------------------------------------------------------------------------------
 1 | assertTrue(true);
18 |     }*/
19 | 
20 |     /* @test */
21 | 
22 |     public function test_book_can_deleted(){
23 |         //$Category =  factory(App\Category::class)->create();
24 | 
25 |       /*  $post = $Category->posts()->create([
26 |             'title' => 'HabbitTest11',
27 |             'body'  => 'HabbitTest11@gmail.com',
28 |             'slug'  =>  str_random(10),
29 |         ]);
30 | 
31 |         $post->delete();
32 |          
33 |         $this->notSeeInDatabase('posts',['id'=>26,'title'=>'HabbitTest11']); 
34 | 
35 |        */ 
36 | 
37 |      // $found_post = Post::find(25);
38 |      // $name = 'Doyle Wunsch';
39 |      // $found_post = Post::where('title', '=', $name)->first();
40 |      // $found_post->delete();
41 |      // $this->notSeeInDatabase('posts',['title'=>'Doyle Wunsch']);
42 | 
43 |       $title = 'Hab_NHlit';
44 |       $found_post = Post::where('title', '=', $title)->first();
45 |       $this->assertEquals($found_post->title,'Hab_NHlit');
46 |         
47 |     }
48 | 
49 |     public function test_book_can_created()
50 |     {
51 |         $Category =  factory(App\Category::class)->create();
52 | 
53 |         $post = $Category->posts()->create([
54 |             'title' => 'Hab_'.str_random(5),
55 |             'body'  => 'This Post is related to'.str_random(20),
56 |             'slug'  =>  str_random(10),
57 | 
58 |             //'title' => 'HabbitTest',
59 |             //'body'  => 'HabbitTest@gmail.com',
60 |             //'slug'  =>  str_random(10),
61 | 
62 |         ]);
63 | 
64 |         //$found_post = Post::find(24);
65 |         //$this->assertEquals($found_post->title,'HabbitTest');
66 |         //$this->seeInDatabase('posts',['id'=>24,'title'=>'HabbitTest']);
67 |     }
68 | 
69 |    
70 | 
71 | 
72 | }
73 | 


--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
 1 | make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
22 | 
23 |          return $app;
24 |     }
25 | }
26 | 


--------------------------------------------------------------------------------
/tests/UserTest.php:
--------------------------------------------------------------------------------
 1 | assertTrue(true);
17 |     }
18 | 
19 |    public function test_user_can_created(){
20 | 
21 |          $User =  factory(App\User::class)->create();
22 | 
23 |          //$post_user = $User->create([
24 |             //'title' => 'Hab_'.str_random(5),
25 |             //'body'  => 'This Post is related to'.str_random(20),
26 |             //'slug'  =>  str_random(10),
27 | 
28 |            // 'name'   => 'Varun',
29 |             //'email'  => 'varun@nitorinfotech.com',
30 |             //'password' => bcrypt('varun'),
31 |            // 'remember_token' => str_random(10),
32 | 
33 | 
34 |          //]);
35 | 
36 |          //$name = 'PrashantNitor';
37 |          //$found_user = User::where('name', '=', $name)->first(); 
38 |         // $this->assertEquals($found_user->name,'PrashantNitor');
39 | 
40 |         //$found_userId = User::find(33);
41 |         //$this->assertEquals($found_userId->name,'PrashantNitor');
42 |         //$this->seeInDatabase('users',['id'=>33,'name'=>'PrashantNitor']);
43 | 
44 |         //$found_userId = User::find(33);
45 |         //$found_userId->delete();
46 |         //$this->notSeeInDatabase('users',['name'=>'PrashantNitor']);
47 |     }
48 | 
49 |     public function test_user_can_deleted(){
50 | 
51 |         //$User =  factory(App\User::class)->create();
52 | 
53 |         
54 | 
55 |           $name = 'PrashantNitor';
56 |           $found_user = User::where('name', '=', $name)->first(); 
57 |           $this->assertEquals($found_user->name,'PrashantNitor');
58 | 
59 |        //$found_userId = User::find(33);
60 |        //$this->assertEquals($found_userId->name,'PrashantNitor');
61 |        //$this->seeInDatabase('users',['id'=>33,'name'=>'PrashantNitor']);
62 | 
63 |        // Search by id and delete
64 | 
65 |        //$found_userId = User::find(40);
66 |        //$found_userId->delete();
67 |        //$this->notSeeInDatabase('users',['name'=>'Varun']);
68 | 
69 |         // Search by name and delete
70 | 
71 |         //$name = 'Asha Rohan';
72 |         //$found_user = User::where('name', '=', $name)->first(); 
73 |         //$this->assertEquals($found_user->name,'Varun');
74 |         //$found_user->delete();
75 |         //$this->notSeeInDatabase('users',['name'=>'Asha Rohan']);
76 |    }
77 | }
78 | 


--------------------------------------------------------------------------------