PHP code example of langleyfoxall / helpers-laravel

1. Go to this page and download the library: Download langleyfoxall/helpers-laravel 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/ */

    

langleyfoxall / helpers-laravel example snippets


public function up()
{
    Schema::create('demos', function (Blueprint $table) {
        $table->uuid('id')->primary();
        $table->timestamps();
    });
}

class Demo extends Model
{
    use IdentifiedByUUID;
}

$api_response = ApiResponse::error($errors, $status)

$api_response->data($data)

$response = (new Response($request)->success($message, $data, $meta, $status)

$response = (new Response($request)->success($message, $status)

$response = (new Response($request)->data($data)

$response = (new Response($request)->status($status)

$data = $cache->getData();

$key = $cache->getKey();

$cache = new ResponseCache($request, false);

if($cache->hasData()){
    $data = $cache->getData();
}else{
    $data = computationallyExpensiveFunction();
}

return ApiResponse::success($data)->cache(1, $cache)->json();