PHP code example of maplesnow / laravel-core

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

    

maplesnow / laravel-core example snippets


use MapleSnow\LaravelCore\Helpers\Export;

class PostExport extends Export implements WithTitle {

    public function query()
    {
        return Post::with('creator')->limit(100);
    }

    public function title(): string {
        return 'Post';
    }

    /**
     * @param Post $post
     * @return array
     */
    public function map($post): array
    {
        return [
            $post->id,
            $post->title,
            $post->creator->name,
            $post->created_at
        ];
    }

    public function headings(): array {
        return [
            '#',
            'Title',
            'Author',
            'CreateTime'
        ];
    }
}

class MultiPost implements WithMultipleSheets {

    public function sheets() :array{

        $sheets[] = new PostExport();
        //$sheets[] = new PostExport();
        return $sheets;
    }
}

$lockKey = "redisKey";
$lock = new RedisLock();
$lock->Lock($lockKey,10);
// logic code
$lock->unLock($lockKey);