seffeng / laravel-helpers by seffeng

PHP laravel extension helpers
3,473
0
2
Package Data
Maintainer Username: seffeng
Maintainer Contact: save.zxf@gmail.com (seffeng)
Package Create Date: 2020-05-21
Package Last Update: 2024-06-12
Home Page: https://packagist.org/packages/seffeng/laravel-helpers
Language: PHP
License: MIT
Last Refreshed: 2024-12-22 15:01:17
Package Statistics
Total Downloads: 3,473
Monthly Downloads: 22
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Laravel Helpers

安装

# 安装
$ composer require seffeng/laravel-helpers

目录说明

└─src
    └─Helpers
        Arr.php
        Json.php
        ReplaceArrayValue.php
        TimeHelper.php
        UnsetArrayValue.php

示例

/**
 * TestController.php
 * 示例
 */
namespace App\Http\Controllers;

use Seffeng\LaravelHelpers\Helpers\Arr;
use Seffeng\LaravelHelpers\Helpers\Json;
use Seffeng\LaravelHelpers\Helpers\TimeHelper;
use Seffeng\LaravelHelpers\Helpers\ReplaceArrayValue;

class TestController extends Controller
{
    public function index()
    {
        $arr = [
            'a' => [
                'b' => [
                    'c' => 'ccc'
                ]
            ],
            'd' => [
                'b' => 'ccc',
                'e' => [
                    'f' => 'hhh'
                ]
            ]
        ];
        echo '<pre>';
        var_dump(Arr::get($arr, 'a.b.c', ''));
        var_dump(Arr::getDepth($arr));
        print_r(Arr::getColumn($arr, 'b'));
        print_r($arr);
        print_r(Arr::merge($arr, [
            'd' => new ReplaceArrayValue(['hhh' => 'iii']),
            'i' => [
                'j' => 'kkk'
            ]
        ]));
        $json = Json::encode($arr);
        var_dump($json);
        print_r(Json::decode($json));
        var_dump(TimeHelper::asWeekCN(time()));
    }
}

备注