Skip to content

Commit d04965c

Browse files
author
Jonn Alves
committed
Initial commit
0 parents commit d04965c

File tree

99 files changed

+56030
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+56030
-0
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.env.example

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
10+
11+
DB_CONNECTION=mysql
12+
DB_HOST=127.0.0.1
13+
DB_PORT=3306
14+
DB_DATABASE=laravel
15+
DB_USERNAME=root
16+
DB_PASSWORD=
17+
18+
BROADCAST_DRIVER=log
19+
CACHE_DRIVER=file
20+
FILESYSTEM_DRIVER=local
21+
QUEUE_CONNECTION=sync
22+
SESSION_DRIVER=file
23+
SESSION_LIFETIME=120
24+
25+
MEMCACHED_HOST=127.0.0.1
26+
27+
REDIS_HOST=127.0.0.1
28+
REDIS_PASSWORD=null
29+
REDIS_PORT=6379
30+
31+
MAIL_MAILER=smtp
32+
MAIL_HOST=mailhog
33+
MAIL_PORT=1025
34+
MAIL_USERNAME=null
35+
MAIL_PASSWORD=null
36+
MAIL_ENCRYPTION=null
37+
MAIL_FROM_ADDRESS=null
38+
MAIL_FROM_NAME="${APP_NAME}"
39+
40+
AWS_ACCESS_KEY_ID=
41+
AWS_SECRET_ACCESS_KEY=
42+
AWS_DEFAULT_REGION=us-east-1
43+
AWS_BUCKET=
44+
AWS_USE_PATH_STYLE_ENDPOINT=false
45+
46+
PUSHER_APP_ID=
47+
PUSHER_APP_KEY=
48+
PUSHER_APP_SECRET=
49+
PUSHER_APP_CLUSTER=mt1
50+
51+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
52+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
53+
54+
#Firebase
55+
#Push Apps
56+
FCM_SERVER_KEY=
57+
58+
#Analytcs
59+
FBA_API_KEY=
60+
FBA_AUTH_DOMAIN=
61+
FBA_SENDER_ID=
62+
FBA_APP_ID=
63+
FBA_MEASUREMENT_ID=

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/storage/*.key
5+
/vendor
6+
.env
7+
.env.backup
8+
.phpunit.result.cache
9+
docker-compose.override.yml
10+
Homestead.json
11+
Homestead.yaml
12+
npm-debug.log
13+
yarn-error.log
14+
/.idea
15+
/.vscode

.styleci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
php:
2+
preset: laravel
3+
version: 8
4+
disabled:
5+
- no_unused_imports
6+
finder:
7+
not-name:
8+
- index.php
9+
- server.php
10+
js:
11+
finder:
12+
not-name:
13+
- webpack.mix.js
14+
css: true

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
2+
3+
<p align="center">
4+
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
5+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
6+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
7+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
8+
</p>
9+
10+
## Firebase for web
11+
12+
- Initialization with [Oficial Doc](https://firebase.google.com/docs/web/setup).
13+
- Add [analytics](https://firebase.google.com/docs/analytics/get-started?platform=web) in project.
14+
- Add [Events](https://firebase.google.com/docs/analytics/events?platform=web) in project.
15+
- Add [Remote config](https://firebase.google.com/docs/remote-config/get-started?platform=web) in project.
16+
- Add [Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/js/client) in project.
17+
- Add [Receive Messaging](https://firebase.google.com/docs/cloud-messaging/js/receive) in project.
18+
19+
####Examples
20+
- [GitHub Javascrip project](https://github.com/firebase/quickstart-js).
21+
- [Remote config](https://github.com/firebase/quickstart-js/blob/master/remote-config/index.html).
22+
23+
##### others
24+
- [Gerenciando Assets com Laravel Mix](https://imasters.com.br/css/gerenciando-assets-com-laravel-mix).
25+
- [how to call user-defined function of a window object in javascript](https://stackoverflow.com/questions/18956328/how-to-call-user-defined-function-of-a-window-object-in-javascript).
26+
- [Where can I find the API KEY for Firebase Cloud Messaging?](https://stackoverflow.com/questions/37337512/where-can-i-find-the-api-key-for-firebase-cloud-messaging).

app/Console/Kernel.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* Define the application's command schedule.
12+
*
13+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
14+
* @return void
15+
*/
16+
protected function schedule(Schedule $schedule)
17+
{
18+
// $schedule->command('inspire')->hourly();
19+
}
20+
21+
/**
22+
* Register the commands for the application.
23+
*
24+
* @return void
25+
*/
26+
protected function commands()
27+
{
28+
$this->load(__DIR__.'/Commands');
29+
30+
require base_path('routes/console.php');
31+
}
32+
}

app/Exceptions/Handler.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* A list of the exception types that are not reported.
12+
*
13+
* @var string[]
14+
*/
15+
protected $dontReport = [
16+
//
17+
];
18+
19+
/**
20+
* A list of the inputs that are never flashed for validation exceptions.
21+
*
22+
* @var string[]
23+
*/
24+
protected $dontFlash = [
25+
'current_password',
26+
'password',
27+
'password_confirmation',
28+
];
29+
30+
/**
31+
* Register the exception handling callbacks for the application.
32+
*
33+
* @return void
34+
*/
35+
public function register()
36+
{
37+
$this->reportable(function (Throwable $e) {
38+
//
39+
});
40+
}
41+
}

app/Firebase/Push/Push.php

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?php
2+
3+
namespace App\Firebase\Push;
4+
5+
class Push
6+
{
7+
private $title;
8+
private $message;
9+
private $to;
10+
private $deeplink = null;
11+
private $payload = [];
12+
13+
/**
14+
* @param $title
15+
*/
16+
public function setTitle(string $title)
17+
{
18+
$this->title = $title;
19+
}
20+
21+
/**
22+
* @param $message
23+
*/
24+
public function setMessage(string $message)
25+
{
26+
$this->message = $message;
27+
}
28+
29+
/**
30+
* @param array $payload
31+
*/
32+
public function setPayload(array $payload)
33+
{
34+
$this->payload = $payload;
35+
}
36+
37+
/**
38+
* @param string $to
39+
*/
40+
public function setTo(string $to)
41+
{
42+
$this->to = $to;
43+
}
44+
45+
/**
46+
* @param string|null $deeplink
47+
*/
48+
public function setDeeplink(?string $deeplink)
49+
{
50+
$this->deeplink = $deeplink;
51+
}
52+
53+
/**
54+
* @return string
55+
*/
56+
public function send(): string
57+
{
58+
//
59+
$request = array();
60+
//
61+
$request['notification'] = $this->makeNotification();
62+
$request['data'] = $this->makeData();
63+
$request['apns']['payload']['aps'] = $this->makeApns();
64+
//
65+
$request['content_available'] = true;
66+
$request['priority'] = 5;
67+
//
68+
if (count($this->payload) > 0) {
69+
$request['registration_ids'] = $this->payload;
70+
} else {
71+
$request['to'] = $this->to;
72+
}
73+
//
74+
return $this->makeSend($request);
75+
}
76+
77+
private function makeSend($request): string
78+
{
79+
$headers = [
80+
'Authorization: key=' . env('FCM_SERVER_KEY'),
81+
'Content-Type: application/json',
82+
];
83+
84+
$ch = curl_init();
85+
86+
curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
87+
curl_setopt($ch, CURLOPT_POST, true);
88+
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
89+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
90+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
91+
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request));
92+
return curl_exec($ch);
93+
}
94+
95+
private function makeNotification(): array
96+
{
97+
$notification = array();
98+
if ($this->title !== null) {
99+
$notification['title'] = $this->title;
100+
}
101+
102+
if ($this->message !== null) {
103+
$notification['body'] = $this->message;
104+
}
105+
106+
if ($this->deeplink !== null) {
107+
$notification['deeplink'] = $this->deeplink;
108+
}
109+
110+
$notification['badge'] = 1;
111+
$notification['priority'] = 'high';
112+
$notification['mutable_content'] = true;
113+
return $notification;
114+
}
115+
116+
private function makeData(): array
117+
{
118+
$data = array();
119+
if ($this->title !== null) {
120+
$data['title'] = $this->title;
121+
}
122+
123+
if ($this->message !== null) {
124+
$data['body'] = $this->message;
125+
}
126+
127+
if ($this->deeplink !== null) {
128+
$data['deeplink'] = $this->deeplink;
129+
}
130+
131+
$data['timestamp'] = date('Y-m-d G:i:s');
132+
return $data;
133+
}
134+
135+
private function makeApns(): array
136+
{
137+
$apns = array();
138+
if ($this->deeplink !== null) {
139+
$apns['mutableContent'] = true;
140+
$apns['deeplink'] = $this->deeplink;
141+
}
142+
return $apns;
143+
}
144+
}

0 commit comments

Comments
 (0)