Sti3bas

Member Since 2 Years Ago

Experience Points
340,820
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
1158
Lessons
Completed
Best Reply Awards
384
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
340,820 XP
Mar
30
12 hours ago
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
1 day 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
2 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 ?

Activity icon

Awarded Best Reply on Pre-populate Route Parameter

@morcen something like this might work:

php artisan make:middleware SetDefaultCompanySlugForRoutes

public function handle($request, Closure $next)
{
    $route = app('router')->getCurrentRoute();

    if($route->hasParameter('company_slug')) {
        app('url')->defaults([
            'company_slug' => $route->parameter('company_slug'),
        ]);
    }
    
    return $next($request);
}
use App\Http\Middleware\SetDefaultCompanySlugForRoutes;

//...

Route::group([
   'middleware' => [
      'web',
      'auth',
      SetDefaultCompanySlugForRoutes::class
   ],
   'prefix' => '/{company_slug}'
], function () {
    //...
});

https://github.com/laravel/framework/blob/7.x/src/Illuminate/Routing/UrlGenerator.php#L596

Activity icon

Replied to Handling An Incoming Webhook

@ameenmathers what errors do you get?

Activity icon

Awarded Best Reply on How To Save A Validated Model?

@moctarss update($this->validator($request)); should be update($validator->validated());

Activity icon

Replied to How To Save A Validated Model?

@moctarss update($this->validator($request)); should be update($validator->validated());

Activity icon

Awarded Best Reply on Cannot Import Component Inside Other Component

So apparently ./ is supposed to be the app root folder.

./ is the current directory. So it should be import Icon from './icon/index.vue'

Activity icon

Replied to Inserting Multiple Array Into Database In Laravel

The AllowanceUser and DeductionUser model are not been saved.

Is it not saved at all? Do you get any errors?

Why are you passing the same value to both of these?:

'allowance_id'=>$request->id,
'user_id'=>$request->id,

user_id should probably be set to $user->id?

Also, make sure that this condition is not always true: if (empty($input['deduction_name'][$i]) || !is_numeric($input['deduction_name'][$i])) continue;

Activity icon

Replied to Cannot Import Component Inside Other Component

So apparently ./ is supposed to be the app root folder.

./ is the current directory. So it should be import Icon from './icon/index.vue'

Activity icon

Replied to Pre-populate Route Parameter

@morcen something like this might work:

php artisan make:middleware SetDefaultCompanySlugForRoutes

public function handle($request, Closure $next)
{
    $route = app('router')->getCurrentRoute();

    if($route->hasParameter('company_slug')) {
        app('url')->defaults([
            'company_slug' => $route->parameter('company_slug'),
        ]);
    }
    
    return $next($request);
}
use App\Http\Middleware\SetDefaultCompanySlugForRoutes;

//...

Route::group([
   'middleware' => [
      'web',
      'auth',
      SetDefaultCompanySlugForRoutes::class
   ],
   'prefix' => '/{company_slug}'
], function () {
    //...
});

https://github.com/laravel/framework/blob/7.x/src/Illuminate/Routing/UrlGenerator.php#L596

Activity icon

Awarded Best Reply on Dependancy Injection

It works if I call it like this: (new Populator(new SeedData)) but I wanted to avoid passing in the parameter.

You should resolve the Populator from the container app(Populator::class).

Activity icon

Awarded Best Reply on Laravel 7.x Setting Default Component Attributes

public $defaultAttributes

public function __construct($class, $type, $name, $size, $blah) 
{
   $this->defaultAttributes = [
      'class' => $class,
      'type' => $type,
      'name' => $name,
      //...
   ]);
}
<select {{ $attributes->merge($defaultAttributes) }}>...</select

https://laravel.com/docs/7.x/blade#managing-attributes

Mar
27
3 days ago
Activity icon

Awarded Best Reply on How To Throw A 404 If ID In URL Doesnt Match

@oli_d111 it should be like this:

public function show($unique_id)
{
   $order = Order::where('unique_id', $unique_id)->firstOrFail();
   // etc etc
   return view....
}

What is the message of 500 error?

Activity icon

Replied to Extend A Model $fillable From A Vendor Component

@kimmer forceFill: https://github.com/illuminate/database/blob/master/Eloquent/Model.php#L364

(new Category)->forceFill([
   "icon" => "test",
   //...
])->save();
Activity icon

Replied to Laravel: The Expected [Illuminate\Auth\Notification\VerifyEmail] Notification Was Not Sent

Strange that you were able to get it to work. Was there a fix or something?

No, I've just added your test to a fresh Laravel 7 app (with auth scaffolding) and replaced register method in App\Http\Controllers\Auth\RegisterController with yours.

Activity icon

Replied to Bootstrap Modal Open With Record Details

Is this the correct aporoach?

Yes, it's totally valid approach.

Laravel Livewire framework uses the same approach: https://laravel-livewire.com