PHP code example of aliirfaan / laravel-simple-force-update

1. Go to this page and download the library: Download aliirfaan/laravel-simple-force-update library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aliirfaan / laravel-simple-force-update example snippets


  aliirfaan\LaravelSimpleForceUpdate\SimpleForceUpdateProvider::class,

 'aliirfaan\LaravelSimpleForceUpdate\SimpleForceUpdateProvider',



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use aliirfaan\LaravelSimpleForceUpdate\Services\SimpleForceUpdateService;

class TestController extends Controller
{
    public function index(Request $request, SimpleForceUpdateService $simpleForceUpdateService)
    {
        // get all versions by application. You may have multiple applications/mobile apps
        $appName = 'default';
        $platform = null;

        $result = $simpleForceUpdateService->getVersions($appName, $platform);
        dd($result);

        // get version by application and platform.
        $appName = 'default';
        $platform = 'android';

        $result = $simpleForceUpdateService->getVersions($appName, $platform);
        dd($result);

        // get update action based on a candidate version.
        $candidateVersion = '2.0.9'; // this is normally the version currently installed on the client/device
        $appName = 'default';
        $platform = 'android';

        $result = $simpleForceUpdateService->getApplicationCompatibility($candidateVersion, $appName, $platform);
        dd($result);

    }
}



namespace App\Services;

use aliirfaan\LaravelSimpleForceUpdate\Contracts\AbstractSimpleForceUpdate;

class CustomForceUpdateService extends AbstractSimpleForceUpdate 
{
    /**
     * You can override this function or create another function
     */
    public function getApplicationCompatibility($candidateVersion, $appName = 'default', $platform = 'android')
    {
        // your logic
    }
}
bash
 $ php artisan vendor:publish --provider="aliirfaan\LaravelSimpleForceUpdate\SimpleForceUpdateProvider"
bash
 $ php artisan migrate