{{ $post->title }}
23 |{{ substr(strip_tags($post->body), 0, 300) }}{{ strlen(strip_tags($post->body)) > 300 ? "..." : "" }}
24 | Read More 25 |├── .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 |
2 | {{ $link }}
--------------------------------------------------------------------------------
/resources/views/auth/login.blade.php:
--------------------------------------------------------------------------------
1 | @extends('main')
2 |
3 | @section('title', '| Login')
4 |
5 | @section('content')
6 |
7 |
Forgot My Password 24 | 25 | 26 | {!! Form::close() !!} 27 |
{{ substr(strip_tags($post->body), 0, 250) }}{{ strlen(strip_tags($post->body)) > 250 ? '...' : "" }}
21 | 22 | Read More 23 |{!! $post->body !!}
14 |Posted In: {{ $post->category->name }}
16 |# | 14 |Name | 15 |
---|---|
{{ $category->id }} | 22 |{{ $category->name }} | 23 |
11 | Name: {{ $comment->name }}
12 | Email: {{ $comment->email }}
13 | Comment: {{ $comment->comment }}
14 |
Sent via {{ $email }}
-------------------------------------------------------------------------------- /resources/views/errors/503.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |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 |Thank you so much for visiting. This is my test website built with Laravel. Please read my popular post!
11 | 12 |{{ substr(strip_tags($post->body), 0, 300) }}{{ strlen(strip_tags($post->body)) > 300 ? "..." : "" }}
24 | Read More 25 |Copyright asdasdas - All Rights Reserved
-------------------------------------------------------------------------------- /resources/views/partials/_head.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |# | 25 |Title | 26 |Body | 27 |Created At | 28 |29 | 30 | 31 | 32 | 33 | @foreach ($posts as $post) 34 | 35 | |
---|---|---|---|---|
{{ $post->id }} | 37 |{{ $post->title }} | 38 |{{ substr(strip_tags($post->body), 0, 50) }}{{ strlen(strip_tags($post->body)) > 50 ? "..." : "" }} | 39 |{{ date('M j, Y', strtotime($post->created_at)) }} | 40 |View Edit | 41 |
{!! $post->body !!}
12 | 13 |{{ $post->category->name }}
61 |{{ date('M j, Y h:ia', strtotime($post->created_at)) }}
66 |{{ date('M j, Y h:ia', strtotime($post->updated_at)) }}
71 |# | 14 |Name | 15 |
---|---|
{{ $tag->id }} | 22 |{{ $tag->name }} | 23 |
# | 27 |Title | 28 |Tags | 29 |30 | |
---|---|---|---|
{{ $post->id }} | 37 |{{ $post->title }} | 38 |@foreach ($post->tags as $tag) 39 | {{ $tag->name }} 40 | @endforeach 41 | | 42 |View | 43 |
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 | --------------------------------------------------------------------------------
{{ $comment->name }}
29 |{{ date('F dS, Y - g:iA' ,strtotime($comment->created_at)) }}
30 |