Applied fixes from StyleCI
This commit is contained in:

committed by
StyleCI Bot

parent
09bf25b5e2
commit
e2390f67d4
@@ -5,33 +5,31 @@ namespace App\Http\Controllers\Api\v1;
|
||||
// Controllers
|
||||
use App\Http\Controllers\Controller;
|
||||
// Requests
|
||||
use Illuminate\Http\Request;
|
||||
// Models
|
||||
use App\User;
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||
// Models
|
||||
use App\Model\helpdesk\Ticket\Tickets;
|
||||
use App\User;
|
||||
use FCM;
|
||||
// classes
|
||||
use LaravelFCM\Message\PayloadNotificationBuilder;
|
||||
use LaravelFCM\Message\Topics;
|
||||
use Illuminate\Http\Request;
|
||||
use LaravelFCM\Message\OptionsBuilder;
|
||||
use LaravelFCM\Message\PayloadDataBuilder;
|
||||
use LaravelFCM\Message\PayloadNotificationBuilder;
|
||||
use LaravelFCM\Response\DownstreamResponse;
|
||||
use FCM;
|
||||
use FCMGroup;
|
||||
|
||||
/**
|
||||
* **********************************************
|
||||
* PushNotificationController
|
||||
* **********************************************
|
||||
* This controller is used to send notification to FCM cloud which later will
|
||||
* foreward notification to Mobile Application
|
||||
* This controller is used to send notification to FCM cloud which later will
|
||||
* foreward notification to Mobile Application.
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class PushNotificationController extends Controller {
|
||||
|
||||
public function Response($token, $body, $ticket_id = null) {
|
||||
|
||||
class PushNotificationController extends Controller
|
||||
{
|
||||
public function Response($token, $body, $ticket_id = null)
|
||||
{
|
||||
$optionBuiler = new OptionsBuilder();
|
||||
$optionBuiler->setTimeToLive(60 * 60);
|
||||
|
||||
@@ -41,8 +39,8 @@ class PushNotificationController extends Controller {
|
||||
->setIcon('ic_stat_f1')
|
||||
->setClickAction('OPEN_ACTIVITY_1');
|
||||
|
||||
if($ticket_id != null) {
|
||||
$ticket_data = Tickets::where('id', '=', $ticket_id )->first();
|
||||
if ($ticket_id != null) {
|
||||
$ticket_data = Tickets::where('id', '=', $ticket_id)->first();
|
||||
$thread_data = Ticket_Thread::where('ticket_id', '=', $ticket_id)->first();
|
||||
$dataBuilder = new PayloadDataBuilder();
|
||||
$dataBuilder->addData(['ticket_id' => $ticket_id]);
|
||||
@@ -73,21 +71,24 @@ class PushNotificationController extends Controller {
|
||||
$downstreamResponse->tokensToRetry();
|
||||
// return Array (key:token, value:errror) - in production you should remove from your database the tokens
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* function to get the fcm token from the api under a user.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function fcmToken(Request $request, User $user) {
|
||||
// get the requested details
|
||||
public function fcmToken(Request $request, User $user)
|
||||
{
|
||||
// get the requested details
|
||||
$user_id = $request->input('user_id');
|
||||
$fcm_token = $request->input('fcm_token');
|
||||
// check for all the valid details
|
||||
if($user_id != null && $user_id != "" && $fcm_token != null && $fcm_token != "") {
|
||||
if ($user_id != null && $user_id != '' && $fcm_token != null && $fcm_token != '') {
|
||||
// search the user_id in database
|
||||
$user = $user->where('id', '=', $user_id)->first();
|
||||
if($user != null) {
|
||||
if ($user != null) {
|
||||
$user->fcm_token = $fcm_token;
|
||||
$user->save();
|
||||
// success response for success case
|
||||
@@ -101,5 +102,4 @@ class PushNotificationController extends Controller {
|
||||
return ['response' => 'fail', 'reason' => 'Invalid Credentials'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user