Loyd

Loyd

Member Since 5 Months Ago

Experience Points
11,400
Total
Experience

3,600 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
14
Lessons
Completed
Best Reply Awards
11
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.

Level 3
11,400 XP
Sep
27
22 hours ago
Activity icon

Replied to Where Is The App Id In Laravel 8 And Jetstream?

Its in your layouts under resources then views

Activity icon

Replied to Help Me To Convert This SQL Query Into Eloquent

Please format your code using back ticks


Activity icon

Replied to Index.php In Public Folder Is Not Loading Js And Css Files

@zool in your .env change APP_URL from

localhost:8000

To

http://localhost/ecommerce/ecommerce/ecommerce/

And then restart yor server and try again

Activity icon

Started a new Conversation Facebook And Instagram Cool Feature Tagging Products On Images

In the past year facebook and instagram introduced the capability to tag products from a catalogue to a post and be able to view product details from a post and also a link to click to view more.

I was just wondering how this can be done in laravel, livewire and maybe vue.

Any ideas. Thanks.

Sep
22
5 days ago
Activity icon

Started a new Conversation Conditional Validate A Filled If A Certain Condition Is Met

Hi Devs, I want to conditionally validate the recaptcha if the google_recaptcha_key is not equal to null in my laravel app.

What I have

blade

                                @if(config('services.recaptcha.key'))
			                <div class="g-recaptcha mb-3"
			                    data-sitekey="{{config('services.recaptcha.key')}}">

			                    @error('g-recaptcha-response')
			                        <span class="invalid-feedback mt-3" role="alert">
			                            <strong>{{ $message }}</strong>
			                        </span>
			                    @enderror
			                </div>
			            @endif

validate

       return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
            'g-recaptcha-response' => 'required|recaptcha'
        ]);

I only want to run the validation on g-recaptcha-response if(config('services.recaptcha.key'))

Sep
20
1 week ago
Activity icon

Replied to Project Suggestion

Social media app maybe an fb or tinder clone

Sep
18
1 week ago
Activity icon

Replied to Trying To Get Property 'name' Of Non-object

@michaloravec tried your methods it works now I know where my problem was. Thanks so much for sharing.

Activity icon

Replied to Trying To Get Property 'name' Of Non-object

@sinnbeck thanks for the insight (maybe there is a bug in my code) if you ever experience the same issue and find a solution please share. Thanks a lot.

Activity icon

Replied to Trying To Get Property 'name' Of Non-object

@sinnbeck could it be that in my case I had not explicitly defined my foreign keys

Activity icon

Replied to Trying To Get Property 'name' Of Non-object

@sinnbeck how come I was having that error?

Activity icon

Replied to Trying To Get Property 'name' Of Non-object

@snapey @silencebringer @sinnbeck thanks a lot devs

this worked like a charm (changed subcategory to subCategory) in relationship

Activity icon

Replied to Trying To Get Property 'name' Of Non-object

@silencebringer looks like it does

App\SubCategory {#1588 ▼
  #fillable: array:3 [▶]
  #connection: "sqlite"
  #table: "sub_categories"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:6 [▼
    "id" => "2"
    "name" => "Sub 2"
    "slug" => "sub-2"
    "category_id" => "2"
    "created_at" => "2020-09-14 13:56:01"
    "updated_at" => "2020-09-14 13:56:01"
  ]
  #original: array:6 [▶]
  #changes: []
  #casts: []
  #classCastCache: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
}
Activity icon

Replied to Trying To Get Property 'name' Of Non-object

@sinnbeck in my controller

public function index()
    {
        $products = Product::orderBy('created_at', 'DESC')->with('photos')->paginate(10);

        return view('admin.products.index', compact('products'));
    }
Activity icon

Replied to Trying To Get Property 'name' Of Non-object

@sinnbeck product migrations

 $table->unsignedBigInteger('sub_category_id')->nullable();
Activity icon

Replied to Trying To Get Property 'name' Of Non-object

@sinnbeck it's returning no subcategory but if I get an instance of that product in tinker am getting the following

         name: "Juice 2",
         code: "juice 2",
         description: "juice 2",
         quantity: "4",
         slug: "juice-2",
         category_id: "3",
         created_at: "2020-09-03 17:18:27",
         updated_at: "2020-09-14 13:57:34",
         sub_category_id: "2",
         price: "220",
         meta_keywords: null,
         meta_description: null,
         on_sale: "0",
         is_new: "0",

and $p is set as follows

@foreach($products as $index => $p)
   // my code here
@endif
Activity icon

Replied to Trying To Get Property 'name' Of Non-object

@silencebringer in my view am checking if not null

@if($p->sub_category_id != null)
       {{ $p->subcategory->name }}
@else
Activity icon

Replied to Trying To Get Property 'name' Of Non-object

@snapey sorry I did paste the wrong model, I have edited the question with the correct relationships

Activity icon

Awarded Best Reply on Request Validate

@kikogyh you missed a $ on request change to $request

public function store(Request $request, $project_id) 
    {
        $request()->validate([
            'news' => ['required', 'string', 'max:2500', 'min:30'],
            'terms' => ['required'],
        ]);

        $dv = new Developer();
        $dv->news          = $request->input('news');
        $dvs->developer_id  = Auth::user()->id;
        $dv->project_id    = Project::findOrFail($project_id)->id;
        $dv->first_name    = Auth::user()->first_name;
        $dv->last_name     = Auth::user()->last_name;
        $dv->project_name  = Project::findOrFail($project_id)->name;
        $dev->links         = $request->input('video_live');
       
        $developerNews->save();
        Auth::user()->decrement('post_limit', 1);
        return back();
    }
Activity icon

Replied to Request Validate

@kikogyh you missed a $ on request change to $request

public function store(Request $request, $project_id) 
    {
        $request()->validate([
            'news' => ['required', 'string', 'max:2500', 'min:30'],
            'terms' => ['required'],
        ]);

        $dv = new Developer();
        $dv->news          = $request->input('news');
        $dvs->developer_id  = Auth::user()->id;
        $dv->project_id    = Project::findOrFail($project_id)->id;
        $dv->first_name    = Auth::user()->first_name;
        $dv->last_name     = Auth::user()->last_name;
        $dv->project_name  = Project::findOrFail($project_id)->name;
        $dev->links         = $request->input('video_live');
       
        $developerNews->save();
        Auth::user()->decrement('post_limit', 1);
        return back();
    }
Activity icon

Replied to Fixing N+1 Problem

@automica thanks a lot

Activity icon

Started a new Conversation Trying To Get Property 'name' Of Non-object

am having an issue Trying to get the property 'name' of non-object.

I have a product model that has belongs to category and subcategory

my relationships in category model

protected $fillable = ['name', 'slug'];

    public function getRouteKeyName()
    {
    	return 'slug';
    }

    public function subcategories()
    {
    	return $this->hasMany(SubCategory::class);
    }

    public function products()
    {
    	return $this->hasMany(Product::class);

product model

public function category()
    {
    	return $this->belongsTo(Category::class);
    }

    public function subcategory()
    {
        return $this->belongsTo(SubCategory::class);
    }

    public function transactions()
    {
    	return $this->hasMany(Transaction::class);
    }

in subcategory

public function category()
    {
    	return $this->belongsTo(Category::class);
    }

    public function products()
    {
    	return $this->hasMany(Product::class);
    }

in my view

{{ $p->subcategory->name }}
Activity icon

Replied to Fixing N+1 Problem

@sinnbeck thanks that helped

Activity icon

Started a new Conversation Fixing N+1 Problem

Hi devs, I am currently working on enhancing my app, how can I fix limit 1 issue select * from "system_settings" limit 1

my query

View::share('shareSettings', SystemSetting::first());
Sep
14
1 week ago
Activity icon

Replied to ECommerce Currency Switcher

@snapey database design for such a scenario. Thanks for your reply I found a related tutorial on devto

Activity icon

Replied to ECommerce Currency Switcher

@snapey Thanks for your response. It doesn't have to be real-time so I would say there is no need for a 3rd party API

Its something that an admin can manually enter

Activity icon

Replied to Load Balancer

@rully make your function/method reusable

eg

private function reusableMethod()
{
     $myName = 'Loyd';

     return $myName;
}

where you want to use it in your class just call

$name = $this->reusableMethod();
Activity icon

Started a new Conversation ECommerce Currency Switcher

Hi Devs.

I want to add a multi-currency feature to an existing Laravel project. Currently, the platform supports a single currency. By default, the platform currency is going to be USD and then have other currencies, and if the user selects another currency I would want the view to re-render and display the correct currency.

Frankly, I have no idea how to do this but from the back of my mind, I think I should have a currency table and have rates something like that.

Any ideas?

Thanks.

Sep
11
2 weeks ago
Activity icon

Started a new Conversation Laravel Jetstream To An Existing Laravel

Is it posible to add laravel jetstream to an existing laravel project. Currently on laravel 7 but my question comes if i update to laravel 8.

Sep
08
2 weeks ago
Activity icon

Started a new Conversation Storing Google Analytics & Facebook Pixel Code In DB (JS CODE)

I stored google analytics and Facebook pixels code in DB as text and when call-in in my view its not being called it is being escaped. I think because it is rendered as plain text. How can I successfully store analytics code and render it to the view from DB?

in other words, How to safely store javascript code in the database and render them to the blade template.

table

table->text('facebook_pixel');
table->text('google_analytics');

view

<head>
	{{ $code->google_analytics }}
        {{ $code->facebook_pixel }}
</head>
Sep
07
2 weeks ago
Activity icon

Started a new Conversation Paginate Through A Relationship

I want to paginate products that fall in a certain category

$products = $category->products->all();

i want to do something like

$products = $category->products->paginate(8);

error BadMethodCallException Method Illuminate\Database\Eloquent\Collection::paginate does not exist.

Sep
04
3 weeks ago
Activity icon

Replied to Cannot Save Price Variable To Table

@redlik how you saving to your db

Sep
03
3 weeks ago
Activity icon

Replied to Chartjs Doesn't Output Results In Production

@devionti share the code where you are drawing your chart in your view

Activity icon

Replied to Laravel SweetAlert 2 Toast Message Not Hiding :

delete the toastr css and js files and redownload the .min versions.

Activity icon

Replied to Strange Livewire Problem

@krismanning show your code.

Activity icon

Replied to Install Laravel Ui On Shared Hosting

run composer update on local then npm update the npm run production then zip your files and upload again then unzip once that is done

Activity icon

Replied to Does Anyone Know A Configuration Application Built With Laravel?

To call or consume external API in Laravel you use Guzzle Http.

From Laravel 7 by default you have Http installed all you have to do is to import it

use Http;

in your controller method, you can have something like (this depends with the API docs)

$myVariable = Http::withToken(env('MY_API_TOKEN'))->get('https://api.example.com/1/games/popular')->json()['results'];
Aug
30
4 weeks ago
Activity icon

Replied to Getting Data From View To Controller

@itprocity continue with laravel its good

Activity icon

Awarded Best Reply on Getting Data From View To Controller

@itprocity in js you can loop to get the status before performing the ajax call or you can send the object to your controller and only select the status

var Response = {
   amount: 54600,
   currency: "NGN",
   customer: {
        name: "Yemi Desola", 
        email: "[email protected]", 
        phone_number: "08102909304"
    },
   flw_ref: "FLW-MOCK-597ae423f1470309edcb5879e3774bfa",
   status: "successful",
   tx_ref: "hooli-tx-1920bbtyt",
   transaction_id: 495000
}

 for(var status in Response){
  alert(status + ' : ' + Response[status])
 }

since this question is now closed I advise to a new discussion so that you can get help from everyone.

Activity icon

Replied to Php Mysql Database Not Uploading The File

let's see what you have tried so far?

Activity icon

Replied to Why Is This Boolean Field Not Working?

@geerizzle it may be that your method is always returning true

Activity icon

Replied to Why Is This Boolean Field Not Working?

@geerizzle let's see the boolean field called notify_user. Share the code

Activity icon

Replied to Getting Data From View To Controller

@itprocity in js you can loop to get the status before performing the ajax call or you can send the object to your controller and only select the status

var Response = {
   amount: 54600,
   currency: "NGN",
   customer: {
        name: "Yemi Desola", 
        email: "[email protected]", 
        phone_number: "08102909304"
    },
   flw_ref: "FLW-MOCK-597ae423f1470309edcb5879e3774bfa",
   status: "successful",
   tx_ref: "hooli-tx-1920bbtyt",
   transaction_id: 495000
}

 for(var status in Response){
  alert(status + ' : ' + Response[status])
 }

since this question is now closed I advise to a new discussion so that you can get help from everyone.

Activity icon

Replied to Getting Data From View To Controller

@itprocity by default flutter wave return an object like

{
   amount: 54600
   currency: "NGN" 
   customer: {
        name: "Yemi Desola", 
        email: "[email protected]", 
        phone_number: "08102909304"
    }
   flw_ref: "FLW-MOCK-597ae423f1470309edcb5879e3774bfa"
   status: "successful",
   tx_ref: "hooli-tx-1920bbtyt",
   transaction_id: 495000
}

after a successful transaction, you can console log to view this data,

to then pass data to your controller from this object you can perform an ajax call to send the data to your controller.

Then save it or do whatever you want with it.

Activity icon

Replied to How Can I Filter Firebase Data With Laravel By " Name " ?

@mahmoudtrageh

$filterByName = $firebase
              ->getReference("tableName/name")
              ->get();
Activity icon

Replied to Unable To Delete Record As Authenticated User (vendor)

@erikrobles can you share your controller where u are returning the delete view

Aug
29
4 weeks ago
Activity icon

Replied to Game Server Service Using Laravel

@mekaboo

  1. laravel new SwarzieServer

  2. composer require laravel/ui

  3. php artisan ui vue --auth

By doing the steps above you now have user authentication.

Depending on your game setup assuming that its an HTML file that is being drawn using the js canvas.

You have to create a route in your routes that call the index.html that you would have remained to Laravel templating engine something like index.blade.php and save it in resources/views

routes example

Route::get('gameplay', '[email protected]')->middleware('auth');

controller example

public function index()
{
    return view('index');
}

by doing this only logged-in users will be apple to access your game

Activity icon

Awarded Best Reply on Game Server Service Using Laravel

@mekaboo Just create endpoints for your game in the Laravel app and protect the game routes with the auth guard