diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php index ded965bc74da1344039760e4f8fa08432a59b64a..8ca3e91651fb5fa869350d1336c8a0f540a1fdd3 100644 --- a/app/Http/Controllers/CommentController.php +++ b/app/Http/Controllers/CommentController.php @@ -5,6 +5,12 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Tasks; use App\Comment; +use Kreait\Firebase\Factory; +use Kreait\Firebase\ServiceAccount; +use Kreait\Firebase\Messaging\Notification; +use Kreait\Firebase\Messaging\CloudMessage; +use Illuminate\Support\Facades\Config; + class CommentController extends Controller { // @@ -34,7 +40,31 @@ class CommentController extends Controller 'task_id' => $taskId, 'user_id' => $userId ]); + //FireBaseeeee + $serviceAccount = ServiceAccount::fromArray(Config::get('constants.GOOGLE_FIREBASE_SERVICE')); + $firebase = (new Factory) + ->withServiceAccount($serviceAccount) + ->create(); + + $messaging = $firebase->getMessaging(); + + $notification = Notification::fromArray([ + 'title' => 'Dapet comment nih', + 'body' => $request->comment + ]); + + $data = [ + 'task_id' => $taskId, + 'task_id' => $taskId + ]; + + $message = CloudMessage::withTarget('topic', 'whe') + ->withNotification($notification) + ->withData($data); // optional; + + $messaging->send($message); + ////////////// return response(json_encode([ 'data' => NULL, 'statusMessage' => 'success' diff --git a/app/Http/Controllers/EventsController.php b/app/Http/Controllers/EventsController.php index 4e09c4446bfd9c9b4dff44313ee4849d29b8faee..a86a50475b18469618889367501ff96f757ef4a0 100644 --- a/app/Http/Controllers/EventsController.php +++ b/app/Http/Controllers/EventsController.php @@ -31,8 +31,13 @@ class EventsController extends Controller } public function show(Request $request, $groupId) { - $isGroupExist = Events::find($groupId); - + // $isGroupExist = Events::where('group_id', $groupId); + $isGroupExist = DB::table('events') + ->where([ + 'group_id' => $groupId + ]) + ->orderBy('events.created_at', 'asc') + ->get(); if (is_null($isGroupExist)) { return response(json_encode([ 'statusMessage' => 'Not Found' @@ -50,7 +55,7 @@ class EventsController extends Controller public function destroy(Request $request, $groupId) { $event = Events::find($groupId); - if (is_null($group)) { + if (is_null($event)) { return response(json_encode([ 'statusMessage' => 'Bad Request' ]), 400); diff --git a/app/Tasks.php b/app/Tasks.php index fd09260a8563ad13fc30085cf6997ba640782a81..2f9bce2bc1dc4920c580fac709126c07689e3ae7 100644 --- a/app/Tasks.php +++ b/app/Tasks.php @@ -109,7 +109,12 @@ class Tasks extends Model public function getCommentsAttribute() { - $comments = $this->comments()->getQuery()->orderBy('created_at', 'desc')->get(); + $comments = $this->comments() + ->getQuery() + ->join('users','users.id','=','comments.user_id') + ->orderBy('comments.created_at', 'desc') + ->select('comment','name') + ->get(); return $comments; } } diff --git a/composer.json b/composer.json index c45234f792a7758822f643014c969d12b54a908c..0235937a0c9e4ff4cbe77e952ccc79d493d4f5c2 100644 --- a/composer.json +++ b/composer.json @@ -10,11 +10,13 @@ "require": { "php": "^7.1.3", "fideloper/proxy": "^4.0", + "fzaninotto/faker": "^1.4", "google/apiclient": "^2.2", + "guzzlehttp/guzzle": "^6.3", + "kreait/firebase-php": "^4.18", "laravel/framework": "5.7.*", "laravel/passport": "^7.2", - "laravel/tinker": "^1.0", - "fzaninotto/faker": "^1.4" + "laravel/tinker": "^1.0" }, "require-dev": { "beyondcode/laravel-dump-server": "^1.0", diff --git a/composer.lock b/composer.lock index 91aa0aebf9dda2c5184cff101fb3858bf8c53aae..406228471f21e6f3a03a325f085042ff2eed7efe 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4421d982ba37cf104015c6fa39876799", + "content-hash": "4f1cc443d2c4b501803c381544a8da55", "packages": [ { "name": "defuse/php-encryption", @@ -429,6 +429,56 @@ ], "time": "2019-01-10T14:06:47+00:00" }, + { + "name": "fig/http-message-util", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message-util.git", + "reference": "35b19404371b31b3a43823c755398c48c9966db4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message-util/zipball/35b19404371b31b3a43823c755398c48c9966db4", + "reference": "35b19404371b31b3a43823c755398c48c9966db4", + "shasum": "" + }, + "require": { + "php": "^5.3 || ^7.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Fig\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Utility classes and constants for use with PSR-7 (psr/http-message)", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2018-11-19T16:19:58+00:00" + }, { "name": "firebase/php-jwt", "version": "v5.0.0", @@ -475,6 +525,173 @@ "homepage": "https://github.com/firebase/php-jwt", "time": "2017-06-27T22:17:23+00:00" }, + { + "name": "fzaninotto/faker", + "version": "v1.8.0", + "source": { + "type": "git", + "url": "https://github.com/fzaninotto/Faker.git", + "reference": "f72816b43e74063c8b10357394b6bba8cb1c10de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/f72816b43e74063c8b10357394b6bba8cb1c10de", + "reference": "f72816b43e74063c8b10357394b6bba8cb1c10de", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "ext-intl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7", + "squizlabs/php_codesniffer": "^1.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "time": "2018-07-12T10:23:15+00:00" + }, + { + "name": "giggsey/libphonenumber-for-php", + "version": "8.10.6", + "source": { + "type": "git", + "url": "https://github.com/giggsey/libphonenumber-for-php.git", + "reference": "75fa86dec0a79632fe492fa121b2a067ec100bf1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/75fa86dec0a79632fe492fa121b2a067ec100bf1", + "reference": "75fa86dec0a79632fe492fa121b2a067ec100bf1", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "giggsey/locale": "^1.2", + "php": ">=5.3.2" + }, + "require-dev": { + "pear/pear-core-minimal": "^1.9", + "pear/pear_exception": "^1.0", + "pear/versioncontrol_git": "^0.5", + "phing/phing": "^2.7", + "php-coveralls/php-coveralls": "^1.0|^2.0", + "phpunit/phpunit": "^4.8.36|^5.0", + "symfony/console": "^2.8|^3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "8.x-dev" + } + }, + "autoload": { + "psr-4": { + "libphonenumber\\": "src/" + }, + "exclude-from-classmap": [ + "/src/data/", + "/src/carrier/data/", + "/src/geocoding/data/", + "/src/timezone/data/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Joshua Gigg", + "email": "giggsey@gmail.com", + "homepage": "https://giggsey.com/" + } + ], + "description": "PHP Port of Google's libphonenumber", + "homepage": "https://github.com/giggsey/libphonenumber-for-php", + "keywords": [ + "geocoding", + "geolocation", + "libphonenumber", + "mobile", + "phonenumber", + "validation" + ], + "time": "2019-02-21T11:30:36+00:00" + }, + { + "name": "giggsey/locale", + "version": "1.6", + "source": { + "type": "git", + "url": "https://github.com/giggsey/Locale.git", + "reference": "da6845720b5d104d319d7e84576f54e44dd9e4f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/giggsey/Locale/zipball/da6845720b5d104d319d7e84576f54e44dd9e4f5", + "reference": "da6845720b5d104d319d7e84576f54e44dd9e4f5", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "pear/pear-core-minimal": "^1.9", + "pear/pear_exception": "^1.0", + "pear/versioncontrol_git": "^0.5", + "phing/phing": "~2.7", + "phpunit/phpunit": "^4.8|^5.0", + "satooshi/php-coveralls": "^1.0", + "symfony/console": "^2.8|^3.0|^4.0", + "symfony/filesystem": "^2.8|^3.0|^4.0", + "symfony/finder": "^2.8|^3.0|^4.0", + "symfony/process": "^2.8|^3.0|^4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Giggsey\\Locale\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Joshua Gigg", + "email": "giggsey@gmail.com", + "homepage": "http://giggsey.com/" + } + ], + "description": "Locale functions required by libphonenumber-for-php", + "time": "2018-10-18T07:17:52+00:00" + }, { "name": "google/apiclient", "version": "v2.2.2", @@ -618,6 +835,116 @@ ], "time": "2018-09-17T20:29:21+00:00" }, + { + "name": "google/cloud-core", + "version": "v1.26.0", + "source": { + "type": "git", + "url": "https://github.com/googleapis/google-cloud-php-core.git", + "reference": "ea5ac30e4120b48a92494b1de2c5230926f8c171" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/google-cloud-php-core/zipball/ea5ac30e4120b48a92494b1de2c5230926f8c171", + "reference": "ea5ac30e4120b48a92494b1de2c5230926f8c171", + "shasum": "" + }, + "require": { + "google/auth": "^1.2", + "guzzlehttp/guzzle": "^5.3|^6.0", + "guzzlehttp/promises": "^1.3", + "guzzlehttp/psr7": "^1.2", + "monolog/monolog": "~1", + "php": ">=5.5", + "psr/http-message": "1.0.*", + "rize/uri-template": "~0.3" + }, + "require-dev": { + "erusev/parsedown": "^1.6", + "google/gax": "^0.38.0", + "opis/closure": "^3", + "phpdocumentor/reflection": "^3.0", + "phpunit/phpunit": "^4.8|^5.0", + "squizlabs/php_codesniffer": "2.*" + }, + "suggest": { + "opis/closure": "May be used to serialize closures to process jobs in the batch daemon. Please require version ^3.", + "symfony/lock": "Required for the Spanner cached based session pool. Please require the following commit: 3.3.x-dev#1ba6ac9" + }, + "bin": [ + "bin/google-cloud-batch" + ], + "type": "library", + "extra": { + "component": { + "id": "cloud-core", + "target": "googleapis/google-cloud-php-core.git", + "path": "Core", + "entry": "src/ServiceBuilder.php" + } + }, + "autoload": { + "psr-4": { + "Google\\Cloud\\Core\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Google Cloud PHP shared dependency, providing functionality useful to all components.", + "time": "2019-02-06T21:40:58+00:00" + }, + { + "name": "google/cloud-storage", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/googleapis/google-cloud-php-storage.git", + "reference": "9e4b3aeebfc466671e7aa74862131a3bbd34804d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/google-cloud-php-storage/zipball/9e4b3aeebfc466671e7aa74862131a3bbd34804d", + "reference": "9e4b3aeebfc466671e7aa74862131a3bbd34804d", + "shasum": "" + }, + "require": { + "google/cloud-core": "^1.26" + }, + "require-dev": { + "erusev/parsedown": "^1.6", + "google/cloud-pubsub": "^1.0", + "phpdocumentor/reflection": "^3.0", + "phpseclib/phpseclib": "^2", + "phpunit/phpunit": "^4.8|^5.0", + "squizlabs/php_codesniffer": "2.*" + }, + "suggest": { + "google/cloud-pubsub": "May be used to register a topic to receive bucket notifications.", + "phpseclib/phpseclib": "May be used in place of OpenSSL for creating signed Cloud Storage URLs. Please require version ^2." + }, + "type": "library", + "extra": { + "component": { + "id": "cloud-storage", + "target": "googleapis/google-cloud-php-storage.git", + "path": "Storage", + "entry": "src/StorageClient.php" + } + }, + "autoload": { + "psr-4": { + "Google\\Cloud\\Storage\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Cloud Storage Client for PHP", + "time": "2019-02-06T21:40:58+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "6.3.3", @@ -889,6 +1216,178 @@ "description": "Highlight PHP code in terminal", "time": "2018-09-29T18:48:56+00:00" }, + { + "name": "kreait/firebase-php", + "version": "4.19.0", + "source": { + "type": "git", + "url": "https://github.com/kreait/firebase-php.git", + "reference": "08c3a24319698f65e0d7f8335497a46f865d78b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kreait/firebase-php/zipball/08c3a24319698f65e0d7f8335497a46f865d78b5", + "reference": "08c3a24319698f65e0d7f8335497a46f865d78b5", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "giggsey/libphonenumber-for-php": "^8.9", + "google/auth": "^0.11.0|^1.0", + "guzzlehttp/guzzle": "^6.2.1", + "kreait/firebase-tokens": "^1.7.2", + "kreait/gcp-metadata": "^1.0.1", + "lcobucci/jwt": "^3.2", + "mtdowling/jmespath.php": "^2.3", + "php": "^7.0", + "superbalist/flysystem-google-storage": "^7.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0", + "phpstan/phpstan-phpunit": "^0.9.2", + "phpunit/phpunit": "^6.0|^7.0", + "symfony/var-dumper": "^3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, + "autoload": { + "psr-4": { + "Kreait\\Firebase\\": "src/Firebase" + }, + "files": [ + "src/Firebase.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jérôme Gamez", + "homepage": "https://github.com/jeromegamez" + } + ], + "description": "Firebase Admin SDK", + "homepage": "https://github.com/kreait/firebase-php", + "keywords": [ + "api", + "database", + "firebase", + "google", + "sdk" + ], + "time": "2019-02-09T19:26:39+00:00" + }, + { + "name": "kreait/firebase-tokens", + "version": "1.7.2", + "source": { + "type": "git", + "url": "https://github.com/kreait/firebase-tokens-php.git", + "reference": "a300c7dc17d83b1a19af7519c65612c5124d177e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kreait/firebase-tokens-php/zipball/a300c7dc17d83b1a19af7519c65612c5124d177e", + "reference": "a300c7dc17d83b1a19af7519c65612c5124d177e", + "shasum": "" + }, + "require": { + "fig/http-message-util": "^1.1", + "guzzlehttp/guzzle": "^6.2.1", + "lcobucci/jwt": "^3.2", + "php": "^7.0", + "psr/simple-cache": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0", + "phpstan/phpstan-phpunit": "^0.9.3", + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Firebase\\Auth\\Token\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jérôme Gamez", + "homepage": "https://github.com/jeromegamez" + } + ], + "description": "A library to work with Firebase tokens", + "homepage": "https://github.com/kreait/firebase-token-php", + "keywords": [ + "Authentication", + "auth", + "firebase", + "google", + "token" + ], + "time": "2018-10-26T22:01:30+00:00" + }, + { + "name": "kreait/gcp-metadata", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/kreait/gcp-metadata-php.git", + "reference": "9bc4b871bd8623aa018bbd0ff38e3a286e760bc7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kreait/gcp-metadata-php/zipball/9bc4b871bd8623aa018bbd0ff38e3a286e760bc7", + "reference": "9bc4b871bd8623aa018bbd0ff38e3a286e760bc7", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.0", + "php": "^7.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Kreait\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jérôme Gamez", + "email": "jerome@gamez.name" + } + ], + "description": "Get the metadata from a Google Cloud Platform environment.", + "keywords": [ + "gce", + "gcp", + "google", + "google-cloud", + "google-cloud-engine", + "google-cloud-platform" + ], + "time": "2018-07-28T13:57:51+00:00" + }, { "name": "laravel/framework", "version": "v5.7.26", @@ -1629,6 +2128,61 @@ ], "time": "2018-11-05T09:00:11+00:00" }, + { + "name": "mtdowling/jmespath.php", + "version": "2.4.0", + "source": { + "type": "git", + "url": "https://github.com/jmespath/jmespath.php.git", + "reference": "adcc9531682cf87dfda21e1fd5d0e7a41d292fac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/adcc9531682cf87dfda21e1fd5d0e7a41d292fac", + "reference": "adcc9531682cf87dfda21e1fd5d0e7a41d292fac", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "bin": [ + "bin/jp.php" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "JmesPath\\": "src/" + }, + "files": [ + "src/JmesPath.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Declaratively specify how to extract elements from a JSON document", + "keywords": [ + "json", + "jsonpath" + ], + "time": "2016-12-03T22:08:25+00:00" + }, { "name": "nesbot/carbon", "version": "1.36.2", @@ -2586,6 +3140,97 @@ ], "time": "2018-07-19T23:38:55+00:00" }, + { + "name": "rize/uri-template", + "version": "0.3.2", + "source": { + "type": "git", + "url": "https://github.com/rize/UriTemplate.git", + "reference": "9e5fdd5c47147aa5adf7f760002ee591ed37b9ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rize/UriTemplate/zipball/9e5fdd5c47147aa5adf7f760002ee591ed37b9ca", + "reference": "9e5fdd5c47147aa5adf7f760002ee591ed37b9ca", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Rize\\UriTemplate": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marut K", + "homepage": "http://twitter.com/rezigned" + } + ], + "description": "PHP URI Template (RFC 6570) supports both expansion & extraction", + "keywords": [ + "RFC 6570", + "template", + "uri" + ], + "time": "2017-06-14T03:57:53+00:00" + }, + { + "name": "superbalist/flysystem-google-storage", + "version": "7.2.1", + "source": { + "type": "git", + "url": "https://github.com/Superbalist/flysystem-google-cloud-storage.git", + "reference": "97cf8a5c9a9d368260b2791ec130690a1bec0cbd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Superbalist/flysystem-google-cloud-storage/zipball/97cf8a5c9a9d368260b2791ec130690a1bec0cbd", + "reference": "97cf8a5c9a9d368260b2791ec130690a1bec0cbd", + "shasum": "" + }, + "require": { + "google/cloud-storage": "~1.0", + "league/flysystem": "~1.0", + "php": ">=5.5.0" + }, + "require-dev": { + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Superbalist\\Flysystem\\GoogleStorage\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Superbalist.com a division of Takealot Online (Pty) Ltd", + "email": "info@superbalist.com" + } + ], + "description": "Flysystem adapter for Google Cloud Storage", + "time": "2019-02-21T08:07:24+00:00" + }, { "name": "swiftmailer/swiftmailer", "version": "v6.1.3", @@ -3998,56 +4643,6 @@ ], "time": "2018-10-23T09:00:00+00:00" }, - { - "name": "fzaninotto/faker", - "version": "v1.8.0", - "source": { - "type": "git", - "url": "https://github.com/fzaninotto/Faker.git", - "reference": "f72816b43e74063c8b10357394b6bba8cb1c10de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/f72816b43e74063c8b10357394b6bba8cb1c10de", - "reference": "f72816b43e74063c8b10357394b6bba8cb1c10de", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "ext-intl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7", - "squizlabs/php_codesniffer": "^1.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.8-dev" - } - }, - "autoload": { - "psr-4": { - "Faker\\": "src/Faker/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "François Zaninotto" - } - ], - "description": "Faker is a PHP library that generates fake data for you.", - "keywords": [ - "data", - "faker", - "fixtures" - ], - "time": "2018-07-12T10:23:15+00:00" - }, { "name": "hamcrest/hamcrest-php", "version": "v2.0.0", diff --git a/config/constants.php b/config/constants.php index 6ecac55dfc5ee93b79d7975d1c9f1187ca94b31b..86dbe9f1e89fd4d9ecb352aae689e1fa8cb5a064 100644 --- a/config/constants.php +++ b/config/constants.php @@ -13,4 +13,16 @@ return [ 'SCRUM_MASTER' => 'Scrum Master', 'SCRUM TEAM' => 'Scrum Team' ], + 'GOOGLE_FIREBASE_SERVICE' => [ + "type" => "service_account", + "project_id" => "pbdandroid-1550738565959", + "private_key_id"=> "2b7855374ac92e6e67e5bba5fc48e97890809d6b", + "private_key"=> "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCT879xfGw9z2hP\n9ukN66c9dQRUb0Z9Es9aCiKDjSzOxzUk3V2HQc2J4Ud6Hfu0vGtFJ992W+Ehy1sL\nL8NRO97LfRc+2DHD4tBdOK0yU9ZUR8uWE/CkmuKKHdLHG7YIBAB/RkWD1lsnCr3D\nC85/CWDVP7TjdusJQtvAqZJJiiIRO9l1ulA+UcwKDozO3cC75fqx5UuLcgAYEjJ8\ncnD1ZI89k7ZmUns//ewqZ4deUEVQ4IDuRyVApjSEn+zeTLVAOijoaY0xFZWmqxoN\n5J0BxZfA/pDCdllXirMw2vC0k0gsyUZMxAFnyCPKbMty5UunXDwBi1aNFlRzUJ8u\nDBpFjWg5AgMBAAECggEAO2rO7hUhZTtX8ZE/7DLA8cn+SKh9nvpAYrEiRkGahppz\nCdCK4Kh5Eo/yBCVpch6fV+EY+bARfGBuOlJets97/K3KeZcaeUgsFNwPlmAb+bHx\nnV55rKl1JDGw9fx3gMWWq4Z9oWIjLk0+g0fJELSj+lBA5X7bClea6EdRdA4w+0k5\nCCForXJzmuohlGX/iC/ZP58WfUFrMZXcmENPYLpXto0e55rGq9RWFA8VKL3PMHw+\n1IrT92tgOX/FCtfZj7uEELyM3D9IV71Va7OHEkw5u1iJ3qbvgP27q/4EYyJ6k11C\nwFkiPry/d2i1lSClxguGgvXuPtjq6xAekyrUPOAgTwKBgQDFtV+1ietRU8UBPU+L\nHI/HNq1TmtOYHGUCUvoeOTUKnSdGKcu1hOQtKqAt6Ya7kI5SiDNJvp7zi84TREDm\n6jzSb6AKxBxSryD4sLTPCI65K11quM6aryUWzIHyugOK05cR/vAeGWbsHQ9hZCt5\nlwROimX3+qX5QFllomxM78T1OwKBgQC/kt4wIaTIYqaL4SmPGclSPLoEb295xyb1\neuM/I/O255XQ4MX+J20Lu8h8PsVOxB/wrPV2Luf2OpiagQaBg6GMr4NNPhDMlX0T\nXLhplPCLsEhd3x9iuPCKJIPJG7JQ1baQKoVpnhlp3XYcO0MI+n/ZmVIwDnxhcZrX\nBYdsWBHxGwKBgDSaXl2x1W9tB2SeCHTt439Ql+s/rX6yR1nH9A5okClDyPhNFIs2\nUXOG/NlaYeOzwXpKDMNZOXd5Qho0NcR6nDYtRvq2VQbW28HvWhwfncG8vP0xMJ9N\nbGPVg9muDlU4mOBL4V1QyuaVkMsL2NlgCeBPyHOjN9fKfD6jaYdK4C+TAoGBALhQ\nCF8Mb2qvpwbbac2ZBJ2PeXS89eaXGb+CLNLZtyhZZUVijHs62Wo5j+khx1lBzm0T\nKtI6zMeUlq/HxUekKjCdyFjvhuAeTwjq4y4JsujigK139s1Xm219NiGt+QBWrV/E\n2TjFeDPnczQ0PAmOYKUtIurDdR2XXF7VnfY6QYDTAoGAMbrU2EPqhO0pjKLdbC96\nBL+3XpFVeunpRAynw2KZGREc8cZZulhMmb7btO2H24zwXABhDHIE58nAiiGJvE2T\nZ2ZvhdcwoM5oWmqNcAVMA6fIdwwQxvlEi6dAv8tBMmKlbMJkDwMmMAJaoKA+rAKF\nE8z2QRxjPu522voRt+6PD8w=\n-----END PRIVATE KEY-----\n", + "client_email"=> "firebase-adminsdk-unhvv@pbdandroid-1550738565959.iam.gserviceaccount.com", + "client_id"=> "118045150108279787454", + "auth_uri"=> "https://accounts.google.com/o/oauth2/auth", + "token_uri"=> "https://oauth2.googleapis.com/token", + "auth_provider_x509_cert_url"=> "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url"=> "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-unhvv%40pbdandroid-1550738565959.iam.gserviceaccount.com" + ] ]; \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 46c9556da5bf17f612a38993b9c3887ba4eaff40..31bae6d0d7cd2e70bb0192248fdc83f27a652bb7 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,6 +1,11 @@ <?php use Illuminate\Http\Request; +use Kreait\Firebase\Factory; +use Kreait\Firebase\ServiceAccount; +use Kreait\Firebase\Messaging\Notification; +use Kreait\Firebase\Messaging\CloudMessage; +use Illuminate\Support\Facades\Config; /* |-------------------------------------------------------------------------- @@ -66,6 +71,26 @@ Route::delete('/group/{groupId}/events', 'EventsController@destroy'); Route::post('/user/{userId}/task/{taskId}/comment', 'CommentController@createCommentInTaskId'); Route::get('/task/{taskId}/comment', 'CommentController@getCommentsFromTaskId'); + +Route::get('/jeg', function() { + $serviceAccount = ServiceAccount::fromArray(Config::get('constants.GOOGLE_FIREBASE_SERVICE')); + $firebase = (new Factory) + ->withServiceAccount($serviceAccount) + ->create(); + + $messaging = $firebase->getMessaging(); + + $notification = Notification::fromArray([ + 'title' => 'bacot dionnn', + 'body' => 'bacotttttt' + ]); + + $message = CloudMessage::withTarget('topic', 'whe') + ->withNotification($notification); // optional; + + $messaging->send($message); + return 'yeah'; +}); // Route::group(['middleware' => 'auth:api'], function() // { // Route::resource('tasks','TasksController', ['except' => ['index', 'edit', 'create']]);