Sti3bas

Member Since 2 Years Ago

Experience Points
361,810
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
1254
Lessons
Completed
Best Reply Awards
400
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
361,810 XP
Sep
13
2 weeks ago
Aug
02
1 month ago
Activity icon

Awarded Best Reply on Str::ordereduuid() Returns Error

doing composer require moontoast/math will fix the issue.

https://github.com/laravel/framework/issues/23291#issuecomment-573825311

Jun
12
3 months ago
Activity icon

Awarded Best Reply on Want To Update My Sever Database?

@me10071990 you can login to your server through SSH and then execute your PHP code in the Tinker (php artisan tinker). Something like:

Category::create([
   'title' => 'Test',
   //...
]);
Jun
01
3 months ago
Activity icon

Awarded Best Reply on Laravel Secure Bin Files Download With Limitations

P.S. In the future I would like to assign how much a user can download files per day.

This can be done by extending the original middleware:

app/Http/Middleware/ThrottleDownloads.php:

namespace App\Http\Middleware;

use Closure;
use Illuminate\Routing\Middleware\ThrottleRequests;

class ThrottleDownloads extends ThrottleRequests
{
    public function handle($request, Closure $next)
    {
        return parent::handle($request, $next, $request->user()->max_downloads, 1440);
    }
}

app/Http/Kernel.php:

protected $routeMiddleware = [
   //...
    'throttle-downloads' => \App\Http\Middleware\ThrottleDownloads::class,
];

routes/web.php:

Route::get('test-route/{id}', '[email protected]')->middleware(['auth', 'throttle-downloads']);
May
03
4 months ago
Activity icon

Awarded Best Reply on Manually Calling Passing Data To A Form Validator In A Controller

@drewdan this should work, if I understood you correctly:

public function autoTranslate(Request, $request, Interaction $interaction): Response {
    $request->merge(['language_code' => $interaction->languageCode]);

    return $this->translate($interaction, app(InteractionTranslateRequest::class));
}
Apr
26
5 months ago
Activity icon

Awarded Best Reply on For Chat Application Or Real Time Application Which Way Is Better?? Laravel Echo Server Or Socket.io

@kaushal Laravel Echo Server is just a wrapper for socket.io which is built with Node.js. If you want to keep your server setup simple and fully rely on PHP, you should check Laravel Websockets package: https://docs.beyondco.de/laravel-websockets/

Here is the article which covers some differences and includes link to benchmarks: https://ohdear.app/blog/transitioning-from-laravel-echo-server-to-laravel-websockets

Apr
22
5 months ago
Activity icon

Awarded Best Reply on WithoutSyncingToSearch() - Algolia - Laravel Media Library Thumbnail Image Indexing Issue

Is the toSearchableArray() something that should be put to a queue to delay the function?

Are you using queue for your media conversions? If so, it will return null when creating new record because image is not processed yet.

You can add an event listener for Spatie\MediaLibrary\Events\ConversionHasBeenCompleted to update search record with $event->media->model()->searchable(); after conversation has been completed.

I found it hard to track all these automatic syncs when I was working on one of my projects. Some of my controller actions was triggering multiple syncs with the same data, which is bad because Algolia charges you for the records and operations. I ended up managing syncing manually and also wrote a package which helped me to write tests which ensures that syncing is only triggered once with the correct data. You can find it here, if you're interested: https://laravel-news.com/laravel-scout-array-driver-for-testing

Apr
16
5 months ago
Activity icon

Awarded Best Reply on Validation Rules For Field Allowable Null And String

@xtremer360 yeah, it might be useful to use this package if you need to re-use this combination of rules many times. The other option might be to use FormRequest + inheritance, check this thread for more details: https://laracasts.com/discuss/channels/code-review/using-validation-rule-objects

Activity icon

Awarded Best Reply on Get User Of Submitted Job In Queue

@bvanhaastrecht yeah, that's not that easy, try this:

public function boot() {
   Queue::after(function (JobProcessed $event) {
      dump(unserialize($event->job->payload()['data']['command'])->user);
   });
}
Apr
03
5 months ago
Activity icon

Awarded Best Reply on 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.

Mar
31
5 months 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
5 months 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
5 months 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