PHP code example of abordage / eloquent-percentile
1. Go to this page and download the library: Download abordage/eloquent-percentile 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/ */
abordage / eloquent-percentile example snippets
use App\Models\Post;
$posts = Post::withMedian('comments', 'votes')->get();
foreach ($posts as $post) {
echo $post->comments_median_votes;
}
use App\Models\Post;
$posts = Post::withPercentile('comments', 'votes', 0.85)->get();
foreach ($posts as $post) {
echo $post->comments_percentile85_votes;
}
namespace App\Support\IdeHelper;
use App\Models\Post;
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
use Barryvdh\LaravelIdeHelper\Contracts\ModelHookInterface;
use Illuminate\Database\Eloquent\Model;
class PostHook implements ModelHookInterface
{
public function run(ModelsCommand $command, Model $model): void
{
if (!$model instanceof Post) {
return;
}
$command->setProperty('comments_median_votes', 'float|null', true, false);
$command->setProperty('comments_percentile80_votes', 'float|null', true, false);
$command->setProperty('comments_percentile95_votes', 'float|null', true, false);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.