proxomos

Member Since 5 Years Ago

Experience Points
24,020
Total
Experience

980 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
243
Lessons
Completed
Best Reply Awards
0
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 5
24,020 XP
Mar
31
1 week ago
Activity icon

Started a new Conversation How NOT To Use This Forum

Sometimes when you've been hard at it all day, you run into a challenge that has simple solution, yet you can't see it for looking.

When you want to help someone is it for the Kudos? or to genuinely offer assistance to someone who is struggling?

I face one of those moments today. I was at the end of 14 hour day coding an admin system for a watch company and I could not get the results of a collection. All it was, I had not cast a variable to an array, problem was solved by an eagle eyed member here.

Another had offered advice but clearly was losing patience rapidly and in the end finished off by calling me an effing idiot.

I pity him as clearly he was only interested in upping his Kudos with best answer score.

Please users come here for help, not abuse, this turns people off and they will go elsewhere, there is no need for it.

rant over.

Activity icon

Replied to Cannot Get To Data From Collection

Naozaj by ste nemali byť taký drzí k ľuďom, ktorí hľadajú pomoc / vedenie Váš práve nasratý nedostal najlepšiu odpoveď!

Activity icon

Replied to Cannot Get To Data From Collection

Yet you feel obliged to leave one.......

Activity icon

Replied to Cannot Get To Data From Collection

no need to be rude dude.

Activity icon

Replied to Cannot Get To Data From Collection

Thanks, sometimes you cant see for looking. marked as best answer.

Activity icon

Replied to Cannot Get To Data From Collection

ErrorException Invalid argument supplied for foreach() (View: /Users/gnicholas/thunderbolt/swico-crm/resources/views/livewire/admin/repair-case.blade.php)

If I run the query in tinker it works fine:

>>> namespace App;
>>> use App\Models\RepairCase
>>> $casedata = RepairCase::with(['product','watchmaker','customer'])->where('case_number', 'SSC-277595-R6G7J')->first();
=> App\Models\RepairCase {#5066
     id: 4,
     customer_id: 5,
     watch_condition_id: null,
     case_number: "SSC-277595-R6g7j",
     product_id: 8,
     serial_no: "7606846",
     status_id: 3,
     type_id: 1,
     department_id: 2,
     location_id: 1,
     advanced_assessment: 1,
     assessment_condition: null,
     estimate_required: 1,
     admin_postage: 0,
     repair_delayed: 0,
     return_job: 0,
     return_undone: 1,
     guarantee_enc: 0,
     jobtype_id: 1,
     estimate_repair_date: "2021-08-26 16:40:36",
     proceed_date: null,
     misc: "Maxime est provident rerum.",
     trade_repair_ref_1: null,
     trade_repair_ref_2: null,
     royal_mail_tracking_no: null,
     return_job_no: null,
     date_received: null,
     source_of_business: 2,
     despatched_date: null,
     fast_track_battery_type: null,
     proceeded_by: null,
     final_watchmaker: null,
     model_ref: null,
     rud_reason: null,
     guarantee_enclosed_date: null,
     holdstatus_id: 7,
     created_at: "2021-03-29 08:52:14",
     updated_at: "2021-03-29 08:52:14",
     brand_id: 14,
     repair_job_type_id: null,
     fast_track_battery_id: null,
     case_type_id: null,
     serial_number_id: null,
     source_of_business_id: null,
     user_id: null,
     rud_reason_id: null,
     watchmaker_id: null,
     product: App\Models\Product {#4349
       id: 8,
       product_family: "JC - After Sales",
       brand_name: " Juicy Couture Timepieces ",
       name: "Seals",
       product_type: 2,
       price: 29567,
       product_number: "TS74383",
       current_cost: 3677,
       vendor_part_name: "VENDOR_PART_NAME",
       current_cost_base: 4326,
       price_base: 2356,
       product_description: "JCC04 - Seals ",
       quantity: 2645,
       created_at: null,
       updated_at: null,
       guarantee_terms: "60",
       tax_status_id: 2,
     },
     watchmaker: null,
     customer: App\Models\Customer {#5223
       id: 5,
       user_id: null,
       first_name: "Icie",
       last_name: "Cremin",
       telephone: "840-350-9131",
       email: "[email protected]",
       company_name: "Lesch, Yost and Halvorson",
       address_1: "12303 Waters Club",
       address_2: "",
       city: "Strosinchester",
       postcode: "90120-5234",
       country: "Swaziland",
       offers: 1,
       created_at: "2021-03-29 08:52:14",
       updated_at: "2021-03-29 08:52:14",
     },
   }
>>> $casedata->id
=> 4
>>> 
Activity icon

Replied to Cannot Get To Data From Collection

if I do :

{{ $casedata }}

out put in browser is:

{"id":1,"customer_id":25,"watch_condition_id":null,"case_number":"SSC-277658-R5G8D","product_id":18,"serial_no":"4488500","status_id":5,"type_id":4,"department_id":4,"location_id":2,"advanced_assessment":true,"assessment_condition":null,"estimate_required":true,"admin_postage":true,"repair_delayed":false,"return_job":false,"return_undone":false,"guarantee_enc":false,"jobtype_id":4,"estimate_repair_date":"2021-05-03T19:18:14.000000Z","proceed_date":null,"misc":"Facilis in sequi labore doloribus ut.","trade_repair_ref_1":null,"trade_repair_ref_2":null,"royal_mail_tracking_no":null,"return_job_no":null,"date_received":null,"source_of_business":2,"despatched_date":null,"fast_track_battery_type":null,"proceeded_by":null,"final_watchmaker":null,"model_ref":null,"rud_reason":null,"guarantee_enclosed_date":null,"holdstatus_id":6,"created_at":"2021-03-29T08:52:14.000000Z","updated_at":"2021-03-29T08:52:14.000000Z","brand_id":10,"repair_job_type_id":null,"fast_track_battery_id":null,"case_type_id":null,"serial_number_id":null,"source_of_business_id":null,"user_id":null,"rud_reason_id":null,"watchmaker_id":null,"product":{"id":18,"product_family":"JC - After Sales","brand_name":" Juicy Couture Timepieces ","name":"Refit Case Stones / Diamonds","product_type":2,"price":"295.67","product_number":"TS74383","current_cost":3677,"vendor_part_name":"VENDOR_PART_NAME","current_cost_base":4326,"price_base":2356,"product_description":"JCC15 - Refit Case Stones / Diamonds","quantity":2645,"created_at":null,"updated_at":null,"guarantee_terms":"60","tax_status_id":2}}

Activity icon

Started a new Conversation Cannot Get To Data From Collection

I have a collection from the following query:

$this->casedata = \App\Models\RepairCase::with(['product'])
			->where('case_number', $casenumber)
			->get()

The output from this is:

=> App\Models\RepairCase {#5296
     id: 4,
     customer_id: 5,
     watch_condition_id: null,
     case_number: "SSC-277595-R6g7j",
     product_id: 8,
     serial_no: "7606846",
     status_id: 3,
     type_id: 1,
     department_id: 2,
     location_id: 1,
     advanced_assessment: 1,
     assessment_condition: null,
     estimate_required: 1,
     admin_postage: 0,
     repair_delayed: 0,
     return_job: 0,
     return_undone: 1,
     guarantee_enc: 0,
     jobtype_id: 1,
     estimate_repair_date: "2021-08-26 16:40:36",
     proceed_date: null,
     misc: "Maxime est provident rerum.",
     trade_repair_ref_1: null,
     trade_repair_ref_2: null,
     royal_mail_tracking_no: null,
     return_job_no: null,
     date_received: null,
     source_of_business: 2,
     despatched_date: null,
     fast_track_battery_type: null,
     proceeded_by: null,
     final_watchmaker: null,
     model_ref: null,
     rud_reason: null,
     guarantee_enclosed_date: null,
     holdstatus_id: 7,
     created_at: "2021-03-29 08:52:14",
     updated_at: "2021-03-29 08:52:14",
     brand_id: 14,
     repair_job_type_id: null,
     fast_track_battery_id: null,
     case_type_id: null,
     serial_number_id: null,
     source_of_business_id: null,
     user_id: null,
     rud_reason_id: null,
     watchmaker_id: null,
     product: App\Models\Product {#5065
       id: 8,
       product_family: "JC - After Sales",
       brand_name: " Juicy Couture Timepieces ",
       name: "Seals",
       product_type: 2,
       price: 29567,
       product_number: "TS74383",
       current_cost: 3677,
       vendor_part_name: "VENDOR_PART_NAME",
       current_cost_base: 4326,
       price_base: 2356,
       product_description: "JCC04 - Seals ",
       quantity: 2645,
       created_at: null,
       updated_at: null,
       guarantee_terms: "60",
       tax_status_id: 2,
     },
     watchmaker: null,
     customer: App\Models\Customer {#5303
       id: 5,
       user_id: null,
       first_name: "Icie",
       last_name: "Cremin",
       telephone: "840-350-9131",
       email: "[email protected]",
       company_name: "Lesch, Yost and Halvorson",
       address_1: "12303 Waters Club",
       address_2: "",
       city: "Strosinchester",
       postcode: "90120-5234",
       country: "Swaziland",
       offers: 1,
       created_at: "2021-03-29 08:52:14",
       updated_at: "2021-03-29 08:52:14",
     },
   }

The problem is when i try to access anything in the blade file I get this:

Trying to get property 'id' of non-object 

Illuminate\Foundation\Bootstrap\HandleExceptions::handleError resources/views/livewire/admin/repair-case.blade.php:20



        <div class="flex w-2/3">

            <div class="flex items-center justify-between w-full">

                <div>

                    <h1>Case Number</h1>

                    <span class="text-secondary">{{ $casenumber }}</span>

                </div>

                <div>

                    <h4>Product</h4>

                    <span>

 

                    </span>

                </div>

                <div>

                    <h4>Brand</h4>

                    <span>

                        {{  $casedata->id }}

                    </span>

                </div>

                <div>

                    <h4>Serial No.</h4>

                    <span></span>

                </div>

            </div>

            <div>

 

            </div>

        </div>

 

 

 

    </div>

I am flumoxed any ideas anyone?

My class file below:

<?php

namespace App\Http\Livewire\Admin;

use Livewire\Component;

class RepairCase extends Component
{
    public $casenumber;
    public $casedata;

    protected $listeners = ['repaircase' => 'repairCase'];

    public function repairCase($casenumber)
    {
        $this->casenumber = $casenumber;
        
        $this->casedata = \App\Models\RepairCase::with(['product'])
            ->where('case_number', $casenumber)        
            ->get();
            
       
    }

   

    public function render()
    {
        return view('livewire.admin.repair-case');
    }
}
Mar
10
1 month ago
Activity icon

Replied to Laravel 8 Breeze And Views

We've all been there mate, keep going....

Mar
05
1 month ago
Activity icon

Awarded Best Reply on Livewire Changing Url During Reactivity

Well sometimes things just come straight back to you out of nowhere, twas the route, that was the issue,

Route::get('/{category}/{product}', Products::class)->name('products');

to

Route::get('/{category}/{product:slug}', Products::class)->name('products');

Binding the key solved it.

Activity icon

Replied to Livewire Changing Url During Reactivity

Well sometimes things just come straight back to you out of nowhere, twas the route, that was the issue,

Route::get('/{category}/{product}', Products::class)->name('products');

to

Route::get('/{category}/{product:slug}', Products::class)->name('products');

Binding the key solved it.

Activity icon

Started a new Conversation Livewire Changing Url During Reactivity

So I have run into a challenge that I can't find a solution too. I have an eshop that I am building using Livewire. On each product page url is "/computers/imac" with the details of the product and a "Buy" button with a quantity field which increment/decrement using the + and - buttons.

The issue is that when you attempt to change the quantity Livewire changes the url.

"/computers/imac" becomes "/computers/64"

Is there an overide for this? as ive spent the 24 hours googling and I cannot find anything about this.

There is nothing special in my code as far as I can see, although I have noticed in the JSON that livewire adds a 'path' element to the json when the url is nested.

<input wire:model="qty" id="qty" wire:key="qty"  pattern="[0-9]*" type="text" name="qty" class="text-sm w-16 border border-gray-200 mr-1">
                                <button wire:click="decrement"  wire:key="increment" class="w-10 h-10 rounded bg-gray-200 text-2xl m-1 border border-gray-300">-</button>
                                <button wire:click="increment"  wire:key="decrement" class="w-10 h-10 rounded bg-gray-200 text-2xl m-1 border border-gray-300">+</button>

Class file:

public $qty = 0;

 public function increment()
    {
    	$this->qty++;
    }

    public function decrement()
    {
    	$this->qty--;
    }
Feb
11
2 months ago
Activity icon

Replied to Phpunit.xml Being Ignored When Running Tests

Removing

<server name="DB_HOST" value="localhost" />

from phpunit.xml and clear cache and config should have solved it. :/

Activity icon

Replied to Phpunit.xml Being Ignored When Running Tests

In your .env file change DB_HOST=postgres to DB_HOST=localhost Everything will then work fine.

Activity icon

Replied to Run 'npm Run Watch' On MacOS Or Virtualbox

Are you using Homestead?

Activity icon

Replied to Select Dynamic With Livewire

Nice post, saved me a headache - thanks!

Activity icon

Awarded Best Reply on Livewire Component Not Passing Data To View

So I have now managed to get this working, it was just changing the way the data was sent TO the component method so previously it was:

 <div class="p-4 space-y-2">
    	<label for="address_search" class="text-gray-500">Enter your postcode:</label>
    	<div>
    		<input wire:model.lazy="search" class="border-gray-200 rounded" type="search" id="address_search" value="XX2 00X">
    		<button wire:click="search" class="bg-gray-100 px-3 py-3 rounded">Search</button>
    	</div>
    </div>

Just by changing the input to use a form solve it:

   <form wire:submit.prevent="search" action="">
    	<div class="p-10 space-y-3">
	    	<input wire:model.lazy="search" type="search" class="border-gray-300 rounded">
	    	<button type="submit" class="bg-blue-700 text-white p-3 rounded">Search</button>
    	</div>

    </form>
    
    <div>
    	@if($searchData)
    		@foreach($searchData as $data)
    			{{ $data[0] }}
    		@endforeach
    	@endif
    </div>

Nothing changed in the component:

class Checkout extends Component
{
	public $search;
	public $searchData = [];

	public function search()
	{
		$data = Http::get('https://api.getAddress.io/find/' . trim($this->search ). '?api-key=' . config( 'getaddress.api_key' ) . '&format=true&sort=true');
		$this->searchData = $data->json()['addresses'];
		// dd($this->searchData);
	}

    public function render()
    {

        return view('livewire.checkout')
        	->layout('layouts.base');
    }

So something to do with the way the livewire component receives the data??? I dont know but it works :)

Activity icon

Replied to Livewire Component Not Passing Data To View

So I have now managed to get this working, it was just changing the way the data was sent TO the component method so previously it was:

 <div class="p-4 space-y-2">
    	<label for="address_search" class="text-gray-500">Enter your postcode:</label>
    	<div>
    		<input wire:model.lazy="search" class="border-gray-200 rounded" type="search" id="address_search" value="XX2 00X">
    		<button wire:click="search" class="bg-gray-100 px-3 py-3 rounded">Search</button>
    	</div>
    </div>

Just by changing the input to use a form solve it:

   <form wire:submit.prevent="search" action="">
    	<div class="p-10 space-y-3">
	    	<input wire:model.lazy="search" type="search" class="border-gray-300 rounded">
	    	<button type="submit" class="bg-blue-700 text-white p-3 rounded">Search</button>
    	</div>

    </form>
    
    <div>
    	@if($searchData)
    		@foreach($searchData as $data)
    			{{ $data[0] }}
    		@endforeach
    	@endif
    </div>

Nothing changed in the component:

class Checkout extends Component
{
	public $search;
	public $searchData = [];

	public function search()
	{
		$data = Http::get('https://api.getAddress.io/find/' . trim($this->search ). '?api-key=' . config( 'getaddress.api_key' ) . '&format=true&sort=true');
		$this->searchData = $data->json()['addresses'];
		// dd($this->searchData);
	}

    public function render()
    {

        return view('livewire.checkout')
        	->layout('layouts.base');
    }

So something to do with the way the livewire component receives the data??? I dont know but it works :)

Feb
10
2 months ago
Activity icon

Replied to Livewire Component Not Passing Data To View

Nope, I thnk I tried that already.

Activity icon

Replied to Livewire Component Not Passing Data To View

There is no field name, its an array or arrays identifiable only by the key

Activity icon

Started a new Conversation Livewire Component Not Passing Data To View

So, I have a component which I am building to search for a users address when they enter their postcode. I am using getAddress.io.

My component is as follows:

class Checkout extends Component
{
	public $search;
	public $searchResults = [];
	

	public function search()
	{
		$response = Http::get( 'https://api.getAddress.io/find/' . trim($this->search ). '?api-key=' . config( 'getaddress.api_key' ) . '&format=true&sort=true');

			$this->searchResults= $response->json()['addresses'];
			//dd($this->searchResults);
	}

    public function render()
    {
        return view('livewire.checkout')
        ->layout('layouts.base');
    }
}

and then in my view I have:

<div>
    <livewire:toast-messenger />
    <livewire:navbar-top />

    <div class="p-4 space-y-2">
    	<label for="address_search" class="text-gray-500">Enter your postcode:</label>
    	<div>
    		<input wire:model.lazy="search" class="border-gray-200 rounded" type="search" id="address_search" value="XX2 00X">
    		<button wire:click="search" class="bg-gray-100 px-3 py-3 rounded">Search</button>
    	</div>
    </div>
</div>

<div class="p4 border">
	<ul>
		@forelse($searchResults as $result)

			<li>{{ $result[0] }}</li>

		@empty

			<li>Nothing here!</li>

		@endforelse
	</ul>
	
</div>

The issue is this, when I search for a given postcode and dd() the results I can see the JSON clearly :

array:21 [▼
  0 => array:5 [▶]
  1 => array:5 [▼
    0 => "660 Mitcham Road"
    1 => ""
    2 => ""
    3 => "Croydon"
    4 => "Surrey"
  ]
  2 => array:5 [▶]
  3 => array:5 [▶]
  4 => array:5 [▶]
  5 => array:5 [▶]
  6 => array:5 [▶]
  7 => array:5 [▶]
  8 => array:5 [▶]
  9 => array:5 [▶]
  10 => array:5 [▶]
  11 => array:5 [▶]
  12 => array:5 [▶]
  13 => array:5 [▶]
  14 => array:5 [▶]
  15 => array:5 [▶]
  16 => array:5 [▶]
  17 => array:5 [▶]
  18 => array:5 [▶]
  19 => array:5 [▶]
  20 => array:5 [▶]
]

But when I try loop through the data in the view, I see nothing. Am I being a dufus and can't see the obvious for looking, or am I expecting the wrong result as Livewire does something different ?

Any help appreciated.

Activity icon

Awarded Best Reply on Livewire Testing

This worked for me, It was lack of products in the test database:

  public function can_add_item_to_basket()
    {
        $product = Product::create([
            'product_name' => 'Red Balloon Box',
            'product_description' => 'This is a Red Balloon Box',
            'product_price' => 4,
            'product_qty' => 800,
            'photo' => 'images/red-balloon-box.png',
            'active' => 1
        ]);

        $this->get('/')
            ->assertSuccessful()
            ->assertSeeLivewire('add-to-basket');

        Livewire::test('add-to-basket')
            ->set('qty', 10)
            ->call('addtobasket', $product->id);

        $this->assertDatabaseHas('baskets', ['id' => $product->id, 'quantity' => 10]);
Activity icon

Replied to Livewire Testing

This worked for me, It was lack of products in the test database:

  public function can_add_item_to_basket()
    {
        $product = Product::create([
            'product_name' => 'Red Balloon Box',
            'product_description' => 'This is a Red Balloon Box',
            'product_price' => 4,
            'product_qty' => 800,
            'photo' => 'images/red-balloon-box.png',
            'active' => 1
        ]);

        $this->get('/')
            ->assertSuccessful()
            ->assertSeeLivewire('add-to-basket');

        Livewire::test('add-to-basket')
            ->set('qty', 10)
            ->call('addtobasket', $product->id);

        $this->assertDatabaseHas('baskets', ['id' => $product->id, 'quantity' => 10]);
Activity icon

Replied to Livewire Testing

   PASS  Tests\Feature\BasketTest
  ✓ can add item to basket

  Tests:  1 passed
  Time:   0.18s
Activity icon

Replied to Livewire Testing

Duh, I had not created any products in the test database!!??! what a doofus!

Activity icon

Started a new Conversation Livewire Testing

So I am trying to test a method on my livewire component. The method accepts an 'id', how do I pass the 'id' to the method from the test?

 Livewire::test('add-to-basket')
            ->set('qty', 10)
            ->call('addtobasket', ['id' => '45']);

At the moment this returns a 'Trying to get property of non-object error'.

Method below:

public function addtobasket($id)
    {
        $product = Product::where('id', $id)->first();
    	
    	$this->basket->create([
    		'session_id' => session()->getId(),
    		'product_id' => $id,
            'price' => $product->product_price,
            'total' => $product->product_price*$this->qty,
    		'quantity' => $this->qty
    	]);

		$this->qty = 0;
		$this->emit('itemAdded');	
    	$this->dispatchBrowserEvent('success', 'Item added to basket!');
    }

The non-object error is because the '$id' in the method is null, so how to pass id from the test?

Test output:

Trying to get property 'product_price' of non-object

  at app/Http/Livewire/AddToBasket.php:36
     32▕
     33▕     	$this->basket->create([
     34▕     		'session_id' => session()->getId(),
     35▕     		'product_id' => $id,
  ➜  36▕             'price' => $product->product_price,
     37▕             'total' => $product->product_price*$this->qty,
     38▕     		'quantity' => $this->qty
     39▕     	]);
     40▕
Feb
02
2 months ago
Activity icon

Replied to Livewire Nested Data Binding Not Showing The Value

Have you called mount() in your component class?

public function mount()
{
	$this->slug = $slug;
	$this->name = $name;
}