Loyd

Loyd

Member Since 6 Months Ago

Harare

Experience Points
15,940
Total
Experience

4,060 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
28
Lessons
Completed
Best Reply Awards
15
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]racasts.com 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.

Level 4
15,940 XP
Oct
25
1 hour ago
Oct
20
5 days ago
Activity icon

Replied to Validate Recaptcha In Livewire Class

@martinbean thanks for the response I will do so

Activity icon

Replied to How To Crawl Slugs Using Spatie Sitemap

@sinnbeck you know what just ran the command in production and its working like a charm, but in dev in was giving me a hard time

Activity icon

Replied to Validate Recaptcha In Livewire Class

@martinbean well, first of all, am sorry, but to be honest I was in a hurry to get an answer and I also provided additional info which you did not respond to and all I wanted is to solve the problem at hand. I do value how others feel "AM SORRY MAN".

And the problem still exists

Oct
18
1 week ago
Activity icon

Replied to How To Crawl Slugs Using Spatie Sitemap

@sinnbeck thanks for replying. The pages i am reffering to are outsitde the auth guard. And for example the home page is generated and homepage has some products that are not hidden and the package is not generating sitemap for such scenario.

Activity icon

Started a new Conversation How To Crawl Slugs Using Spatie Sitemap

Am using spatie sitemap to generate sitemap links using a command

public function handle()
    {
        // modify this to your own needs
        SitemapGenerator::create(config('app.url'))
            ->writeToFile(public_path('sitemap.xml'));
    }

This only generate links without slugs like home about and contact page

Oct
17
1 week ago
Activity icon

Replied to Validate Recaptcha In Livewire Class

@MichalOravec @Sinnbeck any ideas how to solve this

Activity icon

Replied to Validate Recaptcha In Livewire Class

@martinbean note that if I change this to vanilla laravel blade and controller it works

Activity icon

Replied to Validate Recaptcha In Livewire Class

@martinbean but its there

'g-recaptcha-response' => config('services.recaptcha.key') ? 'required|recaptcha' : 'nullable',
	@if(config('services.recaptcha.key'))
	                <div class="form-group">
	                    <div  wire:model="g-recaptcha-response" class="g-recaptcha"
	                    data-sitekey="{{config('services.recaptcha.key')}}">
	                    </div>
	                    @error('g-recaptcha-response')
	                        <span class="invalid-feedback mt-3" role="alert">
	                            <strong>{{ $message }}</strong>
	                        </span>
	                    @enderror
	                </div>
	            @endif
Oct
16
1 week ago
Activity icon

Replied to Validate Recaptcha In Livewire Class

@martinbean removed but still same error

Activity icon

Replied to Validate Recaptcha In Livewire Class

@martinbean am getting the following error

Exception No property found for validation: [g-recaptcha-response]

Activity icon

Started a new Conversation Validate Recaptcha In Livewire Class

I recently moved my contact form to a livewire component and everything works except my google recaptcha it no longer works

class

 // Validate contact info
        $this->validate([
            'name' => 'required|min:4|max:30',

            'email' => 'required|email',
            'subject' => 'required|min:5|max:100',
            'message' => 'required|min:30|max:500',
            'g-recaptcha-response' => config('services.recaptcha.key') ? 'required|recaptcha' : 'nullable',
        ]);

component form

<!-- google recaptcha -->
				@if(config('services.recaptcha.key'))
	                <div class="form-group">
	                    <div  wire:model.defer="g-recaptcha-response" class="g-recaptcha"
	                    data-sitekey="{{config('services.recaptcha.key')}}">
	                    </div>
	                    @error('g-recaptcha-response')
	                        <span class="invalid-feedback mt-3" role="alert">
	                            <strong>{{ $message }}</strong>
	                        </span>
	                    @enderror
	                </div>
	            @endif
Activity icon

Started a new Conversation How To Run A Method Inside Boot Only If Table And Dat Is Available

I have the following piece of data in appServiceProvider and I want the View::share to run if migrations have been done and if this piece of data exists

public function boot()
    {
        View::share('shareSettings', SystemSetting::first()); // I want this to run if migrations have been done and if this piece of data exists

        Schema::defaultStringLength(191);
        Validator::extend('recaptcha', 'App\Validators\[email protected]');
    }
Activity icon

Replied to Request Method: GET Status Code: 500 Internal Server Error

@tomasosho why are passing product_id & size

  <option value="{{$detail_product->id}}-{{$attrs->size}}">{{$attrs->size}}</option>

is it not suppose to be like this

  <option value="{{$attrs->id}}">{{$attrs->size}}</option>
Activity icon

Awarded Best Reply on How To Prevent Sending Notification If User Is Replying On His Own Comments

@mahmoudmonem

 public function store(Request $request)
    {
        $reply = Reply::create($request->all());
	$comment = // to the comment you are replying
	
	if ($comment->user_id === auth()->id) {
		return back()->with('success', 'Reply Submitted Successfully');
	}
    
        if ($reply && $reply->comment && $reply->comment->user ) {
            
            $reply->comment->user->notify(new RepliedToComment($reply));
            
            return back()->with('success', 'Reply Submitted Successfully');
        }
        return back()->with('error', 'Something wrong while submitting this reply!');
    }
Activity icon

Replied to To Carry Out CRUD Operations For Multiple Tables In A Single View

@toxifiedm if all the operations are going to be coming from the same view you can just create different methods within the same class

Activity icon

Awarded Best Reply on Laravel Live Wire Not Install In Laravel 6.18.35 Version

@towhid add this to composer.json file

"livewire/livewire": "^1.0"

then run composer update

Activity icon

Replied to Finding The Current Questionnaire_id.

@siyaniz i forgot to add $ variable

public function results(Questionnaire $questionnaire, SurveyResponse $surveyresponse) 
{
    dd($questionnaire);
}
Activity icon

Replied to My Responsibility To Add User [from The Social Media Data Got] To Users Table

@lse123 routes

Route::get('login/{provider}', 'Auth\[email protected]');
Route::get('login/{provider}/callback', 'Auth\[email protected]');

services.php

'google' => [
    'client_id' => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => env('GOOGLE_CALLBACK_URL'),
    ],

    'facebook' => [
    'client_id' => env('FACEBOOK_CLIENT_ID'),
    'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
    'redirect' => env('FACEBOOK_CALLBACK_URL'),
    ],

form

<div class="row mb-3">
                <div class="col-6">
                    <a href="/login/facebook" class="btn btn-block btn-social btn-facebook">Facebook</a>
                </div>
                <div class="col-6">
                    <a href="/login/google" class="btn btn-block btn-social btn-google">Google</a>
                </div>
            </div>

.env

FACEBOOK_CLIENT_ID= // put your id
FACEBOOK_CLIENT_SECRET= // put your secret from facebook
FACEBOOK_CALLBACK_URL=http://localhost:8000/login/facebook/callback

GOOGLE_CLIENT_ID= // put your id from google
GOOGLE_CLIENT_SECRET= // put your secret from google
GOOGLE_CALLBACK_URL=http://localhost:8000/login/google/callback
Activity icon

Replied to My Responsibility To Add User [from The Social Media Data Got] To Users Table

@lse123 your database may need modifications

 $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password')->nullable();
            $table->string('provider_id')->nullable();
Activity icon

Replied to My Responsibility To Add User [from The Social Media Data Got] To Users Table

@lse123 no need for another table. The following code checks if the user exists if it does they are logged in without having tryying to recreate the account again

$user = User::Where('email', $providerUser->getEmail())->first();
Activity icon

Replied to Finding The Current Questionnaire_id.

@siyaniz can you dd to see if it's returning any value

public function results(Questionnaire $questionnaire, SurveyResponse $surveyresponse) 
{
    dd(questionnaire);
}
Activity icon

Replied to Laravel 8 Jetstream - Vue Error

@hilbert provide additional info like component code

Activity icon

Replied to Finding The Current Questionnaire_id.

@siyaniz where are you defining $questionnaire->id

Activity icon

Awarded Best Reply on Migration Error

@meglo the class name is your migrations is CreateKaryawanTable not CreateKaryawansTable

try this

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateKaryawansTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('karyawans', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('nama_kyn', 30);
            $table->date('tgl_lahir');
            $table->string('j_kel', 10);
            $table->text('alamat');
            $table->char('no_tlp', 13);
            $table->date('join_date');
            $table->date('end_date')->nullable();
            $table->string('status', 10);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('karyawan');
    }
}
Activity icon

Replied to Why Is My Double / Float Values Casted As Rounded Integer In Model !

@princeoo7

public function getPriceAttribute(){
        return (number_format($this->attributes["price"] / 100, 2));
    }

@sinnbeck sorry didn't notice you had replied with the same answer

Activity icon

Replied to To Carry Out CRUD Operations For Multiple Tables In A Single View

@toxifiedm create instances of all the 3 models in your controller or livewire class then echo that data in your view in a tabular format. Then add buttons to edit and delete each instance and maybe a modal to create each model

Activity icon

Replied to Laravel Live Wire Not Install In Laravel 6.18.35 Version

@loyd correct as only support 7 or 8 as @sinnbeck said

Activity icon

Replied to FormStack Embedded Form

@eshban can you share your code

Activity icon

Replied to Laravel Live Wire Not Install In Laravel 6.18.35 Version

@towhid add this to composer.json file

"livewire/livewire": "^1.0"

then run composer update

Activity icon

Replied to Migration Error

@meglo the class name is your migrations is CreateKaryawanTable not CreateKaryawansTable

try this

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateKaryawansTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('karyawans', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('nama_kyn', 30);
            $table->date('tgl_lahir');
            $table->string('j_kel', 10);
            $table->text('alamat');
            $table->char('no_tlp', 13);
            $table->date('join_date');
            $table->date('end_date')->nullable();
            $table->string('status', 10);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('karyawan');
    }
}
Activity icon

Replied to How To Prevent Sending Notification If User Is Replying On His Own Comments

@mahmoudmonem

 public function store(Request $request)
    {
        $reply = Reply::create($request->all());
	$comment = // to the comment you are replying
	
	if ($comment->user_id === auth()->id) {
		return back()->with('success', 'Reply Submitted Successfully');
	}
    
        if ($reply && $reply->comment && $reply->comment->user ) {
            
            $reply->comment->user->notify(new RepliedToComment($reply));
            
            return back()->with('success', 'Reply Submitted Successfully');
        }
        return back()->with('error', 'Something wrong while submitting this reply!');
    }
Activity icon

Replied to Livewire And Controller

@mathewp

Yeah, it's a good question.

I think you can still have "RESTfull" methods in a Livewire component. But I personally wouldn't stick to it as strictly, because you would be forced to break things out into multiple components which isn't as cheap as breaking things out into separate controllers.

I personally would be fine doing validation and model creation inside a Livewire component method. I imagine some conventions will emerge, but for now, I'd say don't worry about it.

Activity icon

Replied to What Is The Way Of Adding Executable Eloquent Query Scope

@al_imran_ahmed

User::active()->reference($request->ref)->get();
Activity icon

Replied to My Responsibility To Add User [from The Social Media Data Got] To Users Table

@lse123

composer require laravel/socialite

then do something like

/**
     * Redirect the user to the provider authentication page.
     *
     * @return \Illuminate\Http\Response
     */
    public function redirectToProvider($provider)
    {
        return Socialite::driver($provider)->redirect();
    }

    /**
     * Obtain the user information from provider.
     *
     * @return \Illuminate\Http\Response
     */
    public function handleProviderCallback($provider)
    {
        $providerUser = Socialite::driver($provider)->user();

        $user = User::Where('email', $providerUser->getEmail())->first();

        if(!$user) {
                $user = User::create([
                'name' => $providerUser->getName(),
                'email' => $providerUser->getEmail(),
                'avatar' => $providerUser->getAvatar(),
                'provider_id' => $providerUser->getId(),
            ]);
        }

        Auth::login($user, true);

        return redirect($this->redirectTo);
    }

for more info https://laravel.com/docs/8.x/socialite#introduction

Oct
14
1 week ago
Activity icon

Replied to Passing Hidden Input Data To A Livewire Class Returning Null

livewire class

<?php

namespace App\Http\Livewire;

use Livewire\Component;
use Gloudemans\Shoppingcart\Facades\Cart;

class NavCart extends Component
{
	public $product;
	public $name;
	public $quantity;
	public $productIde;
	public $price;

	 public function addToCart()
    {
        // dd($request->all());
        // $duplicates = Cart::search(function ($cartItem, $rowId) use ($productId) {
        //     return $cartItem->id  === $this->productId;
        // });

        // if ($duplicates->isNotEmpty()) {
        //     session()->flash('success', "$request->name already in your cart!");

        //     // return redirect(route('cart.index'));
        // }
        dd($this->productIde);

        Cart::add($this->productIde, $this->name, $this->quantity, $this->price)->associate('App\Product');

        session()->flash('success', "$this->name added to your cart successfully!");

        // return redirect(route('cart.index'));
    }

    public function render()
    {
        return view('livewire.nav-cart');
    }
}

Activity icon

Started a new Conversation Passing Hidden Input Data To A Livewire Class Returning Null

Hi, devs am trying to pass hidden input data to a livewire class but it's returning null. Do I have do wire:model?

<div>
    <form  wire:submit.prevent="addToCart" action="#" method="post">
	    @csrf
	    <input  
	    	wire:model="productIde" id="productIde" 
	    	type="hidden" name="productIde" value="{{$product->id}}">
	    <input  
	    	wire:model="name" id="name"
	    	type="hidden" name="name" value="{{$product->name}}">
	    <input  
	    	wire:model="price" id="price"
	    	type="hidden" name="price" value="{{$product->price}}">
	    <input  
	    	wire:model="quantity" id="quantity"
	    	type="hidden" name="quantity" value="1">
	    <button type="submit" class="add-card"><i class="flaticon-bag"></i><span>ADD TO CART</span></button>
	</form>
</div>

Activity icon

Replied to How To Not Hit Error Exception When There Is No Value?

@felicia00 then do as @sinnbeck said.

if (empty($user_role)) {
    return redirect()->to('/'); //Replace with whatever redirect you need
} else
        {
               // redirect users to their expected routes
        }
Oct
10
2 weeks ago
Activity icon

Replied to Can't Fetch File From Public Folder

@dipcb05 To delete the file you have to explicitly pass the storage disk

Storage::disk('public')->delete($rev_file[0]->summary_doc);
Oct
06
2 weeks ago
Activity icon

Awarded Best Reply on 500 Error On Registering New User

@webfuelcode if it works fill out the .env mail details correctly

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME="${APP_NAME}"
Activity icon

Replied to 500 Error On Registering New User

@webfuelcode if it works fill out the .env mail details correctly

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME="${APP_NAME}"