Sti3bas

Member Since 2 Years Ago

Experience Points
344,350
Total
Experience

0 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
1159
Lessons
Completed
Best Reply Awards
390
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 50
344,350 XP
Mar
31
1 day ago
Activity icon

Awarded Best Reply on Change The Default Login Function

@omar590 that's because you should also update the field in your template, because its name is set to email:

<div class="form-group row">
   <label for="username" class="col-md-4 col-form-label text-md-right">{{ __('Username') }}</label>

   <div class="col-md-6">
      <input id="username" type="text" class="form-control @error('username') is-invalid @enderror" name="username" value="{{ old('username') }}" required autocomplete="username" autofocus>

      @error('username')
         <span class="invalid-feedback" role="alert">
            <strong>{{ $message }}</strong>
         </span>
      @enderror
   </div>
</div>

https://github.com/laravel/ui/blob/2.x/src/Auth/bootstrap-stubs/auth/login.stub#L18

Mar
30
2 days ago
Activity icon

Replied to Dusk Does Not Recognize Text In My H1, But Does In My Button.

@aaronmk2 do you tried ->waitForText('Sign Up')->assertSee('Sign Up')?

Activity icon

Awarded Best Reply on Laravel Dusk Relative Path Not Working, But Absolute Path Is

@aaronmk2 make sure APP_URL evn variable is correct.

Next, set the APP_URL environment variable in your .env file. This value should match the URL you use to access your application in a browser.

https://laravel.com/docs/7.x/dusk#installation

Activity icon

Replied to Laravel Dusk Relative Path Not Working, But Absolute Path Is

@aaronmk2 make sure APP_URL evn variable is correct.

Next, set the APP_URL environment variable in your .env file. This value should match the URL you use to access your application in a browser.

https://laravel.com/docs/7.x/dusk#installation

Activity icon

Replied to Form Vue To Laravel Validator - Best Way To Deal With The Dates

@boubou ah, (Central European Summer Time) is a part of your date string, not sure if it's the best way to remove it, but you can try this:

$date = trim(preg_replace("/\([^)]+\)/","", $request->date));

$request->merge([
   'date' => $date ? Carbon::parse($date)->setTimezone('UTC')->toDateTimeString() : null,
]);
Activity icon

Replied to Mailable Call Repository In Function Build

Right now you have a hard link with the framework and with the SubmitRepository class.

Well, the Mailable class itself is hard linked with the framework: https://github.com/illuminate/mail/blob/master/Mailable.php#L5

Would it be better if you change it to Container::getInstance()->make(SubmitRepository::class)? ;)

Activity icon

Awarded Best Reply on Form Vue To Laravel Validator - Best Way To Deal With The Dates

@boubou create FormRequest class and add prepareForValidation method:

protected function prepareForValidation()
{
    $this->merge([
        'date' => $this->date ? Carbon::parse($this->date)->setTimezone('UTC')->toDateTimeString() : null,
    ]);
}

https://laravel.com/docs/7.x/validation#prepare-input-for-validation

Otherwise you can do the same in your controller:

$request->merge([
   'date' => $request->date ? Carbon::parse($request->date)->setTimezone('UTC')->toDateTimeString() : null,
]);

$request->validate([
   //...
]);
Activity icon

Replied to Form Vue To Laravel Validator - Best Way To Deal With The Dates

@boubou create FormRequest class and add prepareForValidation method:

protected function prepareForValidation()
{
    $this->merge([
        'date' => $this->date ? Carbon::parse($this->date)->setTimezone('UTC')->toDateTimeString() : null,
    ]);
}

https://laravel.com/docs/7.x/validation#prepare-input-for-validation

Otherwise you can do the same in your controller:

$request->merge([
   'date' => $request->date ? Carbon::parse($request->date)->setTimezone('UTC')->toDateTimeString() : null,
]);

$request->validate([
   //...
]);
Activity icon

Replied to Why Is Injected Class Different To My Provider Registered Class?

@simonw as @bobbybouwmann already mentioned both \GuzzleHttp\Client::class and GuzzleHttp\Client::class will return string value of GuzzleHttp\Client (without \ prefix), you can try it yourself in Tinker (php artisan tinker):

>>> \GuzzleHttp\Client::class
=> "GuzzleHttp\Client"
>>> GuzzleHttp\Client::class
=> "GuzzleHttp\Client"
Activity icon

Awarded Best Reply on Passing An Instance But Missing Bindings

$configObject = new ConfigObject()->with(app(A::class));
Activity icon

Awarded Best Reply on Why Is Injected Class Different To My Provider Registered Class?

@simonw you don't need to prefix it with \:

$this->app->bind('GuzzleHttp\Client', function () {
   //...
});

// or

$this->app->bind(\GuzzleHttp\Client::class, function () {
   //...
});

// or (if class is imported)

$this->app->bind(Client::class, function () {
   //...
});
Activity icon

Awarded Best Reply on Mailable Call Repository In Function Build

@gzai just resolve it from the container in your build method:

public function build()
{
   app(SubmitRepository::class)->someMethod();

   return $this->view('some.email');
}

Or if you're going to use it in multiple methods and/or in your template:

public function __construct(Submit $submit)
{
   $this->submit = $submit;
   $this->submit_repository = app(SubmitRepository::class);
}
Activity icon

Replied to Mailable Call Repository In Function Build

@gzai just resolve it from the container in your build method:

public function build()
{
   app(SubmitRepository::class)->someMethod();

   return $this->view('some.email');
}

Or if you're going to use it in multiple methods and/or in your template:

public function __construct(Submit $submit)
{
   $this->submit = $submit;
   $this->submit_repository = app(SubmitRepository::class);
}
Activity icon

Replied to Why Is Injected Class Different To My Provider Registered Class?

@simonw you don't need to prefix it with \:

$this->app->bind('GuzzleHttp\Client', function () {
   //...
});

// or

$this->app->bind(\GuzzleHttp\Client::class, function () {
   //...
});

// or (if class is imported)

$this->app->bind(Client::class, function () {
   //...
});
Activity icon

Replied to Passing An Instance But Missing Bindings

$configObject = new ConfigObject()->with(app(A::class));
Activity icon

Awarded Best Reply on Laravel Query Builders.

@ivanradojevic you mean all query builder methods? You can find them in Illuminate\Database\Query\Builder class: https://laravel.com/api/7.x/Illuminate/Database/Query/Builder.html

Activity icon

Replied to Laravel Query Builders.

@ivanradojevic you mean all query builder methods? You can find them in Illuminate\Database\Query\Builder class: https://laravel.com/api/7.x/Illuminate/Database/Query/Builder.html

Activity icon

Replied to Change The Default Login Function

@omar590 that's because you should also update the field in your template, because its name is set to email:

<div class="form-group row">
   <label for="username" class="col-md-4 col-form-label text-md-right">{{ __('Username') }}</label>

   <div class="col-md-6">
      <input id="username" type="text" class="form-control @error('username') is-invalid @enderror" name="username" value="{{ old('username') }}" required autocomplete="username" autofocus>

      @error('username')
         <span class="invalid-feedback" role="alert">
            <strong>{{ $message }}</strong>
         </span>
      @enderror
   </div>
</div>

https://github.com/laravel/ui/blob/2.x/src/Auth/bootstrap-stubs/auth/login.stub#L18

Activity icon

Awarded Best Reply on Slug On A Resource Method HELP!! How To Do It... :(

Route::resource('user.services', 'ServiceController' , [
    'names' => [
        'index' => 'services',
        'create' => 'newService',
        'store' => 'storeService',
        'edit' => 'editService',
        'update' => 'updateService'
    ]
])

Add this to User model:

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

Add this to Service model:

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

https://laravel.com/docs/7.x/controllers#restful-nested-resources

https://laravel.com/docs/7.x/routing#implicit-binding

Mar
29
3 days ago
Activity icon

Awarded Best Reply on Double Click And Single Click On Same Element In Vue.js

<a @click.prevent="onClick(post.id)">
   <img class="card-img-top w-100" :src="post.image_path" />
</a>
data() {
   return {
      //...
      counter: 0
   };
},
methods: {
   onClick(postId) {
      this.counter++;
      
      if(this.counter == 1) {
         this.timer = setTimeout(() => {
            this.counter = 0;
            window.location.href = 'p/'+ postId;
         }, 300);

         return;
      }
      
      clearTimeout(this.timer);  
      this.counter = 0;
      this.likeThePost(postId);
   }
},

https://stackoverflow.com/a/41309853

Activity icon

Replied to Double Click And Single Click On Same Element In Vue.js

<a @click.prevent="onClick(post.id)">
   <img class="card-img-top w-100" :src="post.image_path" />
</a>
data() {
   return {
      //...
      counter: 0
   };
},
methods: {
   onClick(postId) {
      this.counter++;
      
      if(this.counter == 1) {
         this.timer = setTimeout(() => {
            this.counter = 0;
            window.location.href = 'p/'+ postId;
         }, 300);

         return;
      }
      
      clearTimeout(this.timer);  
      this.counter = 0;
      this.likeThePost(postId);
   }
},

https://stackoverflow.com/a/41309853

Activity icon

Awarded Best Reply on Only One Display On Relation With Pivot Table

@heimdall seems like you've mixed the pivot keys, it should be:

// $related, $table, $foreignPivotKey, $relatedPivotKey
return $this->belongsToMany('App\Dishs', 'category_dishes', 'categories_id', 'dishs_id');

return $this->belongsToMany('App\Category', 'category_dishes', 'dishs_id', 'categories_id');

https://laravel.com/docs/7.x/eloquent-relationships#many-to-many

Activity icon

Replied to Only One Display On Relation With Pivot Table

@heimdall as @snapey said:

@foreach($dish_by_category as $cat)
   {{ $cat->name }}

   @foreach($cat->dishes as $dishs)
      {{ $dishs->name }}
   @endforeach
@endforeach
Activity icon

Replied to Does Anyone Know How To Unittest Beyondcode/laravel-websockets In A App?

@jove unit test what? Events? Event is just a plain php class. For the feature tests Laravel has support for mocking it: https://laravel.com/docs/7.x/mocking#event-fake

Activity icon

Replied to Laravel Nova License

Solo licenses are for single developers working on products making less than $20k USD per year gross. Solo licenses are provided as a cost-effective way to allow single developers to get started using Nova.

Pro licenses are for multiple developers working on products making more than $20k USD per year gross. Pro licenses also receive email support. This is primarily targeted towards business customers.

https://nova.laravel.com/faq

Activity icon

Replied to After Removing Pagination Could Not Get The Data Via Api Laravel/Vuejs

@usmanbasharal well, it seems fine. this.Books should be an array of books objects. What problem do you have?

Activity icon

Replied to ` (errno: 150 "Foreign Key Constraint Is Incorrectly Formed") Posts_comment_id_foreign` Foreign Key (`comment_id`) References `comments` (`id`)

@dostogir make sure the type of foreign key field and id field matches. Both should be unsignedBigInteger.

Activity icon

Replied to Question About Local Storage Mainpulation By Client

@untymage yes, user can modify data stored in local storage, but it doesn't make sense because user will not be able to perform protected actions if it doesn't have a valid token. You should also never trust user input and validate it in the backend.

Activity icon

Replied to Slug On A Resource Method HELP!! How To Do It... :(

Route::resource('user.services', 'ServiceController' , [
    'names' => [
        'index' => 'services',
        'create' => 'newService',
        'store' => 'storeService',
        'edit' => 'editService',
        'update' => 'updateService'
    ]
])

Add this to User model:

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

Add this to Service model:

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

https://laravel.com/docs/7.x/controllers#restful-nested-resources

https://laravel.com/docs/7.x/routing#implicit-binding

Activity icon

Awarded Best Reply on Beginner: Having Trouble Understanding How To Extract The Data Out Of A Result From A Query.

@scottsuhy as far as I understand you want to get the first result, so try to change ->get(); to ->first()->purchase_price_total_LY; in your controller.

Activity icon

Replied to Session Lifetime Question.

@leostereo it's 120 minutes and I think you want to store in the cache instead of session: https://laravel.com/docs/7.x/cache

Activity icon

Replied to Loop Through $users In React

@boyjarv can you show your view file?

Activity icon

Replied to Only One Display On Relation With Pivot Table

@heimdall seems like you've mixed the pivot keys, it should be:

// $related, $table, $foreignPivotKey, $relatedPivotKey
return $this->belongsToMany('App\Dishs', 'category_dishes', 'categories_id', 'dishs_id');

return $this->belongsToMany('App\Category', 'category_dishes', 'dishs_id', 'categories_id');

https://laravel.com/docs/7.x/eloquent-relationships#many-to-many

Activity icon

Replied to Paginate Error On Second Page (The Page Isn’t Redirecting Properly)

@haroncorreia what is stored in $filters variable? And why you're passing it to appends method? Shouldn't it be appends(['filter' => request()->filter]) to append the current filter?

Activity icon

Replied to After Removing Pagination Could Not Get The Data Via Api Laravel/Vuejs

@usmanbasharal your code seems fine. What is returned as data from your API endpoint? console.log(data);

Activity icon

Replied to I Can't Install $ Npm Install && Npm Run Dev In Laravel 6 / 7

@neftaliwine this is just a warning, you can ignore it.

Activity icon

Replied to Loop Through $users In React

@boyjarv if you have a collection, you can call ->toJson() method which will return JSON string, then you can pass it to your react component.

https://laravel.com/docs/7.x/eloquent-serialization#serializing-to-json

Activity icon

Replied to Beginner: Having Trouble Understanding How To Extract The Data Out Of A Result From A Query.

@scottsuhy as far as I understand you want to get the first result, so try to change ->get(); to ->first()->purchase_price_total_LY; in your controller.

Activity icon

Replied to How Do I See Latest Uploads From Laracasts?

@ppshobi you should see "Newest Episodes" section in your profile page: https://laracasts.com/@ppshobi

You can also get it by going to https://laracasts.com/search and selecting "Episode" in "LESSON TYPE" filter.

Activity icon

Replied to Beginner: What Is The Best Way To Get Data From Multiple Tables Without Duplication

@bngaard you should start from watching this free series, it will answer a lot (if not all) of your questions: https://laracasts.com/series/laravel-6-from-scratch

Mar
28
4 days ago
Activity icon

Awarded Best Reply on Upgrade Laravel From 7.2.2 To 7.3

@halim just run composer update. It's minor upgrade, so it's backward compatible.

Activity icon

Replied to How To Retain Old Values Of An Input After Validation Field?

@moctarss yes, you can use old helper for any type of field.

Activity icon

Replied to Upgrade Laravel From 7.2.2 To 7.3

@halim just run composer update. It's minor upgrade, so it's backward compatible.

Activity icon

Replied to Handling An Incoming Webhook

@ameenmathers update your code to:

try {
    if ($request->header('verif-hash') !== "@postpaid") {
        throw new \Exception();
    }

    $payload = json_decode($request->getContent());

    if ($payload->status === "successful") {
        Order::find($payload->txRef)->update([
            "status" => "paid"
        ]);
    }
} catch (\Exception $exception) {
    return response(["message" => "Failed"], 500);
}

return response("Success", 200);

Run php artisan make:test WebhooksTest

Add this to the WebhookTest class:

public function test_webhook()
{
    $this->withoutExceptionHandling();
    
    $order = factory(Order::class)->create();

    $json = '{
    "id": 126122,
    "txRef": "' . $order->id . '",
    "flwRef": "FLW-MOCK-72d0b2d66273fad0bb32fdea9f0fa298",
    "orderRef": "URF_1523185223111_833935",
    "paymentPlan": null,
    "createdAt": "2018-04-08T11:00:23.000Z",
    "amount": 1000,
    "charged_amount": 1000,
    "status": "successful",
    "IP": "197.149.95.62",
    "currency": "NGN",
    "customer": {
        "id": 22836,
        "phone": null,
        "fullName": "Anonymous customer",
        "customertoken": null,
        "email": "[email protected]",
        "createdAt": "2018-04-08T11:00:22.000Z",
        "updatedAt": "2018-04-08T11:00:22.000Z",
        "deletedAt": null,
        "AccountId": 134
    },
    "entity": {
        "card6": "539983",
        "card_last4": "8381"
    },
    "event.type": "CARD_TRANSACTION"
    }';

    // update URL
    $response = $this->postJson('/YOUR_WEBHOOK_ENDPOINT', json_decode($json, true), [
        'HTTP_VERIF_HASH' => '@postpaid'
    ]);

    $response->assertStatus(200);

    $this->assertEquals("paid", $order->fresh()->status);
}

Run phpunit. What do you get?

Are you sure that txRef contains order id?

Activity icon

Replied to Handling An Incoming Webhook

@ameenmathers which response do you get?

Activity icon

Awarded Best Reply on Question Regarding Promises And Then Catch

@gabotronix you should re-throw the error in your catch callback:

(error) => {
   commit('Loader/SET_LOADER', { status:3, errors: error }, { root: true });

   throw error;
}
Activity icon

Replied to Handling An Incoming Webhook

@ameenmathers try this:

public function postPaid(Request $request) {
    try {
        if ($request->header('HTTP_VERIF_HASH') !== "@postpaid") {
            throw new \Exception();
        }

        $payload = json_decode($request->getContent(), true);

        if ($payload->status === "successful") {
            Order::find($payload->txRef)->update([
                "status" => "paid"
            ]);
        }
    } catch (\Exception $exception){
        return response(["message" => "Failed"], 500);
    }

    return response("Success", 200);
}

Also, don't forget to add this route to except array in App\Http\Middleware\VerifyCsrfToken class.

Activity icon

Replied to Handling An Incoming Webhook

@ameenmathers what are you trying to check with if($request->header('@postpaid')) {?

Are you trying to handle webhooks from https://developer.flutterwave.com/docs/events-webhooks ?