rdelorier

rdelorier

Member Since 4 Years Ago

lawrenceville ga

PHP Developer at AgencyMatrix LLC

Experience Points 35,700
Experience Level 8

4,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 179
Lessons
Completed
Best Reply Awards 41
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

08 Mar
5 months ago

rdelorier left a reply on ImageMagic Magic Module Not Available Even When Phpinfo Shows That Imagick Is Installed

@SAYJOY - you can display the php info in the browser to see all the details

<?php
phpinfo(); die;

Try throwing that at the top of public/index.php. the problem may be that php-cli and php-fpm are using different ini files, if thats the case then just edit the ini files you see in the output from the above suggestion and enable the module there.

rdelorier left a reply on ImageMagic Magic Module Not Available Even When Phpinfo Shows That Imagick Is Installed

If it's installed already you may just need to restart php-fpm.

06 Mar
5 months ago

rdelorier left a reply on GuzzleHttp Undefined Offset: 1

Guzzle will encode the auth for you use 'auth' => ['user', 'pass']

rdelorier left a reply on Get Users Subjects With Lessons Scoped To User

You can eager load the nested relationship with User::with(['subjects.lessons']) and you should have all the data available.

05 Mar
5 months ago

rdelorier left a reply on Counting From Relationships

I don't see how it possibly could, it's doing the exact same thing. Maybe your thinking of raw inserts or updates but I don't see any way this could have security implications.

rdelorier left a reply on Getting Data From Eloquent Relationships

You can just call paginate instead of get to paginate it.

You can also use the hasManyThrough relation from the user to do Auth::user()->importantNews

Class User
{
    public function importantNews()
    {
        return $this->hasManyThrough('App\News', 'App\important', 'user_id', 'news_id');
    }
}

rdelorier left a reply on Counting From Relationships

I think something like this should get you the results

BadRunSheet::query()
    ->leftJoin('employees', 'employees.user_id', '=', 'badrunsheets.employee')
    ->where('badrunsheets.status', 5)
    ->groupBy('employees.primary_station')
    ->selectRaw('
        count(*) as count,
        employees.primary_station as primary_station
    ')->get();

Of course if you need something off the stations table then just add a join and the columns you want to select.

edit: it doesn't really make a lot of sense to use the model if your not selecting all the columns tho so maybe use:

DB::table('badrunsheets')
    ->leftJoin('employees', 'employees.user_id', '=', 'badrunsheets.employee')
    ->where('badrunsheets.status', 5)
    ->groupBy('employees.primary_station')
    ->selectRaw('
        count(*) as count,
        employees.primary_station as primary_station
    ')->get();

rdelorier left a reply on Selecting Model On Join With Count

Your definitely right in wanting to refactor this, the first way is not efficient at all

rdelorier left a reply on Selecting Model On Join With Count

You can make it a join instead of left join and just remove the where pending clause

rdelorier left a reply on Selecting Model On Join With Count

Is there a pending column on the notifications table?

rdelorier left a reply on Laravel:Symfony\Component\Debug\Exception\FatalErrorException

The actual error is this Argument 3 passed to Nba\P0\Components\GlobalNavigation\Data\Navigation\Entity::__construct() must be an instance of Illuminate\Translation\Translator, null given

rdelorier left a reply on Polymorphism - Creating The Parent At The Same Time As The Child

You can call create in the relation $input_field->field()->create(...)

rdelorier left a reply on "Session Store Not Set On Request." Error When Run Artisan Command

There is no session when running artisan command since its started by the "StartSession" HTTP middleware which doesn't run for console requests. If your just looking for a quick fix you can just request()->setLaravelSession(session()) and probably get it working :)

01 Mar
5 months ago

rdelorier left a reply on How To Insert Records In Two Tables From Single Form

Here is a very contrived example

<form action="/" method="POST">
    @csrf
    <div>
        <input type="text" name="category[c_name]">
        <input type="text" name="category[c_desc]">
    </div>
    <div>
        <input type="text" name="sub_category[0][sc_name]">
        <input type="text" name="sub_category[0][sc_desc]">
    </div>
    <div>
        <input type="text" name="sub_category[1][sc_name]">
        <input type="text" name="sub_category[1][sc_desc]">
    </div>
    <div>
        <input type="text" name="sub_category[2][sc_name]">
        <input type="text" name="sub_category[2][sc_desc]">
    </div>

    <button type="submit">Submit</button>
</form>
Route::post('/', function (Illuminate\Http\Request $request) {
    $data = $request->validate([
        'category.c_name' => 'required|string',
        'category.c_desc' => 'required|string',
        'sub_category.*.sc_name' => 'required|string',
        'sub_category.*.sc_desc' => 'required|string',
    ]);

    $category = App\Category::create($data['category']);
    $category->subCategories()->createMany($data['sub_category']);
});

rdelorier left a reply on Why Laravel Calls My Model In Plural Instead Of Singular?

Did you also capitalize it in the route config?

If that doesn't work then can you paste in the stack trace?

rdelorier left a reply on RuntimeException: No Application Encryption Key Has Been Specified 5.8

@KENNYBJR87 - I was able to get global phpunit working by upgrading laravel/valet globally

rdelorier left a reply on Why Laravel Calls My Model In Plural Instead Of Singular?

If you rename your controller to start with a capital letter ( both classname and filename ) it should work. Of course since you are on Windows you may have a little trouble there since it's not case sensitive and you may have to delete the file and recreate it with the correct casing.

rdelorier left a reply on RuntimeException: No Application Encryption Key Has Been Specified 5.8

Kinda interesting, I can reproduce this is I use the globally installed version of phpunit but it works fine using the local version

global producing error

/tmp/test$ phpunit
PHPUnit 7.5.6 by Sebastian Bergmann and contributors.

.E                                                                  2 / 2 (100%)

Time: 169 ms, Memory: 18.00 MB

There was 1 error:

1) Tests\Feature\ExampleTest::testBasicTest
RuntimeException: No application encryption key has been specified.

/private/tmp/test/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:44
/Users/rdelorier/.composer/vendor/illuminate/support/helpers.php:1027
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:48
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:24
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Container/Container.php:791
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Container/Container.php:671
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Container/Container.php:619
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:757
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Container/Container.php:929
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Container/Container.php:857
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Container/Container.php:822
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Container/Container.php:671
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Container/Container.php:619
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:757
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:215
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:189
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:354
/private/tmp/test/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:170
/private/tmp/test/tests/Feature/ExampleTest.php:17
/Users/rdelorier/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:208
/Users/rdelorier/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:164

ERRORS!
Tests: 2, Assertions: 1, Errors: 1.

But local version is fine:

/tmp/test$ ./vendor/bin/phpunit
PHPUnit 7.5.6 by Sebastian Bergmann and contributors.

..                                                                  2 / 2 (100%)

Time: 154 ms, Memory: 16.00 MB

OK (2 tests, 2 assertions)

rdelorier left a reply on How To Retrive Multiple Records From One Table And Insert Into Another Table?

@ABDULBAZITH - The exact code would be something like this

$date = now()->format('Y-m-d');

DB::statement("insert into attendance_table (employee_id, date, count) select id, '{$date}', 1 from employees")

I'm not sure if date and count are the correct field names since it's not clear in the post/replies so just change those accordingly.

This would never perform more than 1 query even if you had a million employees, of course it might take a while if you had a million lol.

rdelorier left a reply on Why Laravel Calls My Model In Plural Instead Of Singular?

The Controller suffix is the convention but it completely optional and wouldn't cause an error. But studly case classnames is part of the psr-4 standard and would cause an issue since App by default is rooted in app via composer.json autoload configuration

rdelorier left a reply on Why Laravel Calls My Model In Plural Instead Of Singular?

Is your route service provided modified? I would expect this to look for "app/Http/Controllers/usarios.php" unless you removed the controller namespace in the service provider.

Then again maybe composer sees the lowercase first letter and check psr-0 instead.

rdelorier left a reply on Why Laravel Calls My Model In Plural Instead Of Singular?

Can you show a little more of the stack trace?

Your controller is not following psr standards because the class is not studly cased. This could be what's causing the issue.

28 Feb
5 months ago

rdelorier left a reply on Global Scope On Model Breaks My Laravel Scout:import Command

Maybe you could check if running in console in the trait and don't apply the clause, something like

if (app()->runningInConsole()) {
    return;
}

...

rdelorier left a reply on Mysql Not Restarting

There is usually an error log for mariadb in /var/lib/mysql, probably a file ending in .err

rdelorier left a reply on Database Error

Do you have env variables set on the server that may be overriding the .env file?

in your terminal do you get anything when you run env | grep DB

rdelorier left a reply on Convert Array (key, Value) To Flat Array

careful with those leading % since mysql cannot use an index when you do that so this will perform 3 table scans.

rdelorier left a reply on Vue Handling Relation In Response

you could use v-if on the element

<span v-if="contact.primary_contact">{{ contact.primary_contact.name }}</span>

rdelorier left a reply on Form Doesn't Get Values

Fields need a name attribute to be sent in the request

rdelorier left a reply on How To Retrive Multiple Records From One Table And Insert Into Another Table?

You can do this with a single query pretty easily

DB::statement("insert into attendance_table (employee_id, present) select id, 1 from employees")

Edit: I realize I used different column names but you get the idea ?

rdelorier left a reply on Call To A Member Function Connection() On Null

Also you can replace return Setting::where('name',$setting)->first()->val; with return Setting::where('name',$setting)->value('val');

rdelorier left a reply on Call To A Member Function Connection() On Null

You won't be able to use a database connection in you config/* files because the DatabaseServiceProvider has not been registered yet so when it tries to query the settings table there is no way to connect to the database.

You could update the config option in the boot method of AppServiceProvider tho.

17 Mar
2 years ago

rdelorier left a reply on How Disable .env File

@bashy good point, I've been using .env so long I forgot some‚Äč people just set the vars in PHP.ini :/

rdelorier left a reply on Illegal String Offset 'name'.how To Solve This Error Can Anyone Please Tell Me

Once you get your data from the Excel file you can validate it using array validation to make sure all the rows have the necessary keys.

rdelorier left a reply on How Disable .env File

I'd suggest just adding the additional connection variables to .env so your not committing your passwords to source control.

31 Jan
2 years ago

rdelorier left a reply on It Just.... Doesn't Work (valet)

I had the exact same issue, something to do with permission. If you search the repo you will find some answers.

29 Jan
2 years ago

rdelorier left a reply on Getting "Unauthenticated" Response

In your dev tools network requests does your Ajax call send the cookie in the request

rdelorier left a reply on Auth::id(); Returning Null In Controller (in Api)

You will just need to specify the API guard on the route as auth:api instead of just auth. The default guard is usually web which uses sessions so switching it to API will use passport assuming you've setup your guards correctly.

11 Dec
2 years ago

rdelorier left a reply on Disable Updated_at On Single Save

Try setting timestamps to false on the model before saving

06 Dec
2 years ago

rdelorier left a reply on How To Get The Records Of The Table Downloadable And Exported In Xls Or Csv Format?

You just need to set the correct headers to tell the browser how to handle the response, you can save yourself a lot of work with the package http://csv.thephpleague.com/examples/ or just copy hoe it creates the response.

rdelorier left a reply on Half JS Half PHP 100% Laravel Issue....

Do you get the same response if you include the accept header as application/json so laravel wont redirect if an error occurs?

30 Nov
2 years ago

rdelorier left a reply on Vue.js 2.0 And Problem Using Single File Components Inside Other

That looks correct, the only difference in your example and how I do it is the file extension on the import, try importing without the '.vue' extension

26 Nov
2 years ago

rdelorier left a reply on How To Trigger Vue Event When Selecting An Option From Select List

You should use the change event on the select

rdelorier left a reply on How To Insert Into Collection In A More Functional Way?

You can pass in the function name as a string to map ->map('trim')

25 Nov
2 years ago

rdelorier left a reply on Vue.js 2.0 : Data Gotten From Backend Via Ajax Can Not Be Shown In View

Here is an example of when you might want to use $nextTick

  <div id="app">
    <button v-on:click="makeListVisible">Show List</button>
    <ul v-if="showList" ref="myList">
      <li>Stuff</li>
    </ul>
  </div>

  <script type="text/javascript">
    new Vue({
      el: '#app',
      data: {
        showList: false
      },
      methods: {
        makeListVisible: function () {
          this.showList = true;

          // This will wait for the dom to update so that 
          // the ul is available when the code within runs
          this.$nextTick(function () {
             // this would error outside of nextTick since the v-if prevents myList from rendering
            this.$refs.myList.style.backgroundColor = 'red';
          });
        }
      }
    })
  </script>

rdelorier left a reply on Vue.js 2.0 : Data Gotten From Backend Via Ajax Can Not Be Shown In View

@sunrise try making a reference to the vm before entering the function context.

...
mounted: function () {
  var $vm = this;
  //ajax stuff
  $vm.todos = data
}

there is no reason use nextTick unless you need to wait for some dom change to take effect before continuing.

rdelorier left a reply on Vue.js 2.0 : Data Gotten From Backend Via Ajax Can Not Be Shown In View

You may not have the vm as your 'this' context when setting this.todos if your using es6 then try this syntax


    <div class="container" id="app">
        <ol>
            <li v-for="(todo,index) in todos">
                {{ index }} {{ todo.text }}
            </li>
        </ol>
    
    </div>
    
    <script>
        new Vue({
            el: '#app',
            data: {
                todos: []
            },
            mounted: function () {
                axios.get('/articles')
                    .then(response => {
                        console.log(response);
                        this.todos = response.data;
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            }
        });
    </script>

rdelorier left a reply on Get The Route URI With Parameters "{id}" String?

try Route::current()->getUri()