Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cmgmyr/laravel-messenger
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.3
Choose a base ref
...
head repository: cmgmyr/laravel-messenger
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 2,935 additions and 1,144 deletions.
  1. +10 −0 .gitattributes
  2. +55 −0 .github/CONTRIBUTING.md
  3. +1 −0 .github/FUNDING.yml
  4. +14 −0 .github/ISSUE_TEMPLATE/config.yml
  5. +3 −0 .github/SECURITY.md
  6. +23 −0 .github/workflows/php-cs-fixer.yml
  7. +79 −0 .github/workflows/run-tests-mysql.yml
  8. +94 −0 .github/workflows/run-tests-postgres.yml
  9. +111 −0 .github/workflows/run-tests.yml
  10. +6 −3 .gitignore
  11. +116 −0 .php-cs-fixer.php
  12. +0 −13 .travis.yml
  13. +1 −1 LICENSE
  14. +42 −14 composer.json
  15. +21 −0 config/config.php
  16. +151 −0 examples/MessagesController.php
  17. 0 {src/Cmgmyr/Messenger → }/examples/routes.php
  18. +58 −0 examples/views/layouts/master.blade.php
  19. +36 −0 examples/views/messenger/create.blade.php
  20. +7 −0 examples/views/messenger/index.blade.php
  21. +5 −0 examples/views/messenger/partials/flash.blade.php
  22. +25 −0 examples/views/messenger/partials/form-message.blade.php
  23. +13 −0 examples/views/messenger/partials/messages.blade.php
  24. +1 −0 examples/views/messenger/partials/no-threads.blade.php
  25. +16 −0 examples/views/messenger/partials/thread.blade.php
  26. +10 −0 examples/views/messenger/show.blade.php
  27. +4 −0 examples/views/messenger/unread-count.blade.php
  28. +4 −3 {src → }/migrations/2014_10_28_175635_create_threads_table.php
  29. +4 −6 {src → }/migrations/2014_10_28_175710_create_messages_table.php
  30. +5 −7 {src → }/migrations/2014_10_28_180224_create_participants_table.php
  31. +4 −3 {src → }/migrations/2014_11_03_154831_add_soft_deletes_to_participants_table.php
  32. +4 −3 {src → }/migrations/2014_12_04_124531_add_softdeletes_to_threads_table.php
  33. +33 −0 migrations/2017_03_30_152742_add_soft_deletes_to_messages_table.php
  34. +41 −10 phpunit.xml
  35. +100 −33 readme.md
  36. +0 −43 src/Cmgmyr/Messenger/MessengerServiceProvider.php
  37. +0 −77 src/Cmgmyr/Messenger/Models/Message.php
  38. +0 −51 src/Cmgmyr/Messenger/Models/Participant.php
  39. +0 −204 src/Cmgmyr/Messenger/Models/Thread.php
  40. +0 −60 src/Cmgmyr/Messenger/Traits/Messagable.php
  41. +0 −172 src/Cmgmyr/Messenger/examples/MessagesController.php
  42. +0 −35 src/Cmgmyr/Messenger/examples/create_users_table.php
  43. +0 −33 src/Cmgmyr/Messenger/examples/views/create.blade.php
  44. +0 −20 src/Cmgmyr/Messenger/examples/views/index.blade.php
  45. +0 −41 src/Cmgmyr/Messenger/examples/views/show.blade.php
  46. +0 −4 src/Cmgmyr/Messenger/examples/views/unread-count.blade.php
  47. +109 −0 src/MessengerServiceProvider.php
  48. +114 −0 src/Models/Message.php
  49. +159 −0 src/Models/Models.php
  50. +67 −0 src/Models/Participant.php
  51. +459 −0 src/Models/Thread.php
  52. +93 −0 src/Traits/Messagable.php
  53. 0 src/config/.gitkeep
  54. +0 −5 src/config/config.php
  55. 0 src/migrations/.gitkeep
  56. +0 −27 src/migrations/2014_11_10_083449_add_nullable_to_last_read_in_participants_table.php
  57. +0 −27 src/migrations/2014_11_20_131739_alter_last_read_in_participants_table.php
  58. 0 tests/.gitkeep
  59. +112 −0 tests/CustomModelsTest.php
  60. +9 −15 tests/EloquentMessageTest.php
  61. +474 −75 tests/EloquentThreadTest.php
  62. +84 −36 tests/MessagableTraitTest.php
  63. +10 −0 tests/Stubs/Models/CustomMessage.php
  64. +10 −0 tests/Stubs/Models/CustomParticipant.php
  65. +10 −0 tests/Stubs/Models/CustomThread.php
  66. +87 −103 tests/TestCase.php
  67. +15 −0 tests/User.php
  68. +0 −4 tests/bootstrap.php
  69. +26 −0 tests/database/2014_10_12_000000_create_users_table.php
  70. +0 −16 tests/factories.php
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/tests export-ignore
55 changes: 55 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing

Contributions are **welcome** and will be fully **credited**.

Please read and understand the contribution guide before creating an issue or pull request.

## Etiquette

This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.

Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.

It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.

## Viability

When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.

## Procedure

Before filing an issue:

- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.

Before submitting a pull request:

- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.

## Requirements

If the project maintainer has any additional requirements, you will find them listed here.

- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.

**Happy coding**!
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: cmgmyr
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/cmgmyr/laravel-messenger/discussions/new?category=q-a
about: Ask the community for help
- name: Request a feature
url: https://github.com/cmgmyr/laravel-messenger/discussions/new?category=ideas
about: Share ideas for new features
- name: Report a security issue
url: https://github.com/cmgmyr/laravel-messenger/security/policy
about: Learn how to notify us for sensitive bugs
- name: Report a bug
url: https://github.com/cmgmyr/laravel-messenger/issues/new
about: Report a reproducible bug
3 changes: 3 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Security Policy

If you discover any security related issues, please email cmgmyr@gmail.com instead of using the issue tracker.
23 changes: 23 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check & fix styling

on: [push]

jobs:
php-cs-fixer:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php-cs-fixer.php --allow-risky=yes

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
79 changes: 79 additions & 0 deletions .github/workflows/run-tests-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: MySQL Tests

on:
- push
- pull_request

jobs:
laravel-tests:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: db_test_laravel
ports:
- 33306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2', '8.3']
dependency-stability: [prefer-stable]
laravel: ['9.*', '10.*', '11.*']
include:
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 10.*
php-versions: 8.0
- laravel: 11.*
php-versions: 8.1

name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}

steps:
- uses: actions/checkout@v4

- name: Install PHP versions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}

- name: Get Composer Cache Directory 2
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: actions-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Laravel Dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --dev
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: mysql
DB_DATABASE: db_test_laravel
DB_PORT: 33306
DB_USERNAME: root
run: vendor/bin/phpunit --testdox
94 changes: 94 additions & 0 deletions .github/workflows/run-tests-postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: PostgreSQL Tests

on:
- push
- pull_request

jobs:
laravel-tests:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: db_test_laravel
ports:
- 55432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2', '8.3']
dependency-stability: [prefer-stable]
laravel: ['9.*', '10.*', '11.*']
include:
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 10.*
php-versions: 8.0
- laravel: 11.*
php-versions: 8.1

name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}

steps:
- uses: actions/checkout@v4

- name: Install PHP versions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}

- name: Get Composer Cache Directory 2
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: actions-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Cache PHP dependencies
uses: actions/cache@v4
id: vendor-cache
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}

- name: Install Laravel Dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --dev
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction
- name: Show dir
run: pwd

- name: PHP Version
run: php --version

- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: pgsql
DB_DATABASE: db_test_laravel
DB_PORT: 55432
DB_USERNAME: postgres
DB_PASSWORD: postgres
run: vendor/bin/phpunit --testdox
Loading