stefan7

stefan7

Member Since 2 Years Ago

Experience Points
6,700
Total
Experience

3,300 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
50
Lessons
Completed
Best Reply Awards
1
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 2
6,700 XP
Aug
28
1 month ago
Activity icon

Replied to Call To Undefined Function Illuminate\Encryption\openssl_cipher_iv_length()

I ran with Xampp into the same exception message, after changing the php.ini with a unvalid line.

May be this helps anybody.

Aug
25
1 month ago
Activity icon

Replied to Count On A Normal Get

If you have in your Softwareproduct model the relationship to softwareLicences(), you can do so

$softwareProducts = Softwareproduct::with('manufacturer')
   ->withCount('softwarelicences')
   ->orderBy('name', 'asc')
   ->get();

//now the count is in the attributes list and you can get it like
$countOfFirstProduct = $softwareProducts->first()->softwarelicences_count;

Note: the relationship name should better be camelCase, so it would be softwareLicences, then you need to do

$countOfFirstProduct = $softwareProducts->first()->software_licences_count;
Activity icon

Replied to Get Unique Values Of Eloquent Relationship

Hi @marianomoreyra,

it works, Thank you!

With very large collections it might be not the fastest, but for my purpose is it good. I compared to performance to a solution with iterating through all the branches and add unique ones to an array. The solution with the array needed 50-70% less time.

Aug
24
1 month ago
Activity icon

Replied to Command To Compare And Update

I think all you need is

       //first get all teams where helpdes_id = 1
        $teams = Team::where('helpdesk_id', '1')->get();
        
        //update stat_id
        foreach ($teams as $team) {
            if($team->stat_id === 2) {
                $team->stat_id = 3;
                $team->save();
            }
        }

and dont forget to include the Model on beginning of the file, depending on your structure, for example

use App\Model\HelpDesk\Team;

*updated with your new data

Activity icon

Replied to Get Unique Values Of Eloquent Relationship

Does not work

Property [branches] does not exist on this collection instance.

I think you can not use the branches() relationship on a collection ($products), only on a single record.

Activity icon

Replied to Translation Files In Nested Directories

I think Taylor meant that the following behaviour is not intented by the Laravel Team:

When using the dot notation with nested directories translation key is returned.

So they will not add this "feature" to the documentation because this behaviour could change with future updates.

Activity icon

Started a new Conversation Get Unique Values Of Eloquent Relationship

I have a Product and Branch model with m:n relationship. The following query gives me a collection of products, including the branches relationship. What is a good way to get a list of unique branches (used as a filter in a select list on frontend) with the following query?

  $products = Product::whereHas('categories', function($query){
                 $query->where('id', 2); 
             })
            ->with(['branches'])
            ->orderBy('created_at', 'desc')
            ->get();
May
28
4 months ago
Activity icon

Replied to Routes: Switch Different Actions Depending On The Slug Without Changing Url

The party you did not understand is shown in my code example above with the if/elseif. Depending on the $routeKey record it will choose another controller and another action.

I think I solved this party already with the following

 return App::make('App\Http\Controllers\CategoryController')->show($category->slug, request() );

also possible seems to be

$request = Request::create('c/'.$category->slug, 'GET');
return Route::dispatch($request);

I know this use case sounds in general pretty weird as you normally would make clean routes for each controller action. In this case the client requested something more flexibel for his own reason.

Activity icon

Started a new Conversation Routes: Switch Different Actions Depending On The Slug Without Changing Url

I have a fallback route, at the end of the web.php. It looks in a model for the current slug and should redirect to the correct controller action. If no slug is found, then it will proceed to show 404 error.

In this fallback route I want to have the possibility to decide which controller and which action to call. The problem is that if I call just Route::get() oder redirect->route() it will change the url. But I want to stay the url the same. Is that possible?

My current route function:

Route::get('/{any}', function ($any){
    $routeKey = \App\Models\RouteKey::where('key', $any)->first();
    if(is_null($routeKey)) {
        abort(404);
    }

    if($routeKey->routable_type == 'App\Models\Category') {
        return redirect()->route('category.show', $routeKey->routable_id);
        //return action('[email protected]', $category->slug);
    } elseif($routeKey->routable_type == 'App\Models\Product') {
        return redirect()->route('product.show', $routeKey->routable_id);
    }
});

May
11
5 months ago
Activity icon

Started a new Conversation Use Flexible Route Parameters For Filtering

I try to realise flexible route parameters. The parameters decide which filters should be active on a category page. Examples:

shoes.com/sneakers/white

shoes.com/white/42

shoes.com/female/red

I know, this is mostly done by adding query parameters (?color=red...) but in this case it should be done like the url's above.

There is no fixed structure to follow, like you would do it mostly with routes like '{categoryName}/{color?}/{size?}'

So I thought to make a model CategoryFilter that as a attribute for the complete url-path (exluding domain, exluding parameters) and to save the filters that need to be triggered in a json attribute(color:red, size:39).

To use a "any" route to catch everything and check if the url path i a category page with filters

Route::any('/', '[email protected]')->name('category.show')->middleware('checkIfCategoryPage');

Now I got stuck with the Middleware which should load in the end the category page with the filters but NOT change the url

    public function handle($request, Closure $next)
    {
        $categoryFilter = CategoryFilter::where('path', $request->path())->first();
        if($categoryFilter) {
            $request = Request::create(action('[email protected]', ['slug' =>$categoryFilter->category->slug, 'categoryFilterID' => $categoryFilter->id]), 'GET');
        }
        return $next($request);
    }

This middleware results in a 404 error. How can I solve this or do you have other solutions/best practices for me?

Apr
30
5 months ago
Activity icon

Awarded Best Reply on How Show Image In A Bootsrap Modal

I think you are looking more for a library like Fancybox or Lightbox than modals. This should do what you want:

http://fancyapps.com/fancybox/3/

Activity icon

Replied to How Show Image In A Bootsrap Modal

I think you are looking more for a library like Fancybox or Lightbox than modals. This should do what you want:

http://fancyapps.com/fancybox/3/

Apr
29
5 months ago
Activity icon

Replied to How Show Image In A Bootsrap Modal

Just put your loop for images and further content inside of the class "modal-body". Another tip, Laravel provides the $loop variable inside of a @foreach, so you do not need to do $id++; Just use $loop->index and it will give you the same number. https://laravel.com/docs/7.x/blade#the-loop-variable

<div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
   @foreach($files as $file)
       <img class="btn p-0 card-img3" src="{{$file->image}}">
   @endforeach
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>