ixudra

Member Since 5 Years Ago

Kortessem

Developer at Ixudra

Experience Points 15,025
Experience Level 4

4,975 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 140
Lessons
Completed
Best Reply Awards 2
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.

24 Jun
3 weeks ago

ixudra left a reply on Linux File Permissions

@bobbybouwmann Been quiet around this issue for a while but I've been running into this again and again, lately. Tried resolving it with sudo chown -R www-data /var/www/app but I get an error for every file: chown: operation not permitted. I even logged in as super user but that didn't make any difference. Any suggestions?

Btw, I use a puphpet vagrant box, if that helps...

07 Jun
1 month ago

ixudra left a reply on Mockery: Cannot Redeclare Method

@secmuhammed I don't remember specifically what the problem was, it's been too long. But if recall correctly, it was something to do with the versions of Laravel, Codeception and Mockery. I'd recommend to update everything to the most recent version, see if that fixes things.

Good luck

13 Apr
3 months ago

ixudra started a new conversation Mockery: Cannot Redeclare Method

Updated my composer file and suddenly all my tests fail:

- AccountControllerTest: IndexPHP Fatal error:  Cannot redeclare Mockery_0_Illuminate_Auth_Access_Gate::allows() in /var/www/project/htdocs/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php(34) : eval()'d code on line 1003
PHP Stack trace:
PHP   1. {main}() /var/www/project/htdocs/vendor/codeception/codeception/codecept:0
PHP   2. Codeception\Application->run() /var/www/project/htdocs/vendor/codeception/codeception/codecept:43
PHP   3. Codeception\Application->run() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/Application.php:108
PHP   4. Codeception\Application->doRun() /var/www/project/htdocs/vendor/symfony/console/Application.php:145
PHP   5. Codeception\Application->doRunCommand() /var/www/project/htdocs/vendor/symfony/console/Application.php:269
PHP   6. Codeception\Command\Run->run() /var/www/project/htdocs/vendor/symfony/console/Application.php:908
PHP   7. Codeception\Command\Run->execute() /var/www/project/htdocs/vendor/symfony/console/Command/Command.php:255
PHP   8. Codeception\Command\Run->runSuites() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/Command/Run.php:390
PHP   9. Codeception\Codecept->run() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/Command/Run.php:495
PHP  10. Codeception\Codecept->runSuite() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/Codecept.php:159
PHP  11. Codeception\SuiteManager->run() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/Codecept.php:192
PHP  12. Codeception\PHPUnit\Runner->doEnhancedRun() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/SuiteManager.php:158
PHP  13. Codeception\Suite->run() /var/www/project/htdocs/vendor/codeception/phpunit-wrapper/src/Runner.php:118
PHP  14. AccountControllerTest->run() /var/www/project/htdocs/vendor/phpunit/phpunit/src/Framework/TestSuite.php:746
PHP  15. PHPUnit\Framework\TestResult->run() /var/www/project/htdocs/vendor/phpunit/phpunit/src/Framework/TestCase.php:796
PHP  16. AccountControllerTest->runBare() /var/www/project/htdocs/vendor/phpunit/phpunit/src/Framework/TestResult.php:687
PHP  17. AccountControllerTest->setUp() /var/www/project/htdocs/vendor/phpunit/phpunit/src/Framework/TestCase.php:838
PHP  18. Illuminate\Support\Facades\Facade::shouldReceive() /var/www/project/htdocs/tests/unit/base/BaseUnitTestCase.php:16
PHP  19. Illuminate\Support\Facades\Facade::createFreshMockInstance() /var/www/project/htdocs/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:66
PHP  20. Illuminate\Support\Facades\Facade::createMock() /var/www/project/htdocs/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:78
PHP  21. Mockery::mock() /var/www/project/htdocs/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:94
PHP  22. Mockery\Container->mock() /var/www/project/htdocs/vendor/mockery/mockery/library/Mockery.php:117
PHP  23. Mockery\Loader\EvalLoader->load() /var/www/project/htdocs/vendor/mockery/mockery/library/Mockery/Container.php:224

In EvalLoader.php(34) : eval()'d code line 1003:

Cannot redeclare Mockery_0_Illuminate_Auth_Access_Gate::allows()

Anyone got any ideas?

Laravel: 5.7.28 Mockery: 1.2.2 Codeception: 2.2.5

ixudra left a reply on Linux File Permissions

@bobbybouwmann Storage is not the problem. I checked the path, he's trying to write in /var/www/project/htdocs/bootstrap/cache

ixudra left a reply on Linux File Permissions

@bobbybouwmann Sorry, that was not clear. I try to open my index page (or any page really) and I get the standard chmod(): Operation not permitted error. If I comment out the chmod() in the vendor file (bad idea, I know), the file is generated properly and I can continue development. Nevertheless, should be resolved since this makes no sense to me

ixudra started a new conversation Linux File Permissions

Updated my Laravel website to version 5.7, now suddenly I have permission issues when compiling my auto-discover file.

        // /var/www/project/htdocs/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php
     
        /**
         * Write the contents of a file, replacing it atomically if it already exists.
         *
         * @param  string  $path
         * @param  string  $content
         * @return void
         */
        public function replace($path, $content)
        {
            // If the path already exists and is a symlink, get the real path...
            clearstatcache(true, $path);
     
            $path = realpath($path) ?: $path;
     
            $tempPath = tempnam(dirname($path), basename($path));
     
            // Fix permissions of tempPath because `tempnam()` creates it with permissions set to 0600...
            chmod($tempPath, 0777 - umask());        // => Error occurs here
     
            file_put_contents($tempPath, $content);
     
            rename($tempPath, $path);
        }
     ```

File permissions:

$ ls -al bootstrap/ total 8 drwxrwxr-x 5 vagrant www-data 160 Apr 13 14:52 ./ drwxrwxr-x 36 vagrant www-data 1152 Apr 13 14:38 ../ -rwxrwxr-- 1 vagrant www-data 1654 Apr 13 14:52 app.php* -rwxrwxr-- 1 vagrant www-data 1079 Mar 18 2018 autoload.php* drwxrwxr-x 7 vagrant www-data 224 Apr 13 14:55 cache/

$ ls -al bootstrap/cache/ total 4 drwxrwxr-x 7 vagrant www-data 224 Apr 13 14:55 ./ drwxrwxr-x 5 vagrant www-data 160 Apr 13 14:52 ../ -rwxrwxr-- 1 vagrant www-data 14 Mar 18 2018 .gitignore* -rw-rw-r-- 1 vagrant www-data 0 Apr 13 14:55 packages.phpQSsjXI -rw-rw-r-- 1 vagrant www-data 0 Apr 13 14:46 packages.phpSJ4MQu -rw-rw-r-- 1 vagrant www-data 0 Apr 13 14:48 packages.phpVyLbgt -rw-rw-r-- 1 vagrant www-data 0 Apr 13 14:52 packages.phpZ9EzqP


PHP user: www-user

$ groups www-user www-user : www-user www-data


For as far as I can see, it should be in order. The user belongs to a group that has write and execute permissions so I don't understand how I'm getting an exception. I could just do a `chmod -R 777` but that's a bad idea in general. How can I solve this in a "clean" way?
08 Mar
4 months ago
06 Mar
4 months ago
05 Mar
4 months ago

ixudra left a reply on Laravel Passport With Custom Provider

Bump. Quite urgent :-)

ixudra started a new conversation Laravel Passport With Custom Provider

I have a project where my customers have "Accounts", and employees of my customers can log in to the application using the "User" model. Even though users have their own logins, all data is linked to the account model.

User logins work normally, since it's pretty straightforward. The app also has an API however but the API is Account-specific, not User-specific. Each customer (so each Account) has a website that consumes the API, but for abvious reasons it should only retrieve the information linked to the Account linked to it. Meaning that I need to authenticate the account, and not the user.

In order to do this, I use Laravel passport as an OAuth server. I added the necessary traits to the Account model and set up the provider in the config:

return [

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'passport',
            'provider' => 'accounts',
        ],
    ],

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\Models\User::class,
        ],

        'accounts' => [
            'driver' => 'eloquent',
            'model' => App\Models\Account::class,
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],
];
class Account extends Model {

    use Authenticatable, HasApiTokens;


    protected $table = 'accounts';


    public function users()
    {
        return $this->hasMany( User::class );
    }
}
class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract {

    use Authenticatable, Authorizable, CanResetPassword;


    protected $table = 'users';

    public function account()
    {
        return $this->belongsTo( Account::class );
    }
}

Now I set up the code as shown above, created the OAuth tables and generated the personal keys. When I use the access token as a "Bearer" API authentication method, the user is not authenticated. The correct UserProvider is loaded, the Bearer token is detected and decoded, the correct Account model is recovered from the database. But when I use the Auth facade to get the authenticated user (Auth::user()), it returns null. In short, even though the request is authenticated, no user has been signed in

How can I sort this out? What do I need to change in order to allow the app to authenticate Accounts using the API Bearer tokens?

06 Dec
7 months ago

ixudra left a reply on How To Model Settings In The Database

We have a winner! Thx

ixudra started a new conversation How To Model Settings In The Database

I have an app where my user can generate say 10 different pdfs. For each PDF, there are some settings that the user can customize (page size, font size, colors, content modifications,...). I'm wondering how I can best model this in the database. I can create 10 tables with settings, one for each of the pdfs, will work but won't be pretty since my user will suddenly have a LOT of relationships.

Alternatively, I could make a generalized settings table with a key-value method, but in that case all settings would have the same data type, namely longtext and I'd have to convert to the appropriate data type in code.

I'm partial to the second approach but I was wondering if there are alternatives I missed or different perspectives on the subject

29 Oct
8 months ago

ixudra left a reply on Sync Queue Using Alternate Env Variables

Anyone have an idea?

25 Oct
8 months ago

ixudra left a reply on Help With 2fa

Bump :-)

ixudra started a new conversation Sync Queue Using Alternate Env Variables

I'm running a Laravel 5.7 app which uses a queue. On local, this is set to use the sync driver, so events are handled immediately. Works fine, if not for the fact that my events are handled with different environment variables. I know this because set up Slack notifications from the production environment but I receive them every time I run certain queued actions on a local environment. This shouldn't happen since these notifications are disabled on local. I'm sure they don't come from the production server since they all contain test data.

Any idea how this might be?

16 Oct
9 months ago

ixudra started a new conversation Help With 2fa

I set up 2fa for my application. Works fine, now I want to add pragmarx/recovery to it but I'm having trouble wrapping my head around how it works. I can generate the codes easily enough and show them on screen and/or save them in the database, but no idea what happens next. Do I need to send them to Google to recover the password? Or are the codes themselves the "password", as it were?

12 Sep
10 months ago

ixudra left a reply on Store Results Of Filter For Back Button

Well, my app doesn't use Vuex and it's not a single page app. Gathering the search results happens using the API, but the results details are a completely new page. So client side isn't going to work, I'm afraid

ixudra started a new conversation Store Results Of Filter For Back Button

Hi

I have a Laravel app with search functionality. I would like to add a "back to search results" functionality, meaning that I want to go back to the original search results (same filters, same page, same page size,...) after viewing one of the results generated by the search. Normally, I would do something like this by adding the search filters to the session and recovering them when going back to the search results.

However, my app is using VueJS as a frontend. This means that the search results are recovered via the API, not a "normal" web request. These API requests use the api middleware group, which means that the session is never initiated, which in turn means that I can't use the session to store the search results.

Is there anyone that has done this before? How did you handle it? Am I missing something?

31 Aug
10 months ago

ixudra left a reply on Two-factor Authentication

So I found the solution... Maybe it's a new addition, but all of the tutorials mention that you need to publish the configuration, but they seem to forget that you need to change the enabled value from false to true. Not sure why that's even in there since you'd think that it's supposed to be enabled if you install the package but oh well.

Hope this helps somebody else in the future.

ixudra left a reply on Two-factor Authentication

@jlrdw Thanks for this, it did help me some but the problem still persists. I've identified the problem but no idea how to fix it. Whenever I log in, I get redirected to the next route, which has the 2fa middleware registered as mentioned in the official docs and the tutorial you provided. For some reason, however, the user is already marked as "authenticated", which means the user is never redirected to the 2FA form.

Am I missing something?

30 Aug
10 months ago

ixudra started a new conversation Two-factor Authentication

Hi

I'm trying to to set up two-factor authentication in my app. I'm using the pragmarx/google2fa package to do so. Setting up 2fa, generating the QR code for the user and saving the secret key t the db works perfectly well. The problems occur when I try to log in. I never get redirected to the one-time password window, even though I added the middleware to the route. I find the tutorials very unclear on this subject. Does anyone have experience with this and would like to help me through it?

ixudra left a reply on Installing Mailhog In VM

Any ideas? Thx

ixudra left a reply on Service Provider Vs Simple Class

Honestly, I only use ServiceProviders if I have a couple of classes that might be able to act as a separate package. Doesn't mean they always have to, in some cases you might only use them in one project. But it's a rule of thumb I use. You can see that in Laravel core too: AuthServiceProvider, RoutingServiceProvider,... All major components that could function individually. For one class, I think there aren't any real advantages

Another way of looking at it, is if you need to initialize stuff. Routing is a good example of this. If you look in the RoutingServiceProvider, you'll see that the routing files are loaded in the boot() method. That to me is also an indication that you're dealing with a module of sorts, rather than just one or to "loose" classes

29 Aug
10 months ago

ixudra started a new conversation Installing Mailhog In VM

I'm running an Ubuntu 16 VM with VMWare, for several of my websites, very happy with my setup. I'd like to add Mailhog to the VM so I can see my emails in the browser instead of sending them to a dummy email address.

I found a tutorial that shows me how to install it. It worked perfectly, the app is running on my VM at port 1025. However, now I would like to access it from my local machine (OSX) in my browser. So far, I haven't been able to manage that.

Anyone ever did something like this before? How can it be done?

Thanks

19 Jul
11 months ago

ixudra left a reply on Sending File Using Guzzle

I feel like slamming my head against my desk for at least 15 mins but my desk is actually pretty expensive... Thanks for your patience and your assist @lostdreamer_nl , this did indeed fix my issue.

ixudra left a reply on Sending File Using Guzzle

This is the request that Postman is sending:

POST /api/whitelabel/images HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Authorization: Bearer token-xyz
Cache-Control: no-cache

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="myFile"; filename="plate.jpg"
Content-Type: image/jpeg


------WebKitFormBoundary7MA4YWxkTrZu0gW--

ixudra left a reply on Sending File Using Guzzle

@lostdreamer_nl Got some feedback from that, but not sure what to make of it though:

"""
--ed71df491f8e9775c5c535bc327bfb639a13ce11\r\n
Content-Disposition: form-data; name="myFile"; filename="plate.jpg"\r\n
Content-Length: 78188\r\n
Content-Type: image/jpeg\r\n
\r\n
 Ï Ó\x00\x10JFIF\x00\x01\x01\x01\x01,\x01,\x00\x00 Ý\x00,Photoshop 3.0\x0 .... \r\n
--ed71df491f8e9775c5c535bc327bfb639a13ce11--\r\n
"""

ixudra left a reply on Sending File Using Guzzle

@lostdreamer_nl Tried that as well, didn't work

Sorry, I know you're trying to help but I've been stuck here for a while...

ixudra left a reply on Sending File Using Guzzle

@lostdreamer_nl Tried that, doesn't work

Guzzle version: 6.3.3, which is the latest version

ixudra left a reply on Sending File Using Guzzle

@lostdreamer_nl I get a guzzle client error with a 400 status, saying No image found. For some reason the data is not submitted correctly, or at least the server is not finding it. Not sure how, since I got this code from the official docs

ixudra started a new conversation Sending File Using Guzzle

I'm trying to transform a postman request into Guzzle. Postman works fine, Guzzle is a nightmare. Probably just a minor detail but I can't seem to figure it out. Any help is appreciated.

The postman request: Request

My request so far (not working)

            $response = $this->client->post(
                '/api/whitelabel/images', [
                    'headers' => [
                        'Accept'                => 'application/json',
                        'Content-Type'          => 'multipart/form-data',
                        'Authorization'         => 'Bearer '. $userToken,
                    ],
                    'multipart' => [
                        [
                            'name'     => 'myFile',
                            'contents' => file_get_contents($media->getPath()),
                        ],
                    ],
                ],
            );

Path to file is correct

12 Sep
1 year ago

ixudra left a reply on Two Way Binding Not Successful

@phpMick Yeah, both workoutList and workout props are passed and bound using v-bind, see component files. If I inspect the workouts in the browser, I can clearly see that all props are present in the HTML

ixudra started a new conversation Two Way Binding Not Successful

I'm making an app that allows me to drag and drop elements between lists so I can later store that into a database. I managed to ge this working using the Vue.Draggable library, which is a wrapper around SortableJS.

The problem that I'm having is that only the visual representation is matching. The data does not get updated when I drag an item from one list to another and I have no idea how to make this work. I tried doing some magic using the addToList method, but that didn't do me any good. It seems I can only access the HTML element in there and not the Vue data object it is representing, thus I can not update the data. Am I missing something? Am I not setting it up correctly?

    <div class="row" id="vue-root">
        <div class="col-lg-12">
            <div class="col-lg-4">
                <h2>Required</h2>
                <hiddit-workout-list v-bind="requiredWorkouts"></hiddit-workout-list>

                <h2>Optional</h2>
                <hiddit-workout-list v-bind="optionalWorkouts"></hiddit-workout-list>
            </div>
            <div class="col-lg-8">
                <div class="row col-lg-12">
                    <h1>Workout planning</h1>
                </div>
                <div class="row col-lg-12">
                    <div class="col-lg-4 dropzone">
                        <hiddit-workout-list v-bind="mondayMorningWorkouts"></hiddit-workout-list>
                    </div>
                    <div class="col-lg-4 dropzone">
                        <hiddit-workout-list v-bind="wednesdayMorningWorkouts"></hiddit-workout-list>
                    </div>
                    <div class="col-lg-4 dropzone">
                        <hiddit-workout-list v-bind="fridayMorningWorkouts"></hiddit-workout-list>
                    </div>
                </div>
                <div class="row col-lg-12">
                    <div class="col-lg-4 dropzone">
                        <hiddit-workout-list v-bind="mondayEveningWorkouts"></hiddit-workout-list>
                    </div>
                    <div class="col-lg-4 dropzone">
                        <hiddit-workout-list v-bind="wednesdayEveningWorkouts"></hiddit-workout-list>
                    </div>
                    <div class="col-lg-4 dropzone">
                        <hiddit-workout-list v-bind="fridayEveningWorkouts"></hiddit-workout-list>
                    </div>
                </div>
            </div>
        </div>
    </div>
Vue.component('workout', require('./components/Workout.vue'));
Vue.component('workout-list', require('./components/WorkoutList.vue'));

let vue = new Vue({

    el: '#vue-root',

    data: {

        workouts: [
            {
                id: 1,
                name: 'Cardio 1',
                type: 'cardio',
                optional: false,
                day: 'none',
                timeOfDay: 'none',
                sets: 3,
                reps: 10,
                rest: 24
            },
            {
                id: 2,
                name: 'Cardio 2',
                type: 'cardio',
                optional: true,
                day: 'none',
                timeOfDay: 'none',
                sets: 3,
                reps: 10,
                rest: 24
            },
            {
                id: 3,
                name: 'Agility 1',
                type: 'agility',
                optional: false,
                day: 'none',
                timeOfDay: 'none',
                sets: 3,
                reps: 10,
                rest: 24
            },
            {
                id: 4,
                name: 'Agility 2',
                type: 'agility',
                optional: true,
                day: 'none',
                timeOfDay: 'none',
                sets: 3,
                reps: 10,
                rest: 24
            },
            {
                id: 5,
                name: 'Ropeskipping 1',
                type: 'rope',
                optional: false,
                day: 'none',
                timeOfDay: 'none',
                sets: 3,
                reps: 10,
                rest: 24
            },
            {
                id: 6,
                name: 'Ropeskipping 2',
                type: 'rope',
                optional: true,
                day: 'monday',
                timeOfDay: 'morning',
                sets: 3,
                reps: 10,
                rest: 24
            },
            {
                id: 7,
                name: 'Ropeskipping 3',
                type: 'rope',
                optional: true,
                day: 'monday',
                timeOfDay: 'morning',
                sets: 3,
                reps: 10,
                rest: 24
            },
            {
                id: 8,
                name: 'Ropeskipping 4',
                type: 'rope',
                optional: true,
                day: 'wednesday',
                timeOfDay: 'evening',
                sets: 3,
                reps: 10,
                rest: 24
            }
        ]
    },

    methods: {

    },

    computed: {

        requiredWorkouts() {
            return {
                day: 'none',
                timeOfDay: 'none',
                workouts: this.workouts.filter( workout => !workout.optional && workout.day === 'none' && workout.timeOfDay === 'none' )
            };
        },

        optionalWorkouts() {
            return {
                day: 'none',
                timeOfDay: 'none',
                workouts: this.workouts.filter( workout => workout.optional && workout.day === 'none' && workout.timeOfDay === 'none' )
            };
        },

        mondayMorningWorkouts() {
            return {
                day: 'monday',
                timeOfDay: 'morning',
                workouts: this.workouts.filter( workout => workout.day === 'monday' && workout.timeOfDay === 'morning' )
            };
        },

        mondayEveningWorkouts() {
            return {
                day: 'monday',
                timeOfDay: 'evening',
                workouts: this.workouts.filter( workout => workout.day === 'monday' && workout.timeOfDay === 'evening' )
            };
        },

        wednesdayMorningWorkouts() {
            return {
                day: 'wednesday',
                timeOfDay: 'morning',
                workouts: this.workouts.filter( workout => workout.day === 'wednesday' && workout.timeOfDay === 'morning' )
            };
        },

        wednesdayEveningWorkouts() {
            return {
                day: 'wednesday',
                timeOfDay: 'evening',
                workouts: this.workouts.filter( workout => workout.day === 'wednesday' && workout.timeOfDay === 'evening' )
            };
        },

        fridayMorningWorkouts() {
            return {
                day: 'friday',
                timeOfDay: 'morning',
                workouts: this.workouts.filter( workout => workout.day === 'friday' && workout.timeOfDay === 'morning' )
            };
        },

        fridayEveningWorkouts() {
            return {
                day: 'friday',
                timeOfDay: 'evening',
                workouts: this.workouts.filter( workout => workout.day === 'friday' && workout.timeOfDay === 'evening' )
            };
        }

    }

});
<!-- Workout.vue -->
<template>

    <div class="workout">
        {{ name }}
    </div>

</template>


<script>

    export default {

        props: {
            id: {
                type: Number,
                required: true,
            },
            name: {
                type: String,
                required: true,
            }
        }

    }

</script>
<!-- WorkoutList.vue -->
<template>

    <draggable v-model="workouts" :options="{ group: 'workouts' }" @add="addToList">
        <transition-group class="workout-list">
            <workout v-for="workout in workouts" :key="workout.id" v-bind="workout" class="item"></hiddit-workout>
        </transition-group>
    </draggable>

</template>


<script>

    import draggable from 'vuedraggable'
    import Workout from './Workout.vue'

    export default {

        props: {
            workouts: {
                type: Array,
                required: false
            },
            day: {
                type: String,
                required: true
            },
            timeOfDay: {
                type: String,
                required: true
            }
        },

        components: {
            draggable,
            Workout
        },

        methods: {
            addToList: function(event) {
                // event.item is a HTML element, no connection the the actual data element to be found...
                event.item.day = this.day;
                event.item.timeOfDay = this.timeOfDay;
            }
        }

    }

</script>
05 Sep
1 year ago

ixudra left a reply on How To Test My Package?

@topvillas Mocking the CurlService doesn't solve anything. That class is just an intermediary, only 2 lines of code in there. The real complexity is in the Builder class, that's the one I need to test. And I don't need the CurlService at all to do that

That said, I did consider partial mocking for the Builder class. I could help to get me some coverage at least, but not nearly the level I'm aiming towards

ixudra left a reply on How To Test My Package?

@topvillas That is the general idea, yes, but I have no idea how to accomplish it. cURL is a PHP extension, you can't just mock that. Additionally, the package is platform independent so I don't have a IOC container or facade I can rely on

ixudra started a new conversation How To Test My Package?

I maintain several packages that are available for download via composer. To my shame, most of these do not have tests, despite me using them extensively in my day to day activities. Reason is simple: I don't know how to make them work properly.

For example: my most used package is ixudra/curl, a package for easily sending cURL requests through a fluent query builder. Ideally, I'd want to set up tests that cover all different methods and options, such as GET requests, POST requests, file upload, various header types, ... but I have no idea how to do this. I can't just use random websites, I'll be fixing my tests all the time if they change their interface. I could set up a website myself and provide all the required routes but that just seems silly

How could I best tackle this issue? How can I write reliable tests without external dependencies?

Thx

27 Aug
1 year ago

ixudra left a reply on Laravel Mix Failures - Possible Dependency Issue

It seems NodeJs was the problem here. I recently updated to Node 8.4.* and all my problems disappeared

ixudra started a new conversation How Is JavaScript Set Up In Laravel?

So this is the default app.js file in the Laravel framework:


window._ = require('lodash');

/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

try {
    window.$ = window.jQuery = require('jquery');

    require('bootstrap-sass');
} catch (e) {}

/**
 * We'll load the axios HTTP library which allows us to easily issue requests
 * to our Laravel back-end. This library automatically handles sending the
 * CSRF token as a header based on the value of the "XSRF" token cookie.
 */

window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

/**
 * Next we will register the CSRF Token as a common header with Axios so that
 * all outgoing HTTP requests automatically have it attached. This is just
 * a simple convenience so we don't have to attach every token manually.
 */

let token = document.head.querySelector('meta[name="csrf-token"]');

if (token) {
    window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
    console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}

/**
 * Echo exposes an expressive API for subscribing to channels and listening
 * for events that are broadcast by Laravel. Echo and event broadcasting
 * allows your team to easily build robust real-time web applications.
 */

// import Echo from 'laravel-echo'

// window.Pusher = require('pusher-js');

// window.Echo = new Echo({
//     broadcaster: 'pusher',
//     key: 'your-pusher-key'
// });

I understand what is going on here - we use requirejs to load in lodash, jQuery, bootstrap, axios and possibly pusher as the file is loaded in. Thing is, I don't understand how this is happening. I looked at the requirejs documentation and it seems completely different from what I'm seeing here. How does the app know to look for ~/node-modules/jquery/dist/jquery.js, only from the string 'jquery'? There doesn't seem to be any pattern as far as I can see, so how is that set up?

Let's say I have a small js file from a friend of mine, how could I include it? Right now, I merge them using the mix file, but it seems like there should be a more elegant way of doing this... ?

06 Jul
2 years ago

ixudra left a reply on Supervisor Not Found

Honestly I don't really remember because it's been such a long time but if I had to guess:

[[email protected]]# supervisorctl
unix:///tmp/supervisor.sock refused connection
supervisor> status
unix:///tmp/supervisor.sock refused connection
supervisor> reread
error: <class 'socket.error'>, [Errno 111] Connection refused: file: /usr/lib64/python2.7/socket.py line: 224
supervisor> exit

basically means that the service was not started correctly before accessing the control panel. So what you need to do to fix that, is (surprise surprise) start supervisor:

sudo service supervisor restart

After that, you should be able to access the control panel without issue

04 Jul
2 years ago

ixudra left a reply on Laravel Mix Failures - Possible Dependency Issue

@kehator To be honest: I'm about 98.749% sure the path problem will resolve itself as soon as I manage to update my Laravel mix to > 0.8, it's a know bug that @JeffreyWay actually added a fix for (see Github link in original post). I just have no idea what is going wrong here

ixudra left a reply on Laravel Mix Failures - Possible Dependency Issue

@kehator I believe you misread: I am NOT using a custom webpack config file.

02 Jul
2 years ago

ixudra started a new conversation Laravel Mix Failures - Possible Dependency Issue

I'm trying to manage my dependencies using Laravel Mix. Installing my dependencies works fine, however running npm run dev brings me to a world of trouble.

Here is my package.json file:

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.16.2",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^5.0.1",
    "eonasdan-bootstrap-datetimepicker": "^4.17.0",
    "modernizr": "^3.3.1",
    "restfulizerjs": "^1.0.0",
    "jquery": "^3.1.1",
    "laravel-mix": "^1.0",
    "lodash": "^4.17.4",
    "vue": "^2.1.10"
  }
}

Here is my Laravel mix file:

let mix = require('laravel-mix');

var paths = {
    'bootstrap':        './node_modules/bootstrap-sass/assets/',
    'dateTimePicker':   './node_modules/eonasdan-bootstrap-datetimepicker/src/',
    'jquery':           './node_modules/jquery/',
    'modernizr':        './node_modules/modernizr/',
    'moment':           './node_modules/moment/',
    'momentTimezone':   './node_modules/moment-timezone/',
    'restfulizer':      './node_modules/restfulizerjs/'
};

mix

// Compile SASS files
    .sass('resources/assets/bootstrap/sass/app.scss', 'public/bootstrap/css/app.css')

    // Copy fonts to public directory
    .copy(paths.bootstrap + 'fonts/bootstrap/**', 'public/bootstrap/fonts')

    // Combine Javascript files
    .js([
        paths.jquery + "dist/jquery.js",
        paths.bootstrap + "javascripts/bootstrap.js",
        paths.moment + "moment.js",
        paths.dateTimePicker + "js/bootstrap-datetimepicker.js",
        paths.restfulizer + "jquery.restfulizer.js",
        "resources/assets/bootstrap/js/app.js"
    ], 'public/bootstrap/js/app.js', './')

    // Version stylesheet and javascript file
    .version();

The error that I get is the following:

$ npm run dev

> @ dev /var/www/my-hiddit/htdocs
> npm run development


> @ development /var/www/my-hiddit/htdocs
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.output.path: The provided value "public" is not an absolute path!

That brought me to these posts on the Laravel Mix github page. At first, it didn't seem to apply to me because I have Laravel mix at ^1.0 in my package.json file. But then I ran a node list --depth=0 and got the following:

$ npm list --depth=0
/var/www/my-hiddit/htdocs
├── [email protected] invalid
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] invalid
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

I've tried to fix this in any number of ways, but no matter what I do Laravel Mix always stays stuck at 0.7.5 - even if I fix the version or if I remove all other dependencies from the file. I assume this is what's causing my other problem but I have absolutely no idea why this is happening or how I can fix it.

Any help would be appreciated.

OS: Ubuntu 16 Ruby version: 2.3.1 Node version: 8.0.7 NPM version: 5.0.3

12 Apr
2 years ago
06 Apr
2 years ago

ixudra started a new conversation Non-searchable Arguments Not Returned By Algolia

I have a small app where I use algolia. Amongst other things, I store a profile image in Algolia. These image urls and alts should not be searchable so I exclude them in the algolia rankings screen. This works fine, except for the fact that these fields are now no longer returned in the search results. This is no good and absolutely makes no sense to me.

Is this normal behavior or am I doing something wrong?

14 Feb
2 years ago

ixudra left a reply on Composer Dependency Issues

@KamalKhan That did indeed solve this issue, but it wasn't what I was looking for. I was hoping to set up an app where I could test all my own packages on dev-master, but I guess that's not possible if they depend on each other.

Thanks everyone for the help

10 Feb
2 years ago

ixudra left a reply on Composer Dependency Issues

@KamalKhan That was one of the first things I tried, same error.

ixudra started a new conversation Composer Dependency Issues

I'm having some issues with downloading a couple of packages via composer. As far as I can see, there should not be a problem. Sadly, I keep getting an error saying that there is a mismatch in the dependencies.

Composer.json file for the application:

{
    "name": "Project",
    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.3.*",
        "laravelcollective/html": "~5.3",
        "laracasts/presenter": "0.2.*",
        "arcanedev/log-viewer": "^4.0",
        "ixudra/translation": "dev-master",
        "ixudra/portfolio": "dev-master",
        "ixudra/validation": "dev-master",
        "ixudra/core": "dev-master",
        "ixudra/csi": "dev-master"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "scripts": {
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize",
            "php artisan ide-helper:generate"
        ]
    }
}

Composer.json for package 1:

{
    "name": "ixudra/portfolio",
    "version": "0.2.0",
    "require": {
        "php": ">=5.4.0",
        "illuminate/support": "~5.0",
        "laravelcollective/html": "~5.0",
        "ixudra/core": "~5.0",
        "ixudra/translation": "~5.1",
        "ixudra/imageable": "~6.0",
        "laracasts/presenter": "0.2.*"
    },
    "autoload": {
        "classmap": [
            "src/database/migrations"
        ],
        "psr-4": {
            "Ixudra\\Portfolio\\": "src/"
        }
    }
}

Composer.json for package 2:

{
    "name": "ixudra/core",
    "version": "5.3",
    "require": {
        "php": ">=5.4.0",
        "illuminate/support": "~5.0",
        "laracasts/presenter": "0.2.*"
    },
    "autoload": {
        "classmap": [
            "src/migrations"
        ],
        "psr-4": {
            "Ixudra\\Core\\": "src/"
        }
    }
}

This is the error I receive:

$ composer update --no-scripts
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for ixudra/portfolio dev-master -> satisfiable by ixudra/portfolio[dev-master].
    - ixudra/portfolio dev-master requires ixudra/translation ~5.1 -> satisfiable by ixudra/translation[5.1.0, 5.1.1, 5.1.2, 5.1.3, 5.1.4, 5.1.5, 5.2.0, 5.2.1] but these conflict with your requirements or minimum-stability.

As far as I can see, the ixudra/translation dependency should be resolved by [dev-master]. I don't understand why this is not the case. If I remove the ixudra/portfolio package from the app, the dev-master version of ixudra/translation is downloaded without a problem... Can someone please understand what I am doing wrong here?

30 Nov
2 years ago

ixudra left a reply on Catching Errors In CURL Requests

@jekinney Try-catch will not work as controller and cURL request are in two different applications. My question is related to recovering the error message in the second application, where no actual exception is thrown. Also your condescending tone is noted but not appreciated

@ejdelmonico As you can see from my example, using curl_error($e); returns a generic error message instead of the `You shall not pass that I expect. Maybe there is something wrong with my cURL request, but in all my experiments, I have never been able to make this work.

29 Nov
2 years ago

ixudra started a new conversation Catching Errors In CURL Requests

Question about cURL: say I have the following code

class MyController {

    public function index()
    {
        throw new \InvalidArgumentException('You shall not pass!!');
    }
}

Now let's say that I want to call this piece of code via cURL:

// Create a curl handle to a non-existing location
$ch = curl_init('http://someUrl.net/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

if(curl_exec($ch) === false)
{
    echo curl_error($ch);
}

// Close handle
curl_close($ch);

The code itself works fine, only I don't see my custom exception message. All I see is error code 500 and the following error message:

The requested URL returned error: 500 Internal Server Error

This message is not very helpful as I want to see what exactly went wrong. Is there a way to do this?