HEX
Server: Apache/2.4.46 (Ubuntu)
System: Linux localhost 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64
User: root (0)
PHP: 7.4.16
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/fieldsblaze-heroku/app/Http/Controllers/APIAnnouncementController.php
<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
use DB;
use App\Library\UserLib;
use App\Models\User;
use App\Models\Product;
use App\Models\Customer;
use App\Models\PriceBookEntry;
use App\Models\Order;
use App\Models\OrderItems;
use App\Models\OrderStatus;
use App\Models\Countries;
use App\Models\PaymentType;
use App\Models\Stocks;
use App\Models\StockProducts;
use App\Models\Performance;
use App\Models\PerformanceLineItem;
use App\Models\TargetType;
use App\Models\SalesTerritory;
use App\Models\Announcement;

use DateTime;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;


class APIAnnouncementController extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
 
    protected $userLib;
    protected $dateFormat = 'dd-mm-yyyy';
    public function __construct(UserLib $userLib)
	{
		$this->userLib = $userLib;		 
	}
 
//getAnnouncementList
public function getAnnouncementList(Request $request) {
    $data = $request->json()->all();	                       
    $UserId = $request->header('UserId');
    $AuthToken = $request->header('AuthToken');                
    //check auth token
    if($this->userLib->tokenChecker($request) == FALSE)
    {
        $response = [
            'success' => false,
            'ResponseMessage' => "Authentication Failed",
            'ResponseCode' => "301",
            'ApiVersion' => env('APP_VERSION'),    
        ];
        return response()->json($response);
    }              
    $Announcements = Announcement::select('*')           
    ->where('Status', '=', '1')  
    ->where('IsDeleted', '=', '0')
    ->orderBy('id', 'desc')          
    ->get();   

    if ($Announcements->count() > 0)
    { 
        foreach ($Announcements as $key => $AnnouncementValue) 
        {     
            //Distributer 

            $CreatedFormatedDate = $AnnouncementValue->Created_at;      
            $CreatedFormatedDate = date("j M Y",strtotime($CreatedFormatedDate));    
            $AnnouncementValue->CreatedFormatedDate = $CreatedFormatedDate;
        }
    }
     
    $response = [
        'Success' => true,
        'ResponseMessage' => "Success",
        'ResponseCode' => "200",                                                            
        'Announcements' => $Announcements, 
        'ApiUrl' => env('APP_URL'),    
        'ApiVersion' => env('APP_VERSION'),                           
    ];                                               
    return response()->json($response);
}

//getAnnouncementDetails
public function getAnnouncementDetails(Request $request, $AnnouncementId='') {
    $data = $request->json()->all();	                       
    $UserId = $request->header('UserId');
    $AuthToken = $request->header('AuthToken');                
    //check auth token
    if($this->userLib->tokenChecker($request) == FALSE)
    {
        $response = [
            'success' => false,
            'ResponseMessage' => "Authentication Failed",
            'ResponseCode' => "301",
            'ApiVersion' => env('APP_VERSION'),    
        ];
        return response()->json($response);
    }
    
    if($AnnouncementId == '')
    {
        $response = [
            'success' => false,
            'ResponseMessage' => "Please provide AnnouncementId",
            'ResponseCode' => "305",
            'ApiVersion' => env('APP_VERSION'),    
        ];
        return response()->json($response);
    }
     
 
    $Announcement = Announcement::where('AnnouncementId', $AnnouncementId)->get()->first();               
    

    $CreatedFormatedDate = $Announcement->Created_at;      
    $CreatedFormatedDate = date("j M Y",strtotime($CreatedFormatedDate));    
    $Announcement->CreatedFormatedDate = $CreatedFormatedDate;
     

    $response = [
        'Success' => true,
        'ResponseMessage' => "Success",
        'ResponseCode' => "200",                                                            
        'Announcement' => $Announcement, 
        'ApiUrl' => env('APP_URL'),    
        'ApiVersion' => env('APP_VERSION'),                           
    ];                                               
    return response()->json($response);
}

 

}