jgravois

Technical Manager at Universal Asset Management

Member Since 6 Years Ago

Memphis

Experience Points
160,475
Total
Experience

4,525 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
1540
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 33
160,475 XP
Apr
28
1 week ago
Activity icon

Replied to How Can I Add A Series Of Commands To Forge's Quick Deploy

This is the start of my command (never written one like THIS before):

public function handle(): int
    {
        exec("cd public");
        exec("pwd", $output);

        $this->comment( implode( PHP_EOL, $output ) );

        return 0;
    } // end function

The output is /Users/jongravois/code/eight which is the root of the app. It appears as though it ignored the ``change directory``` command.

Apr
27
1 week ago
Activity icon

Started a new Conversation How Can I Add A Series Of Commands To Forge's Quick Deploy

I have to run these commands after every deployment or else I lose all of my symbolic links in production.

cd public
rm avatars
rm forms
rm media
rm occms
rm tickets
cd ..
php artisan storage:link

This is the current deploy script

cd /home/forge/www.my-uam.com
git stash
git pull origin master
$FORGE_COMPOSER install --no-interaction --prefer-dist --optimize-autoloader

( flock -w 10 9 || exit 1
    echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock

if [ -f artisan ]; then
    $FORGE_PHP artisan migrate --force
fi
Apr
20
2 weeks ago
Activity icon

Started a new Conversation Nested Blade Conditionals Cause Error

I have a nested @if() in the following blade block that is giving me this error:

syntax error, unexpected 'endforeach' (T_ENDFOREACH), expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF)
@if($expanded)
    @foreach($rows as $row)
        @if(\Illuminate\Support\Str::contains('Variance', $row->title))
            <x-table.thin-row class="bg-yellow-300">
        @else
            <x-table.thin-row>
        @endif

        <x-table.text-cell :value="$row->title"/>
        <x-table.currency-cell-br :value="$row['total']"/>
        <x-table.currency-cell :value="$row['mo1']"/>
        <x-table.currency-cell :value="$row['mo2']"/>
        <x-table.currency-cell :value="$row['mo3']"/>
        <x-table.currency-cell :value="$row['mo4']"/>
        <x-table.currency-cell :value="$row['mo5']"/>
        <x-table.currency-cell :value="$row['mo6']"/>
        <x-table.currency-cell :value="$row['mo7']"/>
        <x-table.currency-cell :value="$row['mo8']"/>
        <x-table.currency-cell :value="$row['mo9']"/>
        <x-table.currency-cell :value="$row['mo10']"/>
        <x-table.currency-cell :value="$row['mo11']"/>
        <x-table.currency-cell :value="$row['mo12']"/>
    </x-table.thin-row>
    @endforeach
@endif
Apr
15
3 weeks ago
Activity icon

Started a new Conversation Conditional Attachments In Mailable

How do I attach to a mailable if attachments exists?

so I have a table of form_uploads as a belongsTo relationship to forms (which uses hasMany).

The docs say this is how to attach

 return $this->view('emails.orders.shipped')
               ->attachFromStorageDisk('s3', '/path/to/file');

I may have one or more uploads on that form and I need a conditional way to attach them if they exist.

I currently have this in the mailable:

public function build(): AccidentFormReceived
{
    return $this->subject('Accident/Incident Form Submission')
        ->view('emails.QRF.AccidentSubmission');
}
Apr
14
3 weeks ago
Activity icon

Started a new Conversation Livewire Import Fails If Field Is Null

I am building a datatable like Caleb's in the Surge screencasts. I am mimicking the import csv portion.

Everything works great unless one of the fields in the CSV is empty giving me this error:

Undefined index: Alt. PN and points to this line: return [$field => $row[$heading]];.

This line is part of this function

public function extractFieldsFromRow($row): array
    {
        $attributes = collect($this->fieldColumnMap)
            ->filter()
            ->mapWithKeys(function($heading, $field) use ($row) {
                return [$field => $row[$heading]];
            })
            ->toArray();

        return $attributes + [
            'status' => 'onWing',
            'disassembly_id' => $this->disID,
            'lot_code' => $scope->registration ?? null,
        ];
    }

I am not well-versed with the collect()...filter()...mapWithKeys() construct Caleb is using but I tried the following to no avail to stop the error (and the failure to import)

return [$field => $row[$heading] ?? null];

This allowed the import but ALL of the fields in the column were missing not just the empty ones.

return [($row[$heading] ? $field => $row[$heading] : $field => null)];

This blocks the page from even loading with this error:

syntax error, unexpected '=>' (T_DOUBLE_ARROW)

I don't know how to account for empty cells and look forward to assistance.

Apr
04
1 month ago
Activity icon

Replied to Modify From ['ARRIVAL] To ARRIVAL

yes, I think that is very helpful.

This is a wierd Excel GUI that I am putting online for our Disassembly Team and it has tied me in knots for the last 6 days just trying to figure it out.

Given that there are 164 steps in 11 phases, accordions allow the page to be less intimidating on load.

  1. The phases and their steps are always the same so this is my first w-1/3 columns.
  2. The master is specific to an aircraft type (i.e. A-380) and has baseline performance -- # of techs, #of hours, etc so I need the second w-1/3 column to sync the collapse with the first.
  3. Finally the aircraft is specific to an aircraft and has actual performance and that will be the synced third w-1/3 column.

So do you think I am on the right track to set it up this way and use @entangle to sync the panel collapses.

Activity icon

Replied to Modify From ['ARRIVAL] To ARRIVAL

It's an "accordion" with the "phase" displayed and the records hidden and shown by Alpine

Activity icon

Started a new Conversation Modify From ['ARRIVAL] To ARRIVAL

I have a table (id, sort_order, phase, description).

My query is

$mock = DisStep::orderBy('sort_order')->get()->groupBy('phase');

I pass them to a blade component as such

@foreach($mock as $phase)
    <x-collapse.dis-panel :phase="$phase" />
@endforeach

To display I am using

<span class="font-bold text-lg uppercase text-gray-100">
    {{ collect($phase)->pluck('phase')->unique() }}
</span>

this gives me ["ARRIVAL"]

Do I need to use a complex string_replace to get ARRIVAL?

Apr
01
1 month ago
Activity icon

Replied to Deploy Error -- Help -- Production Is Down

It gave me errors about unresolved directories so I removed each symlink manually on the server and then ran php artisan storage:link and it worked.

I'm all good ... THANKS!!!

Activity icon

Replied to Deploy Error -- Help -- Production Is Down

@automica I need your help again ... I am sorry

Activity icon

Replied to Deploy Error -- Help -- Production Is Down

My image files are on my forge server ... but the symlink is pointing to my local computer and everything is broken

lrwxrwxrwx  1 forge forge     55 Apr  1 20:48 avatars -> /Users/jongravois/code/eight/storage/app/public/avatars

Should be linked here

/home/forge/www.my-uam.com/storage/app/public/avatars
Activity icon

Replied to Deploy Error -- Help -- Production Is Down

This is my gitignore

/node_modules
/public/hot
/public/storage
!/storage/app/public/avatars/*
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

Shouldn't files I put locally in /storage/app/public/avatars go to the repo????

Activity icon

Started a new Conversation Deploy Error -- Help -- Production Is Down

OMG, getting this and I don't know what to do

Thu Apr 1 20:24:48 UTC 2021
Saved working directory and index state WIP on master: df5bb8a Merge pull request #238 from UAM-DEV/staging
From github.com:UAM-DEV/eight
 * branch            master     -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
    public/avatars
Please move or remove them before you merge.
Aborting
Updating df5bb8a..19415d2
Activity icon

Started a new Conversation Spatie's MediaLibrary Pro Question

I am using Spatie's MediaLibraryPro -- the paperclip is showing up for all, even those that have no media. Should I write this differently?

@if(!empty($ticket->getMedia()))
   <span class="cursor-pointer wire:click="view('{{$ticket->id}}')">
      @svg('solid/paperclip', 'h-4 w-4 text-gray-700')
    </span>
 @endif

This is what Invoker tells me $ticket->getMedia()returns:

Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection {#3649
     all: [],
   }
Mar
23
1 month ago
Activity icon

Started a new Conversation Controlling Array Formation In Eloquent

I have a table like this:

dis_master_id: 1,
dis_step_id: 1,
est_time: 0.25,
techs: 1,
labor: 0.25,

dis_master_id: 1,
dis_step_id: 2,
est_time: 1.5,
techs: 4,
labor: 6,

dis_master_id: 1,
dis_step_id: 3,
est_time: 4.5,
techs: 2,
labor: 9,

I need to format DisassemblyMock::whereDisMasterId(1)->get(); or whatever eloquent query I need to use to return THIS

[
	[1] => [
		'est_time' => 0.25,
		'techs' => 1,
		'labor' => 0.25
	],
	[2] => [
		'est_time' => 1.5,
		'techs' => 4,
		'labor' => 6
	],
	[3] => [
		'est_time' => 3,
		'techs' => 2,
		'labor' => 9
	],
]

where the array key === dis_step_id

Mar
10
1 month ago
Activity icon

Replied to Ordering On Relationship With A Sub - Relationship

never thought of that approach ... thanks

Activity icon

Started a new Conversation Ordering On Relationship With A Sub - Relationship

The hasMany relationship on the model also has a hasOne relationship of 'baselines'.

How can I sort the steps but also include the baselines of each step???

DisGroup::with(['steps' => function($q) {
            $q->orderBy('sort_order');
        }])->whereId(1)->get();
Mar
04
2 months ago
Activity icon

Started a new Conversation Model Scope Not Respecting Relationship

On a Company model I have a relationship

public function caf(): HasOne
{
        return $this->hasOne(CompanyCustomerAgreement::class, 'company_id', 'id')->withDefault();
}

when the status of the Customer Agreement reaches 6, they are approved.

So I am trying to create a model scope to make finding these easier later on but it isn't working

public function scopeApproved($query)
{
    return $query->where('caf.status_id', '>=', 6);
} // end function
Feb
27
2 months ago
Activity icon

Replied to Refactor Weekly Scope To Use Week Number

@martinbean I think your suggestion is indeed the best idea. Right now I have 876 row Artisan Command that just resolves the monthly report and I am trying basically to re-create the same for the weekly report ... I need the scope you are suggesting but I am just not sure my level of expertise is up to it.

If you wouldn't mind, let me share my ideas so far (that have already stretched my level of understanding for the last 10 days) and ANY recommendations you could suggest I will follow.

LOLOL, can you tell I am FAR, FAR, FAR out of TutorialWorld here???

Screenshot of Monthly Report: https://share.getcloudapp.com/z8uPbAzj

PostedInvoice Model: https://gist.github.com/4f4e5b48de9ae378dbb5cc6336bb7ac2

Posted Trait: https://gist.github.com/bd25d22b4567a23989e587efea7e3748

Monthly Artisan Command: https://gist.github.com/765944c35953fd974a6270fc6fbf30ae

Report View: https://gist.github.com/339763452e1e3ae7aeb2abc9815eab70

Activity icon

Replied to Refactor Weekly Scope To Use Week Number

I think your year suggestion is a great idea for such a utility class so I tried to implement it as well and failed. I thought this would work

public function scopeWeeklyReport(Builder $query, $weekNumber = null, $year = null): Builder
    {
        if($year) {
            $date = Carbon::create($year);
        } else {
            $date = Carbon::now();
        } // end if

        if ($weekNumber) {
            $date->setISODate(date('Y'), $weekNumber);
        }

        return $query->whereBetween('post_date', [
            $date->startOfWeek()->format('Y-m-d'),
            $date->endOfWeek()->format('Y-m-d')
        ]);
    } // end function
Feb
26
2 months ago
Activity icon

Started a new Conversation Refactor Weekly Scope To Use Week Number

I have a loop where I have to return several datapoints in a weekly report and if I can refactor this model scope to use the number of the week rather than as current (a date), I can do it in a range[1,52] loop but I can't seem to get it to work.

this works when called like PostedInvoice::weeklyReport('2021-02-26')->get();

public function scopeWeeklyReport(Builder $query, $date = null): Builder
    {
        if(!$date) {
            $date = Carbon::now();
        } else {
            $date = Carbon::parse($date);
        } // end if

        return $query->whereBetween('post_date', [$date->startOfWeek()->format('Y-m-d'), $date->endOfWeek()->format('Y-m-d')]);
    } // end function

I would like to be able to do PostedInvoice::weeklyReport(8)->get();

Feb
19
2 months ago
Activity icon

Replied to Syntax For DYNAMIC Array Keys

LOL ... as usual, keep it simple, stupid

Activity icon

Started a new Conversation Syntax For DYNAMIC Array Keys

I have this

<x-table.thin-row>
    <x-table.text-cell :value="$row['title']"/>
    <x-table.currency-cell :value="$row['total']" />
    <x-table.currency-cell :value="$row['wk{{$initial}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+1}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+2}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+3}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+4}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+5}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+6}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+7}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+8}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+9}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+10}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+11}}']" />
    <x-table.currency-cell :value="$row['wk{{$initial+12}}']" />
    <x-table.cell class="m-0 p-0 w-4">&nbsp;</x-table.cell>
<x-table.thin-row>

I am getting Undefined index: wk<?php echo e($initial); ?>

I need to be able to map a group of columns to a set of 13 columns where the user can change the initial value and get the next 13 values.

My syntax is wrong.

Feb
10
2 months ago
Activity icon

Replied to Why Is A Child Component Erroring Because A Method Doesn't Exist On The Parent

that made the error go away but the child's method isn't called.

I added dd('clicked') to the method and nothing happens for wire:click.self="toggleExpanded".

I even turned the<span> into a <button> but no go

Activity icon

Started a new Conversation Why Is A Child Component Erroring Because A Method Doesn't Exist On The Parent

I have a component (sales.monthly-report) that is literally a view of 11 child components that should be be self-contained.

Each child has a twistie to expand that row to show its data. If I click on any of them, I get

Livewire\Exceptions\MethodNotFoundException
Unable to call component method. Public method [toggleExpanded] not found on component: [sales.monthly-report]

Each child has that method but Livewire overlooks it to ask for it in the parent.

For example

child component

<?php

namespace App\Http\Livewire\Reports;

use Livewire\Component;

class MonthlySalesRevenue extends Component
{
    public $sales = [];
    public $expanded = false;

    public function mount(): void
    {
        $this->sales = Sales::getTeam();
    } // end function

    public function render()
    {
        return view('livewire.reports.monthly-sales-revenue');
    } // end function

    public function toggleExpanded(): void
    {
        $this->expanded = !$this->expanded;
    } // end function
}

call in child

<span class="flex" wire:click="toggleExpanded">
    @if($expanded)
         @svg('solid/caret-down', 'mr-4 w-4 h-4 text-gray-700')
     @else
         @svg('solid/caret-right', 'mr-4 w-4 h-4 text-gray-700')
     @endif
      <strong>Sales Revenue</strong>
 </span>
Feb
09
2 months ago
Activity icon

Started a new Conversation Remove 'CMP/' From A HUGE Array

I have an array that starts like this and goes on for a whole bunch more.

[
     "CMP/452",
     "CMP/47",
     "CMP/A117"
]

I need to remove the "CMP/" part to have a list of company_codes.

$reporter = [];

foreach($arr as $cmp) {
	$reporter[] = explode("/", $cmp)[1];
}

Even giving this more time and more memory, I keep hitting the Memory Allocated error.

Is there a way to transform this into an iterator?

Feb
08
3 months ago
Activity icon

Replied to Storage Facade Not Deleting The Directory

 ls -la storage/app/public/tozip
total 360
drwxr-xr-x   4 jongravois  staff    128 Feb  8 06:48 .
drwxr-xr-x  17 jongravois  staff    544 Feb  8 06:48 ..
-rw-r--r--   1 jongravois  staff  70160 Feb  8 07:51 haggen_country_certificate.pdf
-rw-r--r--   1 jongravois  staff  51572 Feb  8 07:51 haggen_resale_certificate.pdf
Activity icon

Replied to Storage Facade Not Deleting The Directory

Through symbiotic link in /public

drwxr-xr-x 4 jongravois staff 128 Feb 8 06:48 tozip

Activity icon

Replied to Storage Facade Not Deleting The Directory

I am not sure and don't really know how to find out but this "user" created it, so can't we assume it has perms to delete it?

Activity icon

Started a new Conversation Storage Facade Not Deleting The Directory

I store files in DigitalOcean Spaces throughout a customer vetting process. At the end of the process, the admin can download a zip of these files to upload into our legacy operations system.

Finding no other way, I am downloading the files from Spaces to a local storage directory, creating the zip and then, I want to clean up to prevent a huge redundancy of files but the storage directory (storage_path('app/public/tozip')) is not being deleted.

public function zipAndGo()
    {
        $fldr = '/CMP/' . $this->company->company_code . '/';

        foreach($this->docs as $doc) {
            Storage::disk('zipper')->put(
                $doc->file_name,
                Storage::disk('spaces')->get($fldr . $doc->file_name));
        } // end foreach

        $zip = new ZipArchive;

        $fileName = strtolower($this->company->company_code) .'_caf_docs.zip';
        $files = File::files(storage_path('app/public/tozip'));

        if ($zip->open(public_path($fileName), ZipArchive::CREATE) === TRUE) {
            foreach ($files as $key => $value) {
                $relativeNameInZipFile = basename($value);
                $zip->addFile($value, $relativeNameInZipFile);
            } // end foreach

            $zip->close();
        } // end if

        Storage::deleteDirectory(storage_path('app/public/tozip'));

        return response()->download(public_path($fileName));
    } // end function
Feb
06
3 months ago
Activity icon

Replied to Works In Tinkerwell But Fails With Undefined Offset In Browser

dd($this->id); 2

dd($w9);

Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection {#898 ▼
  +collectionName: null
  +formFieldName: null
  #items: []
}

dd($sales);

Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection {#611 ▼
  +collectionName: null
  +formFieldName: null
  #items: array:1 [▼
    0 => App\Models\Media {#500 ▼
      #table: "media"
      #guarded: []
      #casts: array:4 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:18 [▶]
      #original: array:18 [▼
        "id" => 24
        "model_type" => "App\Models\Company"
        "model_id" => 2
        "uuid" => "e353c8dc-9c3e-40e8-bcc7-f06b7102a03f"
        "collection_name" => "files"
        "name" => "Resale Certificate"
        "file_name" => "Invoice_INVJBA1953597.pdf"
        "mime_type" => "application/pdf"
        "disk" => "media"
        "conversions_disk" => "media"
        "size" => 70160
        "manipulations" => "[]"
        "custom_properties" => "{"doc_name":"Resale Certificate"}"
        "responsive_images" => "[]"
        "generated_conversions" => "[]"
        "order_column" => 14
        "created_at" => "2021-02-04 10:49:48"
        "updated_at" => "2021-02-04 11:00:20"
      ]
      #changes: []
      #classCastCache: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #fillable: []
    }
  ]
}
Activity icon

Replied to Works In Tinkerwell But Fails With Undefined Offset In Browser

Shouldn't you be handling those cases in the getRequiredCAFDocs() method?

Wouldn't optional() handle this? If exists I get a name or a path, etc but if it doesn't exist, those are null.

Activity icon

Replied to Works In Tinkerwell But Fails With Undefined Offset In Browser

Tinkerwell

$id = 2;
\App\Models\Company::find($id)->getRequiredCAFDocs();

Result

[
     [
       "id" => 1,
       "title" => "Country Certificate",
     ],
     [
       "id" => 2,
       "title" => "Resale Certificate",
     ],
   ]
Feb
05
3 months ago
Activity icon

Started a new Conversation Works In Tinkerwell But Fails With Undefined Offset In Browser

Using MediaLibrary (Pro, actually) from Spatie and I need to know if a government required document is in the company's media library. I extended Spatie's Media class and added this static function:

class Media extends BaseMedia
{
    public static function byName($cid, $name)
    {
        return static::whereModelType('App\Models\Company')
            ->whereModelId($cid)
            ->whereName($name)
            ->get();
    } // end function
}

I have this static function in my Company model

public function getRequiredCAFDocs(): array
{
    $w9 = Media::byName($this->id, 'Country Certificate');
    $sales = Media::byName($this->id, 'Resale Certificate');

    $reporter = [
        [
            'id' => 1,
            'title' => 'Country Certificate',
            'path' => optional($w9[0])->file_name
        ]
    ];

    if($this->is_tax_exempt) {
            $reporter[] = [
           'id' => 2,
           'title' => 'Resale Certificate',
           'path' => optional($sales[0])->file_name
        ];
    } // end if

    return $reporter;
} // end function

In my Livewire Component

public function mount(): void
{
    $this->requireds = $this->company->getRequiredCAFDocs();
} // end function

In my Livewire view

<x-repository.container>
    @forelse($requireds as $doc)
        <x-repository.uploader :file="$doc" wire:key="row-{{$doc['id']}}" />
    @empty
         <x-repository.empty />
    @endforelse
</x-repository.container>

The browser returns

ErrorException
Undefined offset: 0

TINKERWELL:

$w9 = Media::byName(2, 'Company Certificate');
return optional($w9[0])->file_name;
Aliasing 'Media' to 'App\Models\Media' for this Tinker session.
=> "Invoice_INVJBA1949158.pdf"
Activity icon

Awarded Best Reply on Media Library: Using A Select Rather Than An Input For Custom Properties

Nevermind, going for a different approach.

Activity icon

Replied to Media Library: Using A Select Rather Than An Input For Custom Properties

Nevermind, going for a different approach.

Activity icon

Started a new Conversation Media Library: Using A Select Rather Than An Input For Custom Properties

I need to limit the values allowed for the custom properties of the downloads. So I edited the example blade that had an input to use a select. I was able to get the select styled and in place but the value stored in the database does not respect the select.

https://share.getcloudapp.com/qGuXDXvw

Fields Blade

@include('media-library::livewire.partials.collection.fields')

<div class="media-library-field">
    <label class="media-library-label">Document Name</label>
    <select
        class="media-library-input"
        {{ $mediaItem->livewireCustomPropertyAttributes('doc_name') }}
    >
        <option value="Country Certificate">Country Certificate</option>
        <option value="Liability Insurance">Liability Insurance</option>
        <option value="Resale Certificate">Resale Certificate</option>
    </select>

    @error($mediaItem->customPropertyErrorName('doc_name'))
    <span class="media-library-text-error">
       {{ $message }}
    </span>
    @enderror
</div>

Livewire Component

<div class="w-1/3">
    <form method="POST" wire:submit.prevent="submit">
        <h2 class="mb-4 text-blue-500 font-bold text-center">
            Required Documents
        </h2>

        <x-media-library-collection
                        name="files"
                        :model="$company"
                        collection="files"
                        fields-view="/fields/document"
        />

        <div class="my-4 w-full flex justify-center items-center">
            <x-buttons.submit-button label="Save Uploads" />
        </div>

    </form>
</div>

FIELDS IN DATABASE https://share.getcloudapp.com/4gu1x1G0

Feb
02
3 months ago
Activity icon

Replied to Conditional Validation In Livewire

You got it ... THANKS so much

Activity icon

Replied to Conditional Validation In Livewire

<input type="search" {{ $attributes }} class="w-full form-input rounded-md block transition duration-150 ease-in-out sm:text-sm sm:leading-5"/>

Activity icon

Started a new Conversation Conditional Validation In Livewire

I thought I had this right by the docs but the conditional validation is not working.

protected $rules = [
        'company.legal_name' => 'required',
        'company.address' => 'required',
        'company.country' => 'required',
        'company.address2' => 'nullable',
        'company.address3' => 'required_if:company.country,!=,US',
        'company.cage' => 'nullable',
        'company.city' => 'required_if:company.country,==,US',
        'company.dba' => 'nullable',
        'company.email' => 'nullable',
        'company.fax' => 'nullable',
        'company.naics' => 'nullable',
        'company.phone' => 'nullable',
        'company.state' => 'required_if:company.country,==,US',
        'company.uri' => 'nullable',
        'company.zip' => 'required_if:company.country,==,US',
    ];

So, if company.country is "US" I expect that city, state and zip are required but if is anything other than 'US', I expect address3 to be required.

well, it is submitting the form regardless.

Jan
31
3 months ago
Activity icon

Replied to Failing Test Due To Coalescence

OMG!!!!!!!!!!!!!!!!

Activity icon

Replied to Failing Test Due To Coalescence

<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use App\Models\CompanyCustomerAgreement;

class CompanyCustomerAgreementFactory extends Factory
{
    protected $model = CompanyCustomerAgreement::class;

    public function definition()
    {
        return [
            'company_id' => 1,
            'requester_id' => 1,
            'status_id' => 1,
            'company_code' => 'UAMI2',
            'last_agreement' => '2020',
            'last_completed_step' => 1,
            'verified_id' => null,
            'verified_date' => null,
            'approved_date' => null,
            'approved_id' => null,
            'is_favorited' => null,
            'reporter' => 'Jon Gravois',
            'reporter_title' => 'Technology Manager',
            'reporter_email' => '[email protected]',
            'signer' => null,
            'signer_title' => null,
            'signer_email' => null,
            'terms_initials' => null,
            'current_caf_invited' => true,
            'uploaded_quantum' => false,
            'is_airline' => false,
            'is_lessor' => false,
            'is_mro' => false,
            'is_mro_faa' => false,
            'is_mro_easa' => false,
            'is_mro_caac' => false,
            'is_oem' => false,
            'is_supplier' => false,
            'is_trader' => false,
            'is_other' => false,
            'other_fillin' => null,
        ];
    }
}
Activity icon

Replied to Failing Test Due To Coalescence

Excellent explanation -- thank you!!!

This makes my original issue more mysterious.

if I use either of these, i still get Failed asserting that null matches expected 1.

$this->lcStep = $co->last_completed_step ?: 1; // Will be set to 1
$this->lcStep = $co->last_completed_step ?? 1; // Will be set to 1
Activity icon

Replied to Failing Test Due To Coalescence

'company_code' => 'UAMI2', is in the factory but I tried it anyway and it is still Failed asserting that null matches expected 1.

ternary or coalescence ... isn't that saying if $co->last_completed_step is null, make this one or else use $co->last_completed_step ???

Activity icon

Started a new Conversation Failing Test Due To Coalescence

$co = CompanyCustomerAgreement::whereCompanyCode($code)->first();

if(!isset($co)) {
    $this->redirect('/expired');
} else {
    $this->lcStep = $co->last_completed_step ?: 1;
    $this->currentStep = $co->last_completed_step ?: 1;
} // end if

Shouldn't null coalescence kick in???

/** @test */
public function caf_loads_properly(): void
{
    $caf = CompanyCustomerAgreement::factory()->make([
        'last_completed_step' => null
    ]);

    Livewire::actingAs($this->user)
        ->test(CustomerWizard::class, ['code' => 'UAMI2'])
        ->assertSet('companyCode', 'UAMI2')
        ->assertSet('currentStep', 1)
        ->assertSet('lcStep', 1)
        ->assertOK();
} // end test
Failed asserting that null matches expected 1.

Fails on either ->assertSet('currentStep', 1) or ->assertSet('lcStep', 1)

Activity icon

Started a new Conversation Has ->assertSet() Been Deprecated In Livewire

Livewire::actingAs($this->user)
            ->test(CustomerWizard::class, ['code' => 'UAMI2'])
            ->assertOk()
            ->assertSet('companyCode', 'UAMI2');

is returning

BadMethodCallException : Method Illuminate\Http\Response::assertSet does not exist.
 /Users/jongravois/code/agreements/vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:103
 /Users/jongravois/code/agreements/vendor/laravel/framework/src/Illuminate/Testing/TestResponse.php:1238
 /Users/jongravois/code/agreements/tests/Feature/Customers/CustomerWizardTest.php:40
Jan
29
3 months ago
Activity icon

Replied to Text Dump On Top Of Livewire Component

didn't help but I changed the <x-app-layout> wrapper to just div and it went away.

I assume that <x-app-layout> was already called by JetStream???

Activity icon

Replied to Text Dump On Top Of Livewire Component

This is the app.blade.php and according to Global Search, it's the only place where it is used.

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>{{ config('app.name', 'Laravel') }}</title>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:[email protected];600;700&display=swap">
        <link rel="stylesheet" href="{{ mix('css/app.css') }}">
        @livewireStyles
        <script src="{{ mix('js/app.js') }}" defer></script>
    </head>
    <body class="font-sans antialiased">
        <div class="min-h-screen"><main>{{ $slot }}</main></div>
        @stack('modals')

        @livewireScripts
    </body>
</html>