Refringe

Refringe

Member Since 3 Years Ago

Experience Points 9,470
Experience
Level
Lessons Completed 111
Lessons
Completed
Best Reply Awards 1
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

21 Aug
2 years ago

Refringe left a reply on Seeding Multiple Foreign Key Records Using Model Factories

Is there a way to go one step deeper and create (say 10) of App\Player for each of the two teams that are created per user?

Refringe left a reply on Seeding Multiple Foreign Key Records Using Model Factories

That's exactly what I was looking for. Thank you!

Refringe started a new conversation Seed, Factories, Foreign Keys, Oh My.

Alright, so I have a User and Team model factory and I'm using a seeder to populate the database. However, I'm trying to ensure that each user that I add has two teams.

This works, but because I'm repeating a line entirely, it feels... dirty?

factory(App\User::class, 30)->create()->each(function ($user) {
    $user->teams()->save(factory(App\Team::class)->make());
    $user->teams()->save(factory(App\Team::class)->make());
});

Is there a more efficient way to do this? It's not a huge deal now, but I'm going to be using this same method to add 20+ child records to a parent with other models and I want to be sure I'm doing it right.

13 Jun
2 years ago

Refringe left a reply on Laravel CI Testing With GitLab

@Fuxy22 It checks to see if Docker exists. If it doesn't then the script halts. @bashy pointed to an issue that explains that this method stops working with newer versions of Docker. This should work with the new version:

[[ ! -e /.dockerinit ]] && [[ ! -e  /.dockerenv ]] && exit 0

However, I have yet to test it.

29 Apr
2 years ago
28 Apr
2 years ago

Refringe left a reply on Multiple Domains For Languages

Or would you set each of the domains to load their own copy of the code, but connect to the same database? Is there any downside to that, other than having to manage making releases to two directories at the same time? Am I missing something?

23 Apr
2 years ago

Refringe left a reply on Multiple Domains For Languages

Using the . env file had crossed my mind but I didn't know how I would load different versions of the file (one per language/domain) while at the same time pointing the domains to the same app folder. Is there a technique for doing that?

Refringe left a reply on Giving Routes Of Different Kinds With Same URL The Same Name?

If the routes have the same URL there's no point in naming all of them. Just name the GET request and use that route name to generate URLs for all of your other request types with the same route structure. This removes a little bit of unnecessary repetition.

I'm not even sure the delete or post route names would even be picked up in your example because they share the same name. You're not passing the request type to the route function (I don't think you can) so it wouldn't know which one to return. You can test this by simply changing the routes so they're different, but still sharing the same name:

Route::get('show/{id}', 'PostController@show')->name('post');
Route::delete('delete/{id}', 'PostController@delete')->name('post');
Route::post('save/{id}', 'PostController@save')->name('post');

I would expect route('post', $post->id) to return /show/{id}.

If your routes are different URLs then I would recommend giving them a different (descriptive) name per type:

Route::get('view/{id}', 'PostController@show')->name('post.show');
Route::delete('view/delete/{id}', 'PostController@delete')->name('post.delete');
Route::post('view/save/{id}', 'PostController@save')->name('post.save');
22 Apr
2 years ago

Refringe started a new conversation Multiple Domains For Languages

So let's say I have two domains; hello.com and bonjour.com. I need these two domains share the same codebase. The only difference, other than the domains, are the localization language; one is en and the other fr. What would be the best way to dynamically set the URL and locale in the Laravel settings?

03 Mar
2 years ago

Refringe left a reply on Laravel CI Testing With GitLab

Alright, I wanted to work with the official PHP docker builds, so here's what I ended up doing. It tests using PHP v5.5, v5.6, and v7 with MySQL v5.6 and v5.7; six tests in total. A test takes about 6-7 minutes on average to compile before running. Thanks for the help!

.gitlab-ci.yml:

before_script:
  - bash .gitlab-ci.sh

variables:
  MYSQL_DATABASE: project_name
  MYSQL_ROOT_PASSWORD: secret

phpunit:php5.5:mysql5.6:
  image: php:5.5
  services:
    - mysql:5.6
  script:
    - php vendor/bin/phpunit --colors

phpunit:php5.6:mysql5.6:
  image: php:5.6
  services:
    - mysql:5.6
  script:
    - php vendor/bin/phpunit --colors

phpunit:php7.0:mysql5.6:
  image: php:7.0
  services:
    - mysql:5.6
  script:
    - php vendor/bin/phpunit --colors

phpunit:php5.5:mysql5.7:
  image: php:5.5
  services:
    - mysql:5.7
  script:
    - php vendor/bin/phpunit --colors

phpunit:php5.6:mysql5.7:
  image: php:5.6
  services:
    - mysql:5.7
  script:
    - php vendor/bin/phpunit --colors

phpunit:php7.0:mysql5.7:
  image: php:7.0
  services:
    - mysql:5.7
  script:
    - php vendor/bin/phpunit --colors

.gitlab-ci.sh:

#!/bin/bash

# Install dependencies only for Docker.
[[ ! -e /.dockerinit ]] && exit 0
set -xe

# Update packages and install composer and PHP dependencies.
apt-get update -yqq
apt-get install git libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -yqq

# Compile PHP, include these extensions.
docker-php-ext-install mbstring mcrypt pdo_mysql curl json intl gd xml zip bz2 opcache

# Install Composer and project dependencies.
curl -sS https://getcomposer.org/installer | php
php composer.phar install

# Copy over testing configuration.
cp .env.testing .env

# Generate an application key. Re-cache.
php artisan key:generate
php artisan config:cache

# Run database migrations.
php artisan migrate

.env.testing:

APP_ENV=testing
APP_DEBUG=true
APP_KEY=key

DB_HOST=mysql
DB_DATABASE=project_name
DB_USERNAME=root
DB_PASSWORD=secret

CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync
MAIL_DRIVER=log
01 Mar
2 years ago

Refringe left a reply on Laravel CI Testing With GitLab

Hey @noeldiaz, thanks for the reply. Are you sure that's all that's needed for basic unit testing? It's failing for me on the composer install line.

$ composer install --prefer-dist > /dev/null
bash: line 23: composer: command not found

ERROR: Build failed with: exit code 1

Also, will a simple set-up like that get functional testing to work? eg:

$this->visit('/login')->see('Login');

Refringe started a new conversation Laravel CI Testing With GitLab

I'd love to set Laravel up on GitLab with CI, however I can not find any tutorials on how to configure the .gitlab-ci.yml file for a basic Laravel installation. Does anyone have any experience with this? Currently I'm just on gitlab.com using their shared runners.

21 Feb
2 years ago

Refringe left a reply on .env.example And Github Repo

@xtremer360: Sure, no problem there. But again, why? You're never going to have an absolutely perfect repo where anyone can checkout any commit in your history and expect fully functional code. It's just history, focus on the now. :D

Refringe left a reply on .env.example And Github Repo

@xtremer360: I'm sure there's a way to do that, but why? Do you expect yourself or others to specifically checkout the commits between when you deleted it and your current commit? Have you tagged commits in that time period? Made releases? If not, there's no reason to rewrite any history. Simply add it back in a new commit and merge it into all of your working branches. Good to go. =)

Refringe left a reply on .env.example And Github Repo

@xtremer360: So to be clear, you want to go back in your repo's history and rewrite it so a file was never deleted?

Refringe left a reply on .env.example And Github Repo

Here's how to search for and completely remove sensitive information (like your .env file) from your repo: https://help.github.com/articles/remove-sensitive-data/

I've used the BFG Repo-Cleaner that's mentioned at the bottom of the article. It works like magic.