Slamm

Slamm

Member Since 3 Years Ago

Experience Points
500
Total
Experience

4,500 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
0
Lessons
Completed
Best Reply Awards
0
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 1
500 XP
May
28
3 days ago
Activity icon

Replied to App()->getLocale() Is Always Default Locale

Holy Guacamole, why does this work now? I did that also before and it did not work but now it does... strange ..

Okay, before session('locale') returned null...

Many thanks

Activity icon

Replied to App()->getLocale() Is Always Default Locale

It should, see code below...

Kernel:

    protected $middleware = [
        TrustProxies::class,
        HandleCors::class,
        CheckForMaintenanceMode::class,
        ValidatePostSize::class,
        TrimStrings::class,
        ConvertEmptyStringsToNull::class,
        LanguageMiddleware::class,
    ];

Middleware:

    public function handle($request, Closure $next)
    {
        $n = $next($request);

        if (Session::has('locale')) {
            App::setLocale(Session::get('locale'));
        }

        return $n;
    }

furthermore: session('locale') returns currently de config('app.locale') returns en app()->getLocale() returnds en

As I said, that's exactly the same as I did in 5.4 and 5.5 and it worked like a charm.

Many thanks and kind regards

Activity icon

Replied to App()->getLocale() Is Always Default Locale

Thank you very much for your quick answer.

I did exactly that before... but it's not working.

As I wrote, the middleware gets called - the value is correct inside the middleware but as soon as I leave the middleware app()->getLocale() is overwritten by the default value from config/app.php.

Activity icon

Started a new Conversation App()->getLocale() Is Always Default Locale

Hi,

I've been using a LanguageMiddleware to set my locale app()->setLocale() based on the content of Session::get('locale').

Session::get('locale')or session('locale') always returns the corrent language code. en, fr, pl, etc. pp. In my Middleware, the app()->getLocale() also returns the correct value.

However, as soon as I leave the middleware and try to get the value of app()->getLocale() (e.g. in a blade template), I always end up printing en even though another value should have been set. printing app()->getLocale() and session('locale') in a blade template shows, that the session value is the correct value (de) while the app returns en.

Does anybody know how I could set the correct locale value? I do know by chance, that this could have been used in 5.4 and 5.5 however, I never tested this in 6.x.

Many thanks and kind regards

Activity icon

Replied to Artisan Make:controller With Parent Option Not Working (Laravel 7.0)

Thank you very much for clearing my misunderstanding.

May
23
1 week ago
Activity icon

Started a new Conversation Artisan Make:controller With Parent Option Not Working (Laravel 7.0)

Hi all,

I've just asked myself if it is possible to create a Controller using artisan make:controller and directly say which Controller to extend. e.g. ParentController which itself extends Controller.

Using artisan make:controller --help displayed the option: --parent[=PARENT] "Generate a nested resource controller class".

I thought: awesome! that's what I've wanted - at least that's what I thought.

When using the parent option, I get the following Output: A App\ParentController model does not exist. Do you want to generate it? (yes/no).

Saying no will create a controller with the following content:

<?php

namespace App\Http\Controllers;

use App\ParentController;
use Illuminate\Http\Request;
use {{ namespacedModel }};

class TestController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @param  \App\ParentController  $ParentController
     * @return \Illuminate\Http\Response
     */
    public function index(ParentController $ParentController)
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @param  \App\ParentController  $ParentController
     * @return \Illuminate\Http\Response
     */
    public function create(ParentController $ParentController)
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\ParentController  $ParentController
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request, ParentController $ParentController)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\ParentController  $ParentController
     * @param  \{{ namespacedModel }}  ${{ modelVariable }}
     * @return \Illuminate\Http\Response
     */
    public function show(ParentController $ParentController, {{ model }} ${{ modelVariable }})
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\ParentController  $ParentController
     * @param  \{{ namespacedModel }}  ${{ modelVariable }}
     * @return \Illuminate\Http\Response
     */
    public function edit(ParentController $ParentController, {{ model }} ${{ modelVariable }})
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\ParentController  $ParentController
     * @param  \{{ namespacedModel }}  ${{ modelVariable }}
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, ParentController $ParentController, {{ model }} ${{ modelVariable }})
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\ParentController  $ParentController
     * @param  \{{ namespacedModel }}  ${{ modelVariable }}
     * @return \Illuminate\Http\Response
     */
    public function destroy(ParentController $ParentController, {{ model }} ${{ modelVariable }})
    {
        //
    }
}

Look broken to me. Now my question(s):

  1. Did I got this option wrong? In my understanding the --modeloption would have this behaviour.
  2. If my understanding is correct: Does anybody else have this issue? It affects Laravel 7.0.

Many thanks and kind regards

Apr
21
1 month ago
Activity icon

Started a new Conversation Tagging In Laravel 6

Hi all,

I'm trying to resolve the following issue.

Inside my AppServiceProvider:

$this->app->bind('servicea', function() { return new ServiceA(); });
$this->app->bind('serviceb', function() { return new ServiceB(); });
$this->app->tag(['servicea','serviceb'],'services');

$this->app->bind('foo', function(Application $app) {
   return new Foo($app->tagged('services'));
});

According to my understanding, I should get an array of instances of my services. However, simply debugging revealed that I only get Strings containing the Classname but not an instance. How can I retrieve the instances I've just created?

Many thanks and sorry if this question seems stupid. I'm trying to improve :)

Kind regards, Patrick

ps. accessing the services using app('servicea')works like a charm...