1. Go to this page and download the library: Download frictionlessdigital/macros 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/ */
frictionlessdigital / macros example snippets
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Collection;
use Illuminate\Routing\Router;
use Laravel\Dusk\Browser;
return [
/*
|--------------------------------------------------------------------------
| Laravel\Dusk\Browser Macros
|--------------------------------------------------------------------------
| To install
| composer |--------------------------------------------------------------------------
| Illuminate\Database\Eloquent\Builder
|--------------------------------------------------------------------------
| Enabled by default
|
*/
Builder::class => [
'toSqlWithBindings' => \Fls\Macros\Macros\Builder\ToSqlWithBindings::class,
],
/*
|--------------------------------------------------------------------------
| Carbon\Carbon
|--------------------------------------------------------------------------
| startOfFiscalYear($at = null) will return the return of fiscal year
|
*/
Carbon::class => [
'fiscalYearForHumans' => \Fls\Macros\Macros\Carbon\FiscalYearForHumans::class,
'startOfFiscalYear' => \Fls\Macros\Macros\Carbon\StartOfFiscalYear::class,
'endOfFiscalYear' => \Fls\Macros\Macros\Carbon\EndOfFiscalYear::class,
'isFiscalYear' => \Fls\Macros\Macros\Carbon\IsFiscalYear::class,
],
/*
|--------------------------------------------------------------------------
| Illuminate\Support\Collection
|--------------------------------------------------------------------------
| oxford()
'providers' => [
/*
* Package Service Providers...
*/
Fls\Macros\MacrosServiceProvider::class,
$x = Carbon::now()->fiscalYearForHumans()
// $x = 'Fiscal year ending March 31, 2022';
$x = Carbon::now()->fiscalYearForHumans(fn($at) => new HtmlString('<b>'.$at->year.'</b>'));
// $x = HtmlString('<b>2022</b>');
Carbon::startOfFiscalYear();
// Carbon instance at April 1, 2021 0:0:0;
Carbon::endOfFiscalYear();
// Carbon instance at March 31, 2022 25:59:59;
// assuming now is
Carbon::parse('March 31, 2022')->isFiscalYear(2021);
// true
Carbon::parse('April 1, 2022')->isFiscalYear(2021);
// false
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.