@extends('layouts.master') @section('title') Sms Gateways @endsection @section('css') @endsection @section('content') @component('components.breadcrumb') @slot('li_1') SMS @endslot @slot('title') Gateways @endslot @endcomponent
@if (session('error'))
@endif
{{-- --}}
@php $userDefinedGatewayPath = app_path('Gateways/UserDefined'); // Initialize an array to store gateway information $gatewayInfoArray = []; // Loop through user-defined gateway files in the directory foreach (scandir($userDefinedGatewayPath) as $file) { $filePath = $userDefinedGatewayPath . DIRECTORY_SEPARATOR . $file; // Check if it's a PHP file if (is_file($filePath) && pathinfo($file, PATHINFO_EXTENSION) === 'php') { // Extract gateway name from the file name and remove "SmsGateway" prefix $gatewayName = strtolower(str_replace('SmsGateway', '', pathinfo($file, PATHINFO_FILENAME))); // Load the gateway class dynamically $gatewayClass = "App\\Gateways\\UserDefined\\" . ucfirst($gatewayName) . "SmsGateway"; // Initialize error flag and gatewayInfo array $hasSyntaxError = false; $gatewayInfo = []; // Try to include the file and handle ParseError try { if (class_exists($gatewayClass) && method_exists($gatewayClass, 'getGatewayInfo')) { // Call the method only if it exists $gatewayInfo = $gatewayClass::getGatewayInfo(); $gatewayFunctionName = lcfirst($gatewayName); } } catch (\ParseError $parseError) { // Set the error flag to true $hasSyntaxError = true; // Read the file content to extract description and author $phpFileContents = file_get_contents($filePath); // Use regex to extract description and author preg_match('/\* Description:(.*?)\* Author:(.*?)\*/s', $phpFileContents, $matches); // Extract description and author from regex matches $description = isset($matches[1]) ? trim($matches[1]) : ''; $author = isset($matches[2]) ? trim($matches[2]) : ''; // Store additional information in the gatewayInfo array $gatewayInfo = [ 'description' => $description, 'author' => $author, ]; } // Store gateway information and error status in the array $gatewayInfoArray[] = [ 'name' => $hasSyntaxError ? "⚠ $gatewayName" : $gatewayName, 'description' => $gatewayInfo['description'] ?? '', 'author' => $gatewayInfo['author'] ?? '', 'website' => $gatewayInfo['website'] ?? '', 'hasSyntaxError' => $hasSyntaxError, 'gatewayFunctionName' => lcfirst($gatewayName), ]; } } @endphp @foreach($gatewayInfoArray as $gatewayInfo) @endforeach
Gateway Name Description Author Website Actions
{{ $gatewayInfo['name'] }} {{ $gatewayInfo['description'] }} {{ $gatewayInfo['author'] }} @if (isset($gatewayInfo['website'])) {{ $gatewayInfo['website'] }} @endif
    @if (!$gatewayInfo['hasSyntaxError'])
  • @endif
@endsection @section('script') @endsection