Wakanda

Member Since 1 Year Ago

New York

Experience Points
34,910
Total
Experience

90 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
64
Lessons
Completed
Best Reply Awards
30
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 7
34,910 XP
May
08
1 day ago
Activity icon

Replied to Laravel 8 Shopping Cart Quantity Display Issue

@msaad can you dd($request->quantity) to see what you are getting from your ajax request

Activity icon

Replied to Query Builder: How To Select Rows Based On A Given Time Range.

@reprogammer

// 5 mins or less
Model::whereRaw('MINUTE(created_at) <= 5')->get();

// 5 mins or more
Model::whereRaw('MINUTE(created_at) >= 5')->get();
Activity icon

Replied to Laravel 8 Cart Condition Issue

@msaad what kind of condition?

Activity icon

Replied to Movie Website , How To Get Casts Of A Movie In My DB, From External Api Tmdb

@xuuto Andre has a series about and it's a complete no-brainer. I suggest you watch and you will be back on your feet https://www.youtube.com/watch?v=9OKbmMqsREc&list=PLEhEHUEU3x5pYTjZze3fhYMB4Nl_WOHI4

May
07
2 days ago
Activity icon

Awarded Best Reply on Get The Next Value Is The Array

Fixed by using next PHP function

$this->question = next($questions);
Activity icon

Replied to Get The Next Value Is The Array

Fixed by using next PHP function

$this->question = next($questions);
Activity icon

Started a new Conversation Get The Next Value Is The Array

Hi de,

I have an array like

array:40 [▼
  0 => array:8 [▶]
  1 => array:8 [▶]
  2 => array:8 [▶]
  3 => array:8 [▶]
  4 => array:8 [▶]
  5 => array:8 [▶]
  6 => array:8 [▶]
  7 => array:8 [▶]
  8 => array:8 [▶]
  9 => array:8 [▶]
  10 => array:8 [▶]
  11 => array:8 [▶]
  12 => array:8 [▶]

and in my PHP class am getting the first index of the array

 public function__construct()
    {
        $this->questions = $this->exam->questions()->with('answers')->get()->toArray();;

        $this->question = $this->questions[0];
    }

so my question is how can I increment the index from 0 to 1 and so on on the next requests when setting a new value on the variable $this->question? or How to get the next key in an array from the given key in PHP?

May
04
5 days ago
Activity icon

Awarded Best Reply on Laravel 403 Forbidden Nginx

Apparently, I had a folder named library in the root folder and also had a route by the name library, after renaming the folder my app is up and running.

Activity icon

Replied to Laravel 403 Forbidden Nginx

Apparently, I had a folder named library in the root folder and also had a route by the name library, after renaming the folder my app is up and running.

Activity icon

Replied to Laravel 403 Forbidden Nginx

new additional error

2021/05/04 08:20:54 [alert] 576161#576161: worker process 576162 exited on signal 9

Activity icon

Replied to Inertiajs Question - Routes Between Vue Component And Normal Blade.

@alzaabi98 Inertia. js allows developers to write single-page applications (SPAs) using classic server-side routing and controllers. Inertia tightly couples the backend to the frontend so that developers need not write APIs.

Inertia works with frontend frameworks like Vue or react and yes your all your blade needs to be converted to vuejs.

Activity icon

Started a new Conversation Laravel 403 Forbidden Nginx

Hi Devs,

I am experiencing a 403 Forbidden Nginx on my server but only at a specific page /library and this was working well before Nginx error logs am getting


2021/05/04 07:08:12 [crit] 572738#572738: *57 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshaking, client: 35.203.252.157, server: 0.0.0.0:443
2021/05/04 07:08:13 [crit] 572738#572738: *62 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshaking, client: 107.178.238.47, server: 0.0.0.0:443

How can fix this?

I also tried removing the SSL certificate and adding it back again but still the same error on that specific page

other logs

2021/05/04 07:28:43 [notice] 574200#574200: signal process started
2021/05/04 07:32:16 [notice] 574839#574839: signal process started
May
03
6 days ago
Activity icon

Replied to Check If One Of The 4 Variable Exists Or Isset

@michaloravec yes, it is considering am dealing with category and child categories and they have the same attributes, yes it is better on this specific scenario

Activity icon

Replied to Check If One Of The 4 Variable Exists Or Isset

@michaloravec haaa nice this makes me have fewer code thanks.

Activity icon

Started a new Conversation Check If One Of The 4 Variable Exists Or Isset

Hi Devs, I am trying to reuse a blade view on 4 different scenarios. I have 4 variables and only one isset at a given request. What I first thought of is a switch statement but then realized that I first need to set a switch statement to be equal to something and then check in the cases if that's true or false. Given my scenario how can I tackle this?

May
02
1 week ago
Activity icon

Started a new Conversation Polymorphic For Parent To Child

Hi Devs, trying to wrap my head around the idea of reusing my Category Model in my app bear in mind that the category is the Parent.

I have a book that belongs to a category and a course that belongs to a category and a school that belong to a category is there a way to use the same model for all 3 child models bear in mind that a polymorphic relationship allows the child model to belong to more than one type of model using a single association.

The three child models have different category names and its highly unlikely for them to share a category name hence the need for reusability of the same model in different child models, than creating a category model for each child

I could do something like book->category() but in most cases, I would want to display only book categories or school categories.

How can I achieve this?

Activity icon

Replied to Eloquent On Model

@brainyt you create eloquent scopes in model see here https://laravel.com/docs/8.x/eloquent#query-scopes

Apr
28
1 week ago
Activity icon

Replied to Conditional Search Query

@tisuchi thanks for that

Activity icon

Replied to Conditional Search Query

@tykus Thanks man

Activity icon

Started a new Conversation Conditional Search Query

Hi Devs,

I have a live wire class that is supposed to get all the books at first render and then conditional query depending on user input for example if a user clicks on a certain category it returns a book that related to the category. So my question is how can I render my component with books without queries and when needed I serve the user with requested data?

 	public $typeId;
    public $categoryId;
    public $subCategoryId;

    public function render()
    {
        $books = Book::where('book_type_id', $this->typeId)
                        ->where('book_category_id', $this->categoryId)
                        ->where('book_sub_category_id', $this->subCategoryId)
                        ->paginate(12);
	}
Activity icon

Awarded Best Reply on Retrieve Latest Data Collection

@rafaeladi

    public function testExecution($case_id)
    {
        return DB::table('test_executions as e')
                    ->select('h.name as host','e.*','b.*','c.name as case','c.suite_id as suite','e.id as exec_id')
                    ->rightJoin('test_cases as c','e.case_id','=','c.id')
                    ->rightJoin('test_suites as s','c.suite_id','=','s.id')
                    ->rightJoin('build_versions as b','e.build_id','=','b.id')
                    ->rightJoin('test_hosts as h','e.host_id','=','h.id')
                    ->where('c.id',$case_id)
					->whereDate('created_at', Carbon::today())
                    ->latest()
                    ->get();

    }
Activity icon

Replied to Retrieve Latest Data Collection

@rafaeladi import in your controller just after the name space

use Carbon\Carbon;
Activity icon

Replied to Retrieve Latest Data Collection

@rafaeladi

    public function testExecution($case_id)
    {
        return DB::table('test_executions as e')
                    ->select('h.name as host','e.*','b.*','c.name as case','c.suite_id as suite','e.id as exec_id')
                    ->rightJoin('test_cases as c','e.case_id','=','c.id')
                    ->rightJoin('test_suites as s','c.suite_id','=','s.id')
                    ->rightJoin('build_versions as b','e.build_id','=','b.id')
                    ->rightJoin('test_hosts as h','e.host_id','=','h.id')
                    ->where('c.id',$case_id)
					->whereDate('created_at', Carbon::today())
                    ->latest()
                    ->get();

    }
Activity icon

Replied to Disable Artisan Commands

@snapey thanks, maybe i need to change my backups from weekly to daily

Activity icon

Replied to Disable Artisan Commands

@snapey I know it prompts when in production, but my case is that in the production environment I never want to run php artisan migrate:fresh. So prompting does not mean it cannot run it completely. So just adding an extra protection layer in case of human error.

And to be explicit am worried about migrate:fresh rollback and refresh commands, so disabling them helps me better sleep at night.

Apr
27
1 week ago
Activity icon

Replied to Disable Artisan Commands

@laracoft Fixed thanks man

Activity icon

Replied to Disable Artisan Commands

@martinbean it turns out can be achieved check @laracoft solution and also found a similar solution here https://stackoverflow.com/questions/63588629/is-there-a-way-to-disable-artisan-commands

Activity icon

Replied to Disable Artisan Commands

@martinbean Thanks for your reply that would work but would still need access to commands for caching, crone, sitemap, and other custom commands

Activity icon

Started a new Conversation Disable Artisan Commands

Hi Devs, is there a way to disable the artisan command. For example in the production environment, I never want to run PHP artisan migrate:fresh.

Apr
25
2 weeks ago
Activity icon

Awarded Best Reply on Route Any Except Routes With And Admin Middleware

Fixed by moving the any route below admin routes

Activity icon

Replied to Route Any Except Routes With And Admin Middleware

Fixed by moving the any route below admin routes

Activity icon

Started a new Conversation Route Any Except Routes With And Admin Middleware

Hi, devs,

Current set up I have an admin dashboard that is utilizing Laravel router and working in a more traditional way using laravel blade, now I want to use vue and vue router for the non-admins and guest routes and I understand that I have to do something like

Route::any('{any}', function () {
    return view('welcome');
})->where('any', '.*');

but since I have other admin routes with a middleware of admin how can I get all routes in any except the admin routes?

Apr
24
2 weeks ago
Activity icon

Replied to Failed Asserting That Two Strings Are Equal.

@laracoft was not passing slug thanks

Activity icon

Replied to Failed Asserting That Two Strings Are Equal.

@laracoft tried without middleware but same error

Activity icon

Replied to Failed Asserting That Two Strings Are Equal.

@wakanda

array:5 [
  "cache-control" => array:1 [
    0 => "no-cache, private"
  ]
  "date" => array:1 [
    0 => "Sat, 24 Apr 2021 17:49:59 GMT"
  ]
  "location" => array:1 [
    0 => "http://ecomtest.test"
  ]
  "content-type" => array:1 [
    0 => "text/html; charset=UTF-8"
  ]
  "set-cookie" => array:2 [
    0 => "XSRF-TOKEN=eyJpdiI6IkxWWmhjdlpSa3RkZmpJUmtURytZdFE9PSIsInZhbHVlIjoiR0ZYK1BEeGRSbTNhMENrbldlSXU4MnVQSGtCWnpwUW8wSnhoQnZnTm0wRzZnQ01RWDZ2WjlWaUxkRjBOWjVzcVZ2TisrSUdienFBakIxdFZsL3RwZW0yUThCQjgrcTVQWUxHQm5lVFVPZTN2SjhOUDg4Y0JMaEZvdkZrK2FJeFYiLCJtYWMiOiI5MGQxZWExYmMyNjNmMjU1ZTRkMGVjNWEwY2Y3MWRjNjU3MzViNGQzMjQwNDEyYjg0NmNkZWZiMGE0MzJjOTNlIn0%3D; expires=Sat, 24-Apr-2021 19:49:59 GMT; Max-Age=7200; path=/; samesite=lax"
    1 => "laravel_session=eyJpdiI6ImQ5Z0Q1NE9Nd3VwWWNRNFFFMm5QSUE9PSIsInZhbHVlIjoiRm9mdThkRTE4aTFtM25SQkRNOGRJMTcySjBicFZlN1RadTdzd0xIUE5JNjB1Z0Q3NWFVTnhlVWJuME1wQ2JsZnZjMjI1UUMrdXh5aWNnZ3dGZHFiL0RPeURxdXRueWxvRTJHVk1FVm9ENmhMSk9IeUZreEpwa0JsSlZwQ2RHWGoiLCJtYWMiOiIxNDgyYmI3NGYxYzg5YTVmMWZlNGIyMWZmZmE4YTg3MGJhZDNlZjU0N2U5ODlhNmJiMmRlYTJkZjhlYmU1NjA1In0%3D; expires=Sat, 24-Apr-2021 19:49:59 GMT; Max-Age=7200; path=/; httponly; samesite=lax"
  ]
]
Activity icon

Replied to Failed Asserting That Two Strings Are Equal.

@laracoft works the same way I changed for testing purposes but still the same error and I think the error is coming from

private function calculateDiscount(Product $product)

Activity icon

Replied to Failed Asserting That Two Strings Are Equal.

@laracoft

<!DOCTYPE html>\n
<html>\n
    <head>\n
        <meta charset="UTF-8" />\n
        <meta http-equiv="refresh" content="0;url='http://ecom.test'" />\n
\n
        <title>Redirecting to http://ecomtest.test</title>\n
    </head>\n
    <body>\n
        Redirecting to <a href="http://ecomtest.test">http://ecom.test</a>.\n
    </body>\n
</html>
Activity icon

Started a new Conversation Failed Asserting That Two Strings Are Equal.

I have a test that can test if an admin can edit products

and when I run it I get the error Failed asserting that two strings are equal. how can I fix this?

Test

public function test_admin_can_edit_products()
    {
        $this->withExceptionHandling();

        $user = User::factory()->create(['admin' => 1]);

        $product = Product::factory()->create();

        $response = $this->actingAs($user)->patch('/admin/product/' . $product->slug, [
            'name' => 'iPhone X',
            'description' => 'This is a new iphone',
            'price' => 220,
        ]);

        $response->assertRedirect(route('product.index'));
    }

my edit controller

public function update(Request $request, Product $product)
    {
        $validated  = $request->validate([
            'name' => 'required|unique:products,name,' . $product->id,
            'slug' => 'required|unique:products,slug,' . $product->id,
            'price' => 'required|integer',
            'description' => 'required',
        ]);


        $product->update($validated);

        $this->calculateDiscount($product);

        return redirect(route('product.index'));
    }

private function calculateDiscount(Product $product)
    {
        if($product->price >= 112 && $product->price <= 115) {
            $percentage = 0.25;
            $price = $product->price;

            $discount = ($percentage / 100) * $price;

            if($product->discount()->exists()){
                $product->discount()->update(['discount' => $discount]);

            } else {

                $product->discount()->create(['discount' => $discount]);
            }
        }

        if($product->price >= 120) {
            $percentage = 0.50;
            $price = $product->price;

            $discount = ($percentage / 100) * $price;

            $product->discount()->create(['discount' => $discount]);
        }
    }
Apr
21
2 weeks ago
Activity icon

Replied to Is It Okay To Save Uploaded Image In Public Folder?

@nickywan123 if the images are supposed to be accessed by everyone that won't be an issue unless if the images will be private

Activity icon

Replied to Is It Okay To Save Uploaded Image In Public Folder?

@nickywan123 you won't have any problems all you need to do is run

php artisan storage:link

and you are good to go

Activity icon

Replied to How To Make Title Page Dynamic ?

@coupdegraces put your variable in double quotes

@section('header', "{{ $judul1 }}" )
Activity icon

Replied to Finger Print

@adeyeye005 you may want to look at this package https://github.com/DarkGhostHunter/Larapass

Activity icon

Replied to Call A Model In Blade Like (Auth::user())

@marcolino922 why dont you have a single table for your setting and have a name, tagline, and description is a single table or row, then you can get a single instance of settings

Activity icon

Replied to Must Be Of The Type Array,

@swimmer

$diffArray = (array) $diff;

 Sku::insert($diff);
Activity icon

Awarded Best Reply on Larapex Charts

@rafaeladi but to save time you may want to use the default charts all u need to do is to publish the package js file and reference it in your view and do staff

https://larapex-charts.netlify.app/host-your-own-library-file

Activity icon

Replied to How To Always Have A User Model, Whatever If He Is Registered Or Not?

@arnissolle in that case on the admin one you could add a boolean in the user table that checks if a user is an admin then do this in your user model

public function isAdmin()
    {
        return $this->admin == 1;
    }

am not sure what isRegister() is supposed to do but the guest one Laravel supports it out of the box