Walker

Member Since 1 Month Ago

Experience Points
1,540
Total
Experience

3,460 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
3
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 1
1,540 XP
Apr
23
2 weeks ago
Activity icon

Replied to Filling Inputs Alpine JS

Yes, I just don't know how to do it

Activity icon

Started a new Conversation Filling Inputs Alpine JS

Hi everyone, could you advise me how to make. I need to set this value after clicking on the company name in dropdown, ie the name of the company in the input with id sender_company_name I would like to do this with Alpine.Js. THANK YOU

// search company

<!-- after clicking set value to name -->

<x-input 
      wire:model.debounce.500ms="search" 
      id="sender_company_name" 
      class="block mt-1 w-full"
      type="text"
      name="sender_company_name"
     :value=" ... "
 />



<!-- dropdown results -->

 @if (strlen($this->search) > 3)

         @foreach ($results as $key => $company)

             <div class="bg-gls-gray-50 py-2 mt-2 my-1">

                 <a href="#">
                     <div class="flex py-2">

                         <h6 class="text-sm font-semibold pl-2">
                                 {{ $company['name'] }}
                        </h6>
                         <span class="pl-3 font-semibold">
                                     {{ $company['cin'] }}
                         </span>

                     </div>
                 </a>

             </div>

         @endforeach

     @endif


<!-- after clicking set value to cin -->

<x-input
     id="sender_company_ico" 
     class="block mt-1 w-full"
     type="text" 
     name="sender_company_ico"
     :value=" ... "

 />


Apr
22
2 weeks ago
Activity icon

Started a new Conversation Livewire Autoform

Hi everyone, I have a livewire component in which I pull data from an external api that is company data. I would like to use this data in the form to add funny data after clicking on a specific company. Thanks for the help

 <div x-show="show">
     <div class="md:mt-4">
         <x-label for="sender_company_name" :value="__('Firma')" />

         <x-input wire:model.debounce.500ms="search" id="sender_company_name" class="block mt-1 w-full" type="text"
             name="sender_company_name" value="old('sender_company_name')" placeholder="vyhľadať firmu" />
     </div>
     <div class="bg-gls-gray-50 py-2 px-1 mt-1 text-sm">
         <a href="">
             @foreach ($results as $key => $company)
                 <div class="flex border-b py-2 px-2">
                     <strong class="mr-1 w1/2">{{ $company['name'] }}</strong>
                     <p class="text-xs">{{ $company['formatted_address'] }}</p><br>
                 </div>
             @endforeach
         </a>
     </div>
     <div class="flex flex-wrap -mx-3 overflow-hidden">

         <div class="mt-3 px-3 w-full overflow-hidden xl:w-1/3">

             <!-- Sender Company ICO -->
             <div class="md:mt-1">
                 <x-label for="sender_company_ico" :value="__('IČO')" />

                 <x-input id="sender_company_ico" class="block mt-1 w-full" type="number" name="sender_company_ico"
                     :value="old('sender_company_ico')" />
             </div>
         </div>

         <div class="mt-3 px-3 w-full overflow-hidden xl:w-1/3">

             <!-- Sender Company DIC -->
             <div class="md:mt-1">
                 <x-label for="sender_company_dic" :value="__('DIČ')" />

                 <x-input id="sender_company_dic" class="block mt-1 w-full" type="number" name="sender_company_dic"
                     :value="old('sender_company_dic')" />
             </div>
         </div>
         <div class="mt-3 px-3 w-full overflow-hidden xl:w-1/3">
             <!-- Sender Company IC DPH -->
             <div class="md:mt-1">
                 <x-label for="sender_company_ic_dph" :value="__('IČ DPH')" />

                 <x-input id="sender_company_ic_dph" class="block mt-1 w-full" type="text" name="sender_company_ic_dph"
                     :value="old('sender_company_ic_dph')" />
             </div>
         </div>
     </div>
 </div>
class SearchCompany extends Component
{

    public $search = '';

    public function render()
    {
        $results = [];


            $results = Http::get(
                'https://autoform.ekosystem.slovensko.digital/api/corporate_bodies/search?q=name:'.$this->search.'&private_access_token= ***')
                ->json();

        return view('livewire.search-company', [
            'results' => collect($results),
        ]);
    }
}

Apr
14
3 weeks ago
Activity icon

Replied to Axios

Hi, he didn't come ... I made a livewire component and I'm pulling a classic http request.

Apr
12
3 weeks ago
Activity icon

Replied to Request Header

Yes, I've tried that before

EDIT @corvs I forgot to remove the double shoe already it's ok thanks.

Activity icon

Started a new Conversation Request Header

Hi everyone, I'm trying to send a request to an external api to get data. The api is secured by OAuth 2.0. Via the postman, the results are returned to me correctly, but when I make a request with the application, I get a "message" => "Bad credentials" which is wrong?

The documentation provides such an example for an authorization sent in a header

curl -H 'Authorization: Token nbusr123' 'https://datahub.ekosystem.slovensko.digital/api/datahub/corporate_bodies/

$searchResults = Http::withHeaders([
        'Authorization: Token *****',
   ])->get('https://datahub.ekosystem.slovensko.digital/api/datahub/corporate_bodies/search?q=cin:' . $this->search)->json();
Apr
11
3 weeks ago
Activity icon

Replied to Axios

I tried it like this but I don't know if it's right. I also installed the fruitcake package/ laravel-cors

'paths' => ['api/*', 'sanctum/csrf-cookie', '*'],

    'allowed_methods' => ['*'],

    'allowed_origins' => ['*'],

    'allowed_origins_patterns' => ['*'],

    'allowed_headers' => ['*'],

    'exposed_headers' => ['*'],

    'max_age' => 0,

    'supports_credentials' => true,
Activity icon

Started a new Conversation Axios

Hi guys, I'm trying an axios call on an external api. I can't deal with cors. I'm getting a Referrer Policy error: strict-origin-when-cross-origin. Can you advise?

axios.get(
            'https://datahub.ekosystem.slovensko.digital/api/datahub/corporate_bodies/search?q=cin:' + inputValue + '&expand=rpo_organizations', {
            method: 'GET',
            mode: 'no-cors',
            headers: {
                'Access-Control-Allow-Origin': '*',
                'Content-Type': 'application/json',
                'Authorization': `token ${access_token}`
            },
            withCredentials: true,
            credentials: 'same-origin',
        })
Apr
10
4 weeks ago
Activity icon

Replied to Queries

The point is that no auth user can add to the cart, and then the session id changes

Activity icon

Started a new Conversation Queries

Hi can anyone advise me? I need my session id not to change when adding to the cart. I solved it this way but it makes me a lot of duplicate queries. How can this be fixed?

AppServiceProvider

View::composer('*', function ($view) {
     $view->with('cart', Cart::bySession()->first());
 });
Activity icon

Started a new Conversation Cannot Add Or Update A Child Row

Hi, I'm trying to solve such a problem. I want to create a cart where in the database I also want to register usera if it is logged in. The user is set to nullablle so I don't understand why I'm getting an error.

   public function store(ShipmentRequest $request)
    {
        $request = $request->except('_token');

        $cart = Cart::firstOrCreate([
            'user_id' => auth()->id(),
            'session_id' => session()->getId()
        ]);

        if (optional(optional($cart)->shipments)->count()) {

            flash()->error('Only one parcel is allowed');

            return redirect()->route('cart.index');
        }

        $shipment = Shipment::firstOrCreate($request, [
            'user_id' => auth()->id(),
        ]);

        $cart->shipments()->syncWithoutDetaching($shipment->id);

        return redirect()->route('cart.index');
    }

$table->foreignId('user_id')->nullable()->constrained()->onDelete('cascade');

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (homestead.carts, CONSTRAINT carts_user_id_foreign FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE) (SQL: insert into carts (user_id, session_id, updated_at, created_at) values (1, xZn0Of6uM50dQiq7z6hYsIq5VcXC226TBikcDi8w, 2021-04-10 13:06:04, 2021-04-10 13:06:04))

Apr
09
4 weeks ago
Activity icon

Replied to Add Header To The Pdf File

I tried it . It still saves me without a header

%PDF-1.4 %���� % 1 0 obj

Activity icon

Started a new Conversation Add Header To The Pdf File

Hi I need to add a header to the pdf file I am saving. If the user is logged in, the file is saved, if not displayed in the browser. The file is saved but without the application / pdf header

public function getPdf()
    {
        if (! $this->hasLabels()) {
            return null;
        }

        return implode(array_map('chr', $this->data()['Labels']));
    }

if ($response->successfull()) {

            $cart->successResponse($response, $cart);

            $fileName = 'label-' . time() . '.pdf';

            if (auth()->user()) {
                // save label

                Storage::disk('local')->put($fileName, $response->getPdf()); //add header

                flash()->success('Done. Your label is in your orders. Thank you!');
                return redirect()->route('home');
            }

            header('Content-Type: application/pdf');
            header("Content-disposition: attachment; filename=" . $fileName);
            die($response->getPdf());
        }
Apr
08
1 month ago
Activity icon

Started a new Conversation Download Pdf

Hi, I need to download a pdf to a browser before I do redirect can you advise me?

The pdf will not be accessed in this way. And a redirect is done.

if ($response->successfull()) {

      $cart->successResponse($response, $cart);

            header('Content-Type: application/pdf');

            $response->getPdf();

             flash()->success('Done. Your parcel is susscessful send. Thanks for your order.');

            return redirect()->route('home');
        }

Apr
07
1 month ago
Activity icon

Replied to Extract Data

Oh I already have it must hit there () at the end. well thank you.

dump($value->parcelNumber())

Activity icon

Replied to Extract Data

Cannot access protected property Webapix\GLS\Models\PrintLabelsInfo::$parcelNumber

Does this mean that the data cannot be used? I need to save it to db

Activity icon

Started a new Conversation Extract Data

Hi I need to extract data with such an array and I am generally unsuccessful could someone advise me thank you

screen

$labelInfo = $response->printLabelsInfo();
foreach ($labelInfo as $key => $value) {
       dump($value['parcelNumber']);
}

Cannot use object of type Webapix\GLS\Models\PrintLabelsInfo as array

Apr
05
1 month ago
Activity icon

Replied to Missing Required Parameter

I'm sorry I reworked it based on your answer and rewrote the code in the question I shouldn't have done ... Yes due to ShipmentRequest it came back to sleep it's okay now. Sorry again and thank you for your help.

Activity icon

Replied to Missing Required Parameter

I redesigned it, but it still doesn't work. No error is returned but the update function does not start. dd ($ cart) As if there was a return back () in that function, I don't get it

Activity icon

Replied to Missing Required Parameter

I redesigned it, but it still doesn't work. No error is returned but the update function does not start. dd ($ cart) As if there was a return back () in that function, I don't get it

Activity icon

Started a new Conversation Missing Required Parameter

Hi, could anyone advise me to come back to me with such an error

Missing required parameter for [Route: cart.shipments.update] [URI: cart/shipments/{shipment}] [Missing parameter: shipment]. (View: /var/www/html/resources/views/cart/edit.blade.php)

Route::put('/cart/shipments/{shipment}', [CartShipmentController::class, 'update'])
    ->name('cart.shipments.update');

Route::get('/cart/shipments/{shipment}/edit', [CartShipmentController::class, 'edit'])
    ->name('cart.shipments.edit');
    public function edit(Shipment $shipment)
    {
        return view('cart.edit', compact('shipment'));
    }

    public function update(ShipmentRequest $request, Shipment $shipment)
    {
        $cart = Cart::bySession()->first()->shipments();

        dd($cart);
    }
<form action="{{ route('cart.shipments.update', $shipment) }}" method="post">
    @csrf
    @method('PUT')
    <x-button class="mr-4 font-medium text-white hover:bg-red-800">
        Update
    </x-button>
</form>
<x-link-button :href="route('cart.shipments.edit', $shipment)" class="mr-2">
        {{ __('Edit') }}
</x-link-button>
Apr
04
1 month ago
Activity icon

Started a new Conversation Alpine.js

Hi I would like to use alpine.js for the next step. I have select input and date input. Date is disabled by default. When select is selected for option 1, I need a date input to be enabled and required. How could this be solved in alpine.js ??

This is how he solved it with javascript.

let select = document.getElementById('pick_ship')
            let date = document.getElementById('date_pickup')
            select.addEventListener('change', function() {
            if (this.value == 1) {
                    date.disabled = false
                    date.required = true
             } else {
                    date.disabled = true
                    date.required = false
       }
})
<x-input id="date_pickup" class="block mt-1 w-full" type="date" disabled
   name="date_pickup" :value="old('date_pickup')" />
<select
     name="pick_ship" id="pick_ship"
     class="block mt-1 w-full rounded-md shadow-sm border-gray-300 focus:border-indigo-300 focus:ring 
                  focus:ring-indigo-200 focus:ring-opacity-50">
               <option value="0">ParcelShop (0€)</option>
               <option value="1">Pickup by courier (+ 4€)</option>
 </select>
Apr
02
1 month ago
Activity icon

Replied to Missing Required Parameter

I'm sorry I had a mistake I sent shipment there and not shipments. It's all working now. Thank you for your response.

Activity icon

Replied to Missing Required Parameter

It didn't help getting the same error

Activity icon

Started a new Conversation Missing Required Parameter

hello guys, could you advise me where i'm making a mistake? I'm trying to make a delete request and I'm getting such an error.

Missing required parameter for [Route: cart.shipments.destroy] [URI: cart/shipments/{shipment}] [Missing parameter: "id":8,"user_id":null,"sender_first_name":"James","sender_last_name":"Vargas","recipient_first_name":"Zelda","recipient_last_name":"Guerrero","created_at":"2021-04-02T08:57:59.000000Z","updated_at":"2021-04-02T08:57:59.000000Z"]. (View: /var/www/html/resources/views/cart/index.blade.php)

Route::delete('/cart/shipments/{shipment}', [CartShipmentController::class, 'destroy'])
    ->name('cart.shipments.destroy');
public function destroy(Shipment $shipment)
    {
        $cart = Cart::bySession()->first()->shipments();
        dd($cart);
    }
<form action="{{ route('cart.shipments.destroy', $shipment) }}" method="post">
   @csrf
   @method('DELETE')
     <button
             class="font-medium text-indigo-600 hover:text-indigo-500 mr-4">
             Remove
	 </button>
</form>
Apr
01
1 month ago
Activity icon

Replied to Foreach In The Session

yes for example

Activity icon

Replied to Foreach In The Session

In me. I'm saving data to a session. I need to make a foreach over them now.

Activity icon

Replied to Foreach In The Session

I don't know how to get that data, I would like to process it in a cycle

Activity icon

Started a new Conversation Foreach In The Session

Hi, I've been worried for a long time how to get to all the data I store in a session. How could I make a foreach to attract data? I need to pull the data into a variable with each array. Thanks.

screenshot

Mar
31
1 month ago
Activity icon

Replied to Foreach In The View Over The Data In The Session

This is data that does not need to be stored in the db

Activity icon

Replied to Foreach In The View Over The Data In The Session

Undefined array key "consignee_lastName"

@foreach ($data as $value) {{ $value['consignee_lastName']}} @endforeach

Activity icon

Started a new Conversation Foreach In The View Over The Data In The Session

Hi I'm trying to foreach in the view over the data in the session. I get a foreach () argument argument must be of type array | object, string given. Thank you

if (!$request->session()->exists('formData')) {
            $request->session()->put('formData', ['Data', $request->all()]);
        } else {
            $request->session()->push('formData', ['Data', $request->all()]);
        }

public function index()
    {
        $product = Product::get();

        $data = array(session('formData'));

        return view('cart.index', [
            'product' => $product,
            'data' => $data
        ]);
    }
@foreach ($data as $value)
                            {{ $value->consignee_lastName }}
                            @endforeach

Activity icon

Started a new Conversation Push Into The Session More Data

Hi I need advice. I save the data from the form to the session as formData and I would need to fill in the form again so that this data can also be pushed into the session so that I can access it.

this is how I store data in a session $request->session()->put('formData', $request->all());

This is how I approach them

public function index()
    {
        $product = Product::get();

        $data = session('formData');

        return view('cart.index', [
            'product' => $product,
            'data' => $data
        ]);
    }
Mar
30
1 month ago
Activity icon

Started a new Conversation Polimorphic Many To Many.

Hi Can you advise me why my polimorphic currency doesn't work it currency relations returns empty array? well thank you.

Schema::create('zoneables', function (Blueprint $table) {
            $table->id();
            $table->integer('zone_id');
            $table->morphs('zoneable');
        });
public function zones()
    {
        return $this->morphToMany(Zone::class, 'zoneable');
    }
public function index()
    {
        $product = Product::with(['zones'])->get();

        return $product;
        die();

        return view('product.index', [
            'product' => $product
        ]);
    }
Mar
29
1 month ago
Activity icon

Started a new Conversation Save Form Data To Session

Hi, what is the best way if I want to save the data from the request (form) to a session for further use?

Mar
22
1 month ago
Activity icon

Replied to Total Price Function

Yes

Activity icon

Replied to Total Price Function

Cart total: {{ $cart->total()}}

Activity icon

Started a new Conversation Total Price Function

Hi, I need to format the total amount on the card. I use a moneyphp package. I'm getting such error "Unsupported operand types: int + App \ Cart \ Money (View:/var/www/html/resources/views/cart/index.blade.php)"

The question is: How do I format the resulting amount in the total () function?

Money.php

public function formatted()
    {
        $formatter = new IntlMoneyFormatter(
            new NumberFormatter('sk_SK', NumberFormatter::CURRENCY),
            new ISOCurrencies()
        );

        return $formatter->format($this->money);
    }

HasPrice.php

public function getPriceAttribute($value)
    {
        return new Money($value);
    }

 
public function getFormattedPriceAttribute()
    {
        return $this->price->formatted();
    }

Cart.php

public function total()
    {
        return $this->shipments->sum('price');
    }
Mar
12
1 month ago
Activity icon

Replied to PHP Logical Operators

Thank

Activity icon

Replied to PHP Logical Operators

Thank you all, I'm sorry if I spoke badly. I have bad English.

Activity icon

Replied to PHP Logical Operators

But it doesn't work. It didn't remove the hyphen from me

Activity icon

Replied to PHP Logical Operators

syntax error, unexpected ':'

Activity icon

Started a new Conversation PHP Logical Operators

Hi, how could a condition be done if clientref is null displays only orderId without a hyphen. well thank you

'ClientReference' => $this->options['clientref'] .'-'. $this->filterOrderId($order)