PHP code example of skybluesofa / laravel-wrapped-facade
1. Go to this page and download the library: Download skybluesofa/laravel-wrapped-facade 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/ */
skybluesofa / laravel-wrapped-facade example snippets
\App\Classes\SuperFruitsSuperFruits::getAll();
// Returns an array of fruits, just as we'd expect
\App\Classes\SuperFruitsSuperFruits::getAll();
// Returns an array of fruits, just as we'd expect
namespace App\Facades;
use App\Fruits;
use SkyBlueSofa\WrappedFacade\Facades\WrappedFacade;
class SuperFruits extends WrappedFacade
{
public static function getFacadeAccessor()
{
return Fruits::class;
}
protected static function postIndex(array $args, mixed $results): mixed
{
// In this example , the user hates 'Banana'
$hatedFruit = Auth::user()->mostHatedFruit;
return array_diff(
$results,
[$hatedFruit]
);
}
}
\App\Classes\SuperFruitsSuperFruits::getAll();
// Returns an array of fruits, sans Banana
[
1 => 'Apple',
2 => 'Carrot',
3 => 'Durifruit',
4 => 'Eggplant',
]
namespace App\Facades;
use App\Fruits;
use App\FruitValidator;
use SkyBlueSofa\WrappedFacade\Facades\WrappedFacade;
class SuperFruits extends WrappedFacade
{
public static function getFacadeAccessor()
{
return Fruits::class;
}
protected static $sideloadedMethodOrder = [
'postIndexValidate',
'postIndex',
];
protected static function postIndexValidate(array $args, mixed $results): mixed
{
// This is an example validator. How it works really doesn't matter.
$fruitValidator = new FruitValidator($results);
if (! $fruitValidator->validates()) {
throw new \RuntimeException('Fruit does not validate!');
}
return $results;
}
protected static function postIndex(array $args, mixed $results): mixed
{
// In this example , the user hates 'Banana'
$hatedFruit = Auth::user()->mostHatedFruit;
return array_diff(
$results,
[$hatedFruit]
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.