jgravois

Technical Manager at Universal Asset Management

Member Since 6 Years Ago

Memphis

Experience Points
155,365
Total
Experience

4,635 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
1507
Lessons
Completed
Best Reply Awards
2
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 32
155,365 XP
Jan
21
1 day ago
Activity icon

Replied to Laravel Forge: Scheduled Artisan Commands Not Running

I got it ... thanks for the help

the command was missing the '/' in front of /home/forge/www.my-uam.com/artisan

Activity icon

Replied to Laravel Forge: Scheduled Artisan Commands Not Running

It actually does exist .. Forge is just lying

-rw-rw-r--  1 forge forge       61 Jan 21 15:43 scheduled-795365.log
Activity icon

Replied to Laravel Forge: Scheduled Artisan Commands Not Running

I did and I get the same message

Command: php home/forge/www.my-uam.com/artisan schedule:run
cat: /home/forge/.forge/scheduled-795365.log: No such file or directory
Activity icon

Replied to Laravel Forge: Scheduled Artisan Commands Not Running

In Forge if I click info next to the scheduled jobs on the scheduler tab I see this

Scheduled Job Log (795365)
×
Command: php home/forge/www.my-uam.com/artisan schedule:run
cat: /home/forge/.forge/scheduled-795365.log: No such file or directory

No errors though

Activity icon

Replied to Laravel Forge: Scheduled Artisan Commands Not Running

I thought the setup was per documentation which is why I am so confused.

At the end of each of those commands I write a last_run to my database and according to that table, they are only running when I manually trigger them

Activity icon

Started a new Conversation Laravel Forge: Scheduled Artisan Commands Not Running

I am trying to figure out why the scheduled commands are running as scheduled. This is how it is set-up.

Scheduler Tab: https://share.getcloudapp.com/xQuYBy7G

Daemon Tab: https://share.getcloudapp.com/yAuZwd06

kernel.php

protected function schedule(Schedule $schedule)
    {
        $schedule->command('telescope:prune')->daily();
        $schedule->command('database:backup')->daily();
        $schedule->command('media-library:delete-old-temporary-uploads')->daily();

        $schedule->command('uam:troll-sales-day')
            ->timezone('UTC')
            ->weekdays()
            ->everyFiveMinutes()
            ->environments('production');

        $schedule->command('uam:troll-shipments')
            ->weekdays()
            ->everyMinute()
            ->environments('production');

        $schedule->command('uam:troll-quotes')
            ->weekdays()
            ->everyThirtyMinutes()
            ->environments('production');

        $schedule->command('uam:troll-project-totals')
            ->weekdays()
            ->everyThirtyMinutes()
            ->environments('production');

        $schedule->command('uam:troll-lot-parts-sold')
            ->weekdays()
            ->everyThirtyMinutes()
            ->environments('production');
    }
Jan
19
3 days ago
Activity icon

Awarded Best Reply on Can't See Why A Property Is Needed On The Parent

disregard ... doing this differently

Activity icon

Replied to Can't See Why A Property Is Needed On The Parent

disregard ... doing this differently

Activity icon

Started a new Conversation Can't See Why A Property Is Needed On The Parent

I have a child component with a view surrounded by @if and want to toggle a salesperson to assign them to that company and the child component should then be hidden.

Whenever I click the checkbox for Duncan, I get Property [$duncan] not found on component: [customers.company-harvest] and the same for the other 4 sales leads.

In my thinking, the parent shouldn't be involved.

COMPONENT: https://gist.github.com/a0f4c38b0051d08abe5a70be1d677df2

VIEW: https://gist.github.com/37dcb858662342486f56d546703f6090

PARENT: https://gist.github.com/3dfe2756188e5be6fba9aab77f5aaabe

PARENT VIEW: https://gist.github.com/69906e17c52894b260f0ec608c036c6b

BTW, I am pretty sure this is not the best way to do this but I didn't know how else to handle the fact that the database wants a user_id and the checkboxes want a boolean. Also, the dataset is too large to refresh and stay usable so I needed to find a way to "dwindle a list" without refresh.

Activity icon

Replied to Target Class [config] Does Not Exist.

TEST

/** @test */
    public function a_denied_party_can_be_identified(): void
    {
        $check = DeniedParty::check('GASOLINERA RECURSOS HIDRAULICOS');

        dump($check);

        $this->assertEquals("NOCHECK", $check['status']);
    } // end test
Activity icon

Started a new Conversation Target Class [config] Does Not Exist.

$srch = Http::withHeaders(['Authorization' => config('services.itar.basic')])->get($path)->json();

test returns

Illuminate\Contracts\Container\BindingResolutionException : Target class [config] does not exist.
Jan
18
4 days ago
Activity icon

Replied to Production Is Down Due To Composer 2 And PSR-4

sometimes IDEs spoil us, eh?

I was wondering if you use Forge???

If you do, I need to replace a site with a brand new repo ... would you recommend blowing the old one away completely and starting from fresh or is there a safer way?

Activity icon

Replied to Production Is Down Due To Composer 2 And PSR-4

well, the reason it is down in production is that it is layouts as the folder name in the git repo

Activity icon

Replied to Production Is Down Due To Composer 2 And PSR-4

so do I change the folder to lowercase and the namespace?

Activity icon

Replied to Production Is Down Due To Composer 2 And PSR-4

I tried namespace app\View\Components\Layout because the app folder is lowercase but that didn't work

Activity icon

Replied to Production Is Down Due To Composer 2 And PSR-4

that's where I was looking but the folder is Layouts

https://share.getcloudapp.com/p9ur1OJj

Activity icon

Started a new Conversation Production Is Down Due To Composer 2 And PSR-4

Class App\View\Components\Layouts\App located in ./app/View/Components/layouts/App.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201

it's in the app\View\Components\Layouts\App.php

<?php

namespace App\View\Components\Layouts;

use Illuminate\View\Component;

class App extends Component
{
    public function __construct()
    {
        //
    }

    public function render()
    {
        return view('layouts.app');
    }
}

I don't see the error to fix

Jan
15
1 week ago
Activity icon

Replied to Need To Upgrade To Composer 2 On Forge Server

DUH! SUDO!!! dammit!

Thanks!

Activity icon

Started a new Conversation Need To Upgrade To Composer 2 On Forge Server

I am running production on Digital Ocean via Forge ... the current composer version is 1.10.19 ... I can't composer self-update --2 because of this

[Composer\Downloader\FilesystemException]
  Filesystem exception:
  Composer update failed: "/usr/local/bin/composer" could not be written.
  rename(/home/forge/.composer/cache/composer-temp.phar,/usr/local/bin/composer): Permission denied

I am not a "server guy" so would love safe suggestion.

I found this but not sure if it is safe for Forge server

composer
sudo apt-get remove composer
cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Jan
14
1 week ago
Activity icon

Replied to Mapping A Collected Array Is Returning Way Too Much

sorry I guess I am dense ...

95% of the time the gp_percent is going to be different. So I think the "N+1" is unavoidable.

Activity icon

Replied to Mapping A Collected Array Is Returning Way Too Much

so I can't insert local data into an API response?

Activity icon

Started a new Conversation Mapping A Collected Array Is Returning Way Too Much

I have a component which is grabbing an array of arrays from an internal API and I need to add an additional field from a local database table.

public function fetchData()
    {
        $troll = Http::withHeaders([
            'accept' => 'application/json',
            'Authorization' => config('services.quantum.basic')
        ])
            ->get('https://the_source.com/api/stock/pn_search/' . $this->pn)
            ->json();

        $mapped = collect($troll['data'])->map(function ($i) {
            $i['gp_percent'] = ($i['consignment_code'] ? ProjectFin::whereLotCode($i['consignment_code'])->first()->pluck('current_rate') : 0);
            return $i;
        })->toArray();

        $this->fetched = true;
        return $mapped;
    } // end function

in the gp_percent field, I am expecting something like 0.398 but instead I am getting

[0.372,0.337,0.188,0.05,0.95,0.398,0.05,0.95,0.389,0.95,0.29,0.301,0.422,0.05,0.05,0.95,0.95,0.718,0.221,0.221,0.404,0.36,0.341,0.95,0.258,0.95,0.35,0.05,0.15,0,0,0,0,0.15,0.05,0.05,0.05,0.05,0,0.15,0,0,0,0.15,0.175,0,0.2,0.15,0.15,null,0.1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0.15,null,null,0,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,0.01,0.15,0.15,0.15,1,1,0.15,0.15,0.15,0.15,0.13,0.13,0.13,1,0.1,0.1,0.2,1,0.2,0.2,1,1,1,1,0.05,1,1,1,1,0.15,0.15,0.15,1,1,1,1,1,1,1,1,1,1,1,1,1,0.15,0.15,0.15,0.15,0.15,0.15,1,1,0.1,0.2,0,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.05,1,1,1,0,1,0.1,0.1,0.1,0.1,0.1,0.1,1,1,0.05,0.05,1,1,0.3,0.3,0.18,0.2,0.2,0.15,0.15,0.15,0.15,0.15,0.05,0.05,1,0.05,1,1,0.1,0.1,0.1,1,1,1,1,1,0.05,1,1,1,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.1,0.15,0.3,1,0.2,1,1,0.15,0.15,0.2,0.2,0.2,0.2,0.5,0.15,0.3,0.3,0.15,0.15,0.05,0.05,0.15,0.18,0.2,1,0.2,1,0.15,1,0.2,0.18,0.3,0.15,0.15,0.18,0.2,0.15,null,0.13,0.4,0.2,0.5,0.1,0.15,0.05,0.05,0.05,0.1,0.05,1,0.05,0.05,1,1,0.5,1,0.05,1,0.2,0.2,0.05,0.2,0.05,0.05,0.05,1,1,0.2,0.15,0.15,0.15,0.15,0.15,0.15,0.15,0.15,0.15,0.15,0.15,0.05,0.2,0.2,0.2,0.18,0.18,0.15,0.15,0.15,0.15,0.05,0.2,0.05,0.25,0.25,0.25,0.25,0.25,0.05,0.2,0.2,1,0.15,0.15,0.05,0,1,0.15,0.15,1,1,1,1,1,1,1,0.05,0.15,0.05,1,1,1,1,1,1,0.15,0.15,1,1,1,0.05,0.3,0.1,1,0.5,1,0.2,0.05,0.2,0.15,0.2,1,1,1,1,1,1,1,0.05,0.15,0.15,0.15,0.15,0.15,0.15,1,0.15,0.13,0.15,0.13,0.13,0.13,0.13,0.13,0.2,0.13,0.13,0.13,0.13,0.13,0.2,0.13,0.2,0.13,0.2,0.13,0.1,0.13,0.13,1,0.2,0.15,0.05,1,0.25,0.25,0.25,1,1,0.1,1,1,1,1,1,1,0.15,0.15,0.175,1,0.05,0.05,1,0.05,1,0.05,1,1,1,1,0.1,1,0.1,null,0.15,0.15,null,null,null,0.15]

NOT WHAT I EXPECTED!

Dec
29
3 weeks ago
Activity icon

Started a new Conversation Trying To Get Subtotals From A Collection

I am lost in this collection ...

I have a bunch of records like these:

Illuminate\Database\Eloquent\Collection {#3627
     all: [
       App\Models\ArAging {#3703
         id: 3,
         amt: 1500.0,
         balance: 1500.0,
         city: "Atlanta",
         company_code: "DLA",
         company_name: "XXX Airlines ",
         due_date: "2021-01-21",
         due_days: 45,
         entry_date: "2020-12-07",
         max_credit: 3300000.0,
         term_code: "NET 45",
       },
       App\Models\ArAging {#4202
         id: 31,
         amt: 1250000.0,
         balance: 1250000.0,
         city: "Bismark",
         company_code: "AZI3",
         company_name: "XXX Engines",
         due_date: "2020-12-10",
         due_days: 60,
         entry_date: "2020-11-28",
         max_credit: 50000000.0,
         term_code: "NET 60",
       },
       App\Models\ArAging {#4246
         id: 76,
         amt: 800.0,
         balance: 2300.0,
         city: "Atlanta",
         company_code: "DLA",
         company_name: "XXX Airlines ",
         due_date: "2020-12-12",
         due_days: 45,
         entry_date: "2020-10-28",
         max_credit: 3300000.0,
         term_code: "NET 45",
       }]

You can see the companies can have one or more records and they are mixed up. I am trying to extract a "subtotal" line by company.

$reporter = [];
$raw = ArAging::all();

$companies = $raw->pluck('company_code')->unique();

foreach($companies as $company) {
	$comp = $raw->filter(fn($co)=>$co->company_code == $company);
  
  	$code = $comp->pluck('company_code')->unique();

	$name = $comp->pluck('company_name')->unique();

	$credit_limit = $comp->pluck('max_credit')->unique();

	$terms = $comp->pluck('term_code')->unique();
  
  	$sales = $comp->sum('amt');
  
  	$balance = $comp->last()->balance;
  
  $reporter[] = [
  	'company_code' => $code,
    'company_name' => $name,
    'credit_limit' => $credit_limit,
    'terms' => $terms,
    'sales' => $sales,
    'balance' => $balance
  ];
} // end foreach

return $reporter;

This is returning

[!] Aliasing 'ArAging' to 'App\Models\ArAging' for this Tinker session.
=> [
     "company_code" => Illuminate\Support\Collection {#4247
       all: [
         "DLA",
       ],
     },
     "company_name" => Illuminate\Support\Collection {#4127
       all: [
         "XXX Airlines ",
       ],
     },
     "credit_limit" => Illuminate\Support\Collection {#4041
       all: [
         3300000.0,
       ],
     },
     "terms" => Illuminate\Support\Collection {#4146
       all: [
         "NET 45",
       ],
     },
     "sales" => 4800.0,
     "balance" => 2300.0,
   ]

rather than what I am looking for

[
    'company_code' => 'DLA',
    'company_name' => 'XXX Airlines',
    'credit_limit' => 3300000.0,
    'terms' => 'NET 45',
    'sales' => 4800.0,
    'balance' => 2300.0
  ]
Dec
19
1 month ago
Activity icon

Replied to Comparing Passwords Not Working

Thanks!!!

@if(Hash::check(auth()->user()->default_password, auth()->user()->password))

Activity icon

Replied to Comparing Passwords Not Working

The banner displays with @if(true)

Activity icon

Started a new Conversation Comparing Passwords Not Working

Our HR department issues a password to new users which is very insecure. I have lobbied to have that changed but ...

Anyway, I am adding a notification below the navbar to request a change but it is not showing using the following code:

@if(Hash::check(auth()->user()->password, bcrypt(auth()->user()->default_password)))
        <div class="w-full h-12 bg-red">
            <div class="px-4 py-1 flex justify-between items-center">
                <span>
                    <p class="text-xl text-white">
{{--                        {{auth()->user()->password}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{auth()->user()->default_password}}--}}
                        You are using the default (insecure) password. You <strong>must</strong> change it now in your profile.
                    </p>
                </span>
                <span>
                    <a href="/profile">
                        <x-buttons.white>Profile</x-buttons.white>
                    </a>
                </span>
            </div>
        </div>
    @endif
Dec
16
1 month ago
Activity icon

Started a new Conversation Chartisan/ChartJS - Using DataLabel Plugin

I am using Laravel Dashboard Chart Title package with the excellent Spatie Laravel Dashboard package.

I am trying to install and use the chartjs-plugin-datalabels plugin.

The docs say chartjs-plugin-datalabel must be loaded after the Chart.js library!

I have this in app/config/dashboard.php but the labels are not appearing and I have no console errors.

'tiles' => [
    'charts' => [
        'refresh_interval_in_seconds' => 300,
        'scripts' => [
            'chart' => 'https://unpkg.com/[email protected]/dist/Chart.min.js',
            'chartisan' => 'https://unpkg.com/@chartisan/[email protected]*/dist/chartisan_chartjs.umd.js',
            'moment' => 'https://unpkg.com/[email protected]/min/moment-with-locales.min.js',
            'datalabels' => 'https://cdn.jsdelivr.net/npm/[email protected]'
        ],
 ],

And in the chart class I have

public function options(): array
    {
        return [
            'responsive' => true,
            'maintainAspectRatio' => false,
            'legend' => [ 'display' => false ],
            'barWidth' => 0.8,
            'scales' => [
                'xAxes' => [
                    [
                        'gridLines' => [
                            'display' => true,
                            'color' => '#39393A'
                        ],
                        'ticks' => [
                            'fontColor' => "#FFFFFF",
                            'fontSize' => 16
                        ]
                    ],
                ],
                'yAxes' => [
                    [
                        'gridLines' => [
                            'display' => true,
                            'color' => '#989898',
                            'zeroLineColor' => 'red',
                            'zeroLineWidth' => 4
                        ],
                        'ticks' => [
                            'fontColor' => "#FFFFFF",
                            'fontSize' => 12,
                            'beginAtZero' => true
                        ]
                    ],
                ],
            ],
            'plugins' => "{
                datalabels: {
                    color: 'white',
                    font: {
                        size: 16,
                        weight: 'bold'
                    },
                    formatter: (value) => `\$${value.toLocaleString()}`
                }
            }"
        ];
    } // end function
Dec
14
1 month ago
Activity icon

Started a new Conversation Creating A Laravel 8 Factory With Polymorphic

Given this migration

Schema::create('tasks', function (Blueprint $table) {
       $table->id();
       $table->morphs('assignable');
       $table->integer('sort_order')->nullable();
       $table->foreignId('user_id')->nullable();
       $table->foreignId('assigner_id')->nullable();
       $table->string('title')->nullable();
       $table->text('body')->nullable();
       $table->date('assigned_date')->nullable();
       $table->date('due_date')->nullable();
       $table->date('completed_on')->nullable();
       $table->timestamps();
});

I can't find in the docs how to create the factory for $table->morphs('assignable');

public function definition()
{
    return [
        //'assignable',
        'sort_order' => 1,
        'user_id' => User::factory(),
        'assigner_id' => User::factory(),
        'title' => $this->faker->sentence,
        'body' => $this->faker->paragraph,
        'assigned_date' => Carbon::yesterday(),
        'due_date' => Carbon::tomorrow(),
        'completed_on' => null,
    ];
}
Activity icon

Started a new Conversation Polymorphic Relationship Setup

I have tasks that can be assigned from several models -- a user can be assigned an "opportunity" task, a "deal" task, a "project" task, a "workscope" task, a "receiving" task, etc.

so I have a TASK migration like this:

Schema::create('tasks', function (Blueprint $table) {
            $table->id();
            $table->integer('sort_order')->nullable();
            $table->foreignId('assigner_id')->nullable();
            $table->string('title')->nullable();
            $table->text('body')->nullable();
            $table->date('assigned_date')->nullable();
            $table->date('due_date')->nullable();
            $table->timestamps();
        });

The assigned_user and the task type is not there yet.

Do I just need to add the user_id and task_type_id or should this be polymorphic??? If polymorphic, does the $table->morphs('assignable') go in the Task migration or do I need a pivot table?

I know I will want to get remaining tasks for let's say the project with $project->tasks and I will want to grab all of a user's tasks with $user->tasks and I am confused about the structure.

Dec
11
1 month ago
Activity icon

Replied to Forge Is Not Running Scheduled Commands

little paper icon gives me this with forge as user

cat: /home/forge/.forge/scheduled-774889.log: No such file or directory

(at least it is not permission denied)

Activity icon

Started a new Conversation Forge Is Not Running Scheduled Commands

I have been monitoring and the commands I have scheduled are not running.

On the Scheduler tab, I have this command set to run every minute by the root user

Command: /home/forge/avtechnix.com/artisan schedule:run

If I click the paper icon next to that command I see

/bin/sh: 1: /home/forge/avtechnix.com/artisan: Permission denied

This is my scheduler

protected function schedule(Schedule $schedule)
    {
        $schedule->command('telescope:prune')->daily();
        $schedule->command('database:backup')->daily();
        $schedule->command('media-library:delete-old-temporary-uploads')->daily();
        $schedule->command('uam:set-overdue-in-masters')->daily();
        $schedule->command('uam:refresh-models')->daily();
        $schedule->command('uam:troll-sales-totals')
            ->weekdays()
            ->everyTenMinutes()
            ->environments('production');
        $schedule->command('uam:troll-sales-day')
            ->timezone('UTC')
            ->weekdays()
            ->everyFiveMinutes()
            ->environments('production');
        $schedule->command('uam:troll-sales-month')
            ->timezone('UTC')
            ->weekdays()
            ->everyTenMinutes()
            ->environments('production');
        $schedule->command('uam:troll-open-sales')
            ->weekdays()
            ->everyThirtyMinutes()
            ->environments('production');
        $schedule->command('uam:troll-new-repairs')
            ->weekdays()
            ->everyTenMinutes()
            ->environments('production');
        $schedule->command('uam:troll-shipments')
            ->weekdays()
            ->everyMinute()
            ->environments('production');
        $schedule->command('uam:troll-quotes')
            ->weekdays()
            ->everyThirtyMinutes()
            ->environments('production');
    }
Activity icon

Replied to Livewire-DataTable -- Filtering

there is a last_edit column that is set to today() whenever any of the key fields of a master is edited. I run a 2am troll via Artisan to check if any masters are overdue based on business rules (each category has different days requirements).

Activity icon

Replied to Livewire-DataTable -- Filtering

@tykus I added a boolean to that model called overdue so the filter works.

I need to set that boolean to false when that part is updated so I added this to the model

protected static function boot()
{
    parent::boot();
    PartMaster::saving(function ($model) {
        $model->overdue = false;
    });
} // end function

If I read the docs correctly, any record created or updated will no longer be overdue ... I am just confirming this.

Activity icon

Started a new Conversation Livewire-DataTable -- Filtering

I have a massive dataset so pagination is essential.

Following the excellent videos on datatables by Caleb, I have the following working query/pagination combo:

public function getRowsQueryProperty()
    {
        $query = PartMaster::query()
            ->when($this->filters['cat'], fn($query) => $query->where('cat', $this->filters['cat']))
            ->when($this->filters['eu'], fn($query) => $query->where('eu', $this->filters['eu']))
            ->when($this->filters['description'], fn($query) => $query->where('description', 'like',  '%'.$this->filters['description'].'%'))
            ->when($this->filters['variance'], fn($query) => $query->where('variance'))
            ->when($this->filters['repair'], fn($query) => $query->where('should_repair'))
            ->when($this->filters['performer'], fn($query) => $query->where('top_performer'))
            ->when($this->filters['amount-min'], fn($query, $amount) => $query->where('model_value', '>=', $amount))
            ->when($this->filters['amount-max'], fn($query, $amount) => $query->where('model_value', '<=', $amount))
            ->when($this->filters['search'], fn($query) => $query->where('part_number', 'like',  '%'.$this->filters['search'].'%'));

        return $this->applySorting($query);
    } // end function

    public function getRowsProperty()
    {
        // if($this->filters['overdue']) {
            //return $this->rowsQuery->filter(function($i){
               // return $i->overdue;
            //})->paginate($this->perPage);
        //} else {
            return $this->cache(function () {
                return $this->rowsQuery->paginate($this->perPage);
            });
        //} // end if
    } // end function

In the getRowsProperty I am trying to further filter the results (I think I have to do it here because overdue is an mutator value and not a database column). If I uncomment those lines, I get the Call to undefined method Illuminate\Database\Eloquent\Builder::filter() which makes sense since it isn't a collection.

BUT I don't know how to use that mutator to limit the rows.

Dec
10
1 month ago
Activity icon

Replied to Finding The Current Period From An Array

if I start with the deal's close date (which is the 0th value in the array), I can get the period with

(Carbon::parse($project->timeline->close))->diffInQuarters(now());

so should I check if deal is still within range and use this and if not, use @michaloravec's solution?

@tykus I am still trying to figure yours out ... LOL

Activity icon

Replied to Finding The Current Period From An Array

$data[3] = '01-Nov-20' which we have passed

$data[4] = "01-Feb-21" which we have not reached

Activity icon

Replied to Finding The Current Period From An Array

so I need 1/3 of the response for the index, right

no, that's wrong, hmmmm

Activity icon

Replied to Finding The Current Period From An Array

I am expecting 3 for this one

Activity icon

Replied to Finding The Current Period From An Array

"you rained on my joy parade" ...

that is relevant

$data = [
     "07-Feb-20",
     "01-May-20",
     "01-Aug-20",
     "01-Nov-20",
     "01-Feb-21",
     "01-May-21",
     "01-Aug-21",
     "01-Nov-21",
     "01-Feb-22",
     "01-May-22",
     "01-Aug-22",
     "01-Nov-22",
     "01-Feb-23",
   ];

$result = now()->diffInQuarters(Carbon::parse(end($periods)), false);

returns 8 and $data[8] = "01-Feb-22";

it should be 3

DAMN!

Activity icon

Replied to Finding The Current Period From An Array

OMG!

diffInQuarters()???

Activity icon

Started a new Conversation Finding The Current Period From An Array

I am so not sure how to tackle this one ...

I get an array like this from another method --

[
     "08-Mar-17",
     "01-Jun-17",
     "01-Sep-17",
     "01-Dec-17",
     "01-Mar-18",
     "01-Jun-18",
     "01-Sep-18",
     "01-Dec-18",
     "01-Mar-19",
     "01-Jun-19",
     "01-Sep-19",
     "01-Dec-19",
     "01-Mar-20",
   ]

each period is 3 months long.

I need to determine the "current" period and/or if the project is failing, the "period" is negative. So in this example the "current period" is -3. (How that for specs ... LOL).

Dec
05
1 month ago
Activity icon

Started a new Conversation Asantibanez/livewire-charts - Adding Data Labels

Package: https://github.com/asantibanez/livewire-charts

In the Charts API section of the package's Readme, in the all section, I see withDataLabels() | Enables data labels so I tried that in the demo app like this:

$columnChartModel = $expenses->groupBy('type')
            ->reduce(function (ColumnChartModel $columnChartModel, $data) {
                $type = $data->first()->type;
                $value = $data->sum('amount');

                return $columnChartModel->addColumn($type, $value, $this->colors[$type]);
            }, (new ColumnChartModel())
                ->setTitle('Expenses by Type')
                ->withDataLabels()
                ->setAnimated($this->firstRun)
                ->withOnColumnClickEventName('onColumnClick')
            );

but I get

Call to undefined method Asantibanez\LivewireCharts\Models\ColumnChartModel::withDataLabels()

The charts we use are on TVs mounted on the wall so the hover feature is not very helpful to us. I am trying to find a way to display the value on a column chart?

Like this: https://share.getcloudapp.com/p9urPEmK

Dec
03
1 month ago
Activity icon

Replied to Blade Format Question

LOL ... $loop is undefined so I will just let the zebra out of the cage

Activity icon

Replied to Blade Format Question

what about the attributes???

Activity icon

Started a new Conversation Blade Format Question

I currently am using a blade component for table rows that looks like this:

<tr {{ $attributes->merge(['class' => 'bg-white h-12']) }}>
    {{ $slot }}
</tr>

I use it currently like this:

<x-table.row wire:loading.class.delay="opacity-50" wire:key="row-{{ $part->id }}">

I want to add this conditional without losing my opacity attribute:

<tr class="@if($loop->even) bg-gray-200 @else bg-white @endif">

I am not sure if I can use a {{}} INSIDE another {{}} or how I can add this additional condition.

Nov
29
1 month ago
Activity icon

Replied to Add/Remove An Item In Array (or Collection)

sorry I took so long to respond but I had setup for the early service this morning

Activity icon

Started a new Conversation Add/Remove An Item In Array (or Collection)

I have a row of icons in the Livewire Component like this screenshot ( https://share.getcloudapp.com/YEuQKx0q )

I want to be able to "select multiple" by clicking on them to add them to an empty collected array -- done!

I also want to be able to click a selected one and remove it from the array.

(Since I am using ->contains() I am thinking in terms of a collection but it's actually an array)

here's what I have in component

public $types = [];

public function setType($type)
{
    $types = collect($this->types);

    if($types->contains($type)) {
        $types->filter(function($i) use($type) {
            return $i !== $type;
        });
    } else {
        $this->types[] = $type;
    } // end if
}

and in the view

<div class="{{collect($types)->contains('phone-in') ? 'bg-red p-1 rounded-full' : ''}}">
    <span class="block bg-white p-1 rounded-full cursor-pointer"
                 data-wenk="Incoming Phone Call"
                 wire:click="setType('phone-in')">
         @svg('uam/phone-in', 'h-8 w-8 text-gray')
     </span>
</div>

I have also tried $types->forget($type); and $types->reject($type); and unset($this->types[$type]);