rezafm

rezafm

Member Since 2 Months Ago

Experience Points
90
Total
Experience

4,910 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
90 XP
Aug
12
1 month ago
Activity icon

Replied to Dusk: Very Weird Behavior Between Running Locally And In Homestead

In case anybody ever stumbles across this topic... I finally wrapped the whole code

        if (Schema::hasTable('posts')) {
            Post::all()
                ->each(function (Post $post) use ($locale) {
                    Route::get($post->slug, '[email protected]')
                        ->name($$post->slug)
                        ->defaults('slug', $post);
            });
        }

into a try and catch statement that checks if a database connection can be established.

It then fails for the mysql connection (on a local none homestead environment) but then works for the sqlite connections.

Aug
09
1 month ago
Activity icon

Replied to Dusk: Very Weird Behavior Between Running Locally And In Homestead

Well, as it turns out... in homestead first mysql is used... and due to migrations it has the Schema 'posts' - also the database is available as it runs inside homstead.

From what I understood so far is that the application kind of bootstraped with the standard .env file before it seems to run in the actual dusk .env file.

Anyways...I'd be quite interested in any ideas how to set this up properly.

What could work is to simply use a different .env.dusk.testing file and run dusk by --env=testing. In this file you set the env variable to "testing" and if we are in testing, we do not register these routes.

Activity icon

Started a new Conversation Dusk: Very Weird Behavior Between Running Locally And In Homestead

Okay, so I came across this very weird behavior. I run my computer on an ubuntu 18.04 client and I hope I can to a certain extent set permissions correctly. Also, I run Laravel in Homestead.

Here is my .env.dusk.local file:

APP_NAME=Laravel
APP_ENV=local
APP_KEY=mykey
APP_DEBUG=true
APP_URL=https://laravel.test
APP_LANG=en

DB_CONNECTION=testing_browser

and the respective DB_CONNECTION:

          'driver' => 'sqlite',
          'url' => env('DATABASE_URL'),
          'database' => database_path('testing_browser.sqlite'),
          'prefix' => '',
          'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
      ],

Okay so that's all good. If I run in homestead it's works great. If I run the same thing locally I just have to make sure to put...

APP_DEBUG=true
APP_URL=https://laravel.test:44300

..and then I can run it locally on ubuntu which I somestimes do if I cannot get a test to pass (I use quite a bit VUE js and sometimes the browser is quicker than I want so I can only find the error by seeing what's going on).

Okay now I ll come to the unexpeted behavior.

For SEO reasons I had to do the following in my web.php

        if (Schema::hasTable('posts')) {
            Post::all()
                ->each(function (Post $post) use ($locale) {
                    Route::get($post->slug, '[email protected]')
                        ->name($$post->slug)
                        ->defaults('slug', $post);
            });
        }

If I run my tests with this code in Homestead, everything works as expected.

Once I had to switch back to the local version and when I then tried to run my tests it immediately stopped with the following message:

  Illuminate\Database\QueryException  : SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = blog and table_name = posts and table_type = 'BASE TABLE')

  at /home/r/www/blog/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
    665|         // If an exception occurs when attempting to run a query, we'll format the error
    666|         // message to include the bindings with SQL, which will make this exception a
    667|         // lot more helpful to the developer instead of just the database's errors.
    668|         catch (Exception $e) {
  > 669|             throw new QueryException(
    670|                 $query, $this->prepareBindings($bindings), $e
    671|             );
    672|         }
    673| 

  Exception trace:

  1   Illuminate\Foundation\Application::Illuminate\Foundation\{closure}()
      [internal]:0

  2   Doctrine\DBAL\Driver\PDOException::("SQLSTATE[HY000] [2002] Connection refused")
      /home/r/www/blog/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31

  Please use the argument -v to see more details.

If I know uncomment that mentioned block:

       /* if (Schema::hasTable('posts')) {
            Post::all()
                ->each(function (Post $post) use ($locale) {
                    Route::get($post->slug, '[email protected]')
                        ->name($$post->slug)
                        ->defaults('slug', $post);
            });
        }*/

and run it locally again, just to be sure that's how the env.dusk.local file would look like then:

APP_NAME=Laravel
APP_ENV=local
APP_KEY=mykey
APP_DEBUG=true
APP_URL=https://laravel.test:44300
APP_LANG=en

it works again and I can run all my tests.

I tried several permission changes...I deleted the sqlite file completely and put it back, but it didn't help. The only way to get the tests running again locally is to uncomment these mentioned posts routes.

So, what's going on here? Can anyone explain what's happening here?

Activity icon

Replied to Can I Overwrite Laravel's "route" Function?

If any one comes to this thread from google. I believe that the initial mentioned solution here does not work without overwriting the route function.

Jul
01
2 months ago
Activity icon

Replied to Can I Overwrite Laravel's "route" Function?

Hello, I know that this is an old post, but I am actually trying to implement the same. I have on gTLD (domain.com) and I want to have a default url for English users, so I have no prefix here... and then I want to have the same for prefix routes '/de', '/fr' et cetera ....

I tried your implementation but I cannot get it working. Did you maintain your initial routes structure? Where Did you exactly place the middleware? No matter how I coded it, I never really came to a point that I could use route() as you mentioned.

It would be awesome if someone could help me. Thank You.