• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

plank / laravel-metable / 8731338116

18 Apr 2024 02:05AM UTC coverage: 97.685% (-1.1%) from 98.76%
8731338116

Pull #102

github

frasmage
test improvements
Pull Request #102: V6

238 of 248 new or added lines in 18 files covered. (95.97%)

5 existing lines in 1 file now uncovered.

422 of 432 relevant lines covered (97.69%)

65.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.65
/src/Commands/RefreshMeta.php
1
<?php
2

3
namespace Plank\Metable\Commands;
4

5
use Illuminate\Console\Command;
6
use Illuminate\Support\Facades\DB;
7
use Plank\Metable\Meta;
8

9
class RefreshMeta extends Command
10
{
11
    protected $signature = 'metable:refresh';
12

13
    protected $description = 'Re-encode all stored meta values to update types and indexes.';
14

15
    public function handle(): void
16
    {
17
        $this->info('Refreshing meta values...');
6✔
18

19
        $count = 0;
6✔
20
        $total = DB::table('meta')->count();
6✔
21
        $lastId = null;
6✔
22

23
        $progress = $this->output->createProgressBar($total);
6✔
24
        $progress->start();
6✔
25

26
        while ($count < $total) {
6✔
27
            $query = Meta::query()
6✔
28
                ->orderBy('id')
6✔
29
                ->limit(100);
6✔
30
            if ($lastId) {
6✔
NEW
31
                $query->where('id', '>', $lastId);
×
32
            }
33

34
            $collection = $query->get();
6✔
35
            /** @var Meta $meta */
36
            foreach ($collection as $meta) {
6✔
37
                $value = $meta->value;
6✔
38
                $meta->setValueAttribute(null);
6✔
39
                $meta->setValueAttribute($value);
6✔
40
                $meta->save();
6✔
41
                $count++;
6✔
42
                $progress->advance();
6✔
43
                $lastId = $meta->id;
6✔
44
            }
45
        }
46

47
        $progress->finish();
6✔
48

49
        $this->info('Refresh complete.');
6✔
50
    }
51

52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc