PatrickL

PatrickL

Member Since 6 Months Ago

Experience Points 3,390
Experience
Level
Lessons Completed 14
Lessons
Completed
Best Reply Awards 0
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.

03 Dec
6 days ago

PatrickL left a reply on Package For Supporting Stripe Connect

@JLRDW - So, basically, I need to make my own package then. Alright.

PatrickL started a new conversation Package For Supporting Stripe Connect

Is there a package that supports Stripe Connect? I checked Laravel Cashier. But, it doesn’t support Stripe Connect, and according to Taylor Otwell himself, it doesn’t look like it will support it any time soon.

Are there any Laravel packages that support Stripe Connect or will I need to build my own?

02 Dec
1 week ago

PatrickL left a reply on Storage:Link Not Working Properly

@RUMM.AN - Ah. That fixed it. Thank you

01 Dec
1 week ago

PatrickL left a reply on Storage:Link Not Working Properly

@SNAPEY - The resource URL looks right.

<img src="http://homestead.test/storage/images/logo.png" height = "50" width = "50">

However, when I select the resorce in the view source inspector, it says there was an error loading the resource. Apparently, the server is returning a 404 not found error.

Could this be because I am using Homestead in-project? It seemed to work fine when I was testing it in MAMP.

PatrickL left a reply on Storage:Link Not Working Properly

@REALRANDYALLEN - Checked it. It is 755.

PatrickL started a new conversation Storage:Link Not Working Properly

I used the storage:link artisan command to generate a symlink to my application's assets for use in the views (logos, images, etc...). However, when I load my app to a Homestead VM, the images are not showing up on my views.

For instance, when I do something like:

 <img src="{{ URL::asset('storage/images/logo.png') }}" alt = {{ config('app.name') }} height = "50" width = "50">

to link to a file in

public/storage/images/logo.png

I get nothing.

What am I doing wrong?

30 Nov
1 week ago

PatrickL started a new conversation MongoDB Support + Passport

Is there a way to get MongoDB support for both main database functionality and Passport compatibility? I need both. For my project, I want to use MongoDB for everything (just so I don't need to deal with two different types of databases). That is for both API (passport) requirements and data persistence.

Is there any way to do this?

PatrickL started a new conversation MongoDB Support For Both Lumen Models And Passport OAuth

How do I get both Lumen models and OAuth functionality (passport adopter) to be compatible with MongoDB in a Lumen application? I see packages that promise one or the other, but not both. And both packages need my models to inherit each of their distinct Molequent adoptions.

Thanks.

27 Nov
1 week ago

PatrickL left a reply on How Should I Go About This

It would seem that all you need to do is to pass a list of locations that the user owns to your view. Then, have a route that returns the details of the selected location, which gets called every time the user makes a selection in the drop down.

PatrickL started a new conversation Installing Laravel MongoDB On Vagrant Box

Hey, I am having this issue installing Laravel MongoDB (https://github.com/jenssegers/laravel-mongodb). What I have done so far is to install MongoDB on my Vagrant Box as instructed in the Homestead documentation, by adding this line to my Homestead.yaml file:

mongodb: true

I then provisioned the VM by running

vagrant reload --provision

I then tried installing the above package with

composer require jenssegers/mongodb

When running this, I get the following errors:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - jenssegers/mongodb v3.4.0 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.0-alpha1, 1.0.0-beta1, 1.0.0-beta2, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.1.0, 1.1.0-alpha1, 1.1.1, 1.1.2, 1.2.0, 1.2.0-alpha1, 1.3.0, 1.3.1, 1.3.2, 1.4.0, 1.4.1, 1.4.2, 1.5.x-dev, v1.0.x-dev, v1.1.x-dev, v1.2.x-dev, v1.3.x-dev, v1.4.x-dev].
    - jenssegers/mongodb v3.4.1 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.0-alpha1, 1.0.0-beta1, 1.0.0-beta2, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.1.0, 1.1.0-alpha1, 1.1.1, 1.1.2, 1.2.0, 1.2.0-alpha1, 1.3.0, 1.3.1, 1.3.2, 1.4.0, 1.4.1, 1.4.2, 1.5.x-dev, v1.0.x-dev, v1.1.x-dev, v1.2.x-dev, v1.3.x-dev, v1.4.x-dev].
    - jenssegers/mongodb v3.4.2 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.0-alpha1, 1.0.0-beta1, 1.0.0-beta2, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.1.0, 1.1.0-alpha1, 1.1.1, 1.1.2, 1.2.0, 1.2.0-alpha1, 1.3.0, 1.3.1, 1.3.2, 1.4.0, 1.4.1, 1.4.2, 1.5.x-dev, v1.0.x-dev, v1.1.x-dev, v1.2.x-dev, v1.3.x-dev, v1.4.x-dev].
    - jenssegers/mongodb v3.4.3 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.0-alpha1, 1.0.0-beta1, 1.0.0-beta2, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.1.0, 1.1.0-alpha1, 1.1.1, 1.1.2, 1.2.0, 1.2.0-alpha1, 1.3.0, 1.3.1, 1.3.2, 1.4.0, 1.4.1, 1.4.2, 1.5.x-dev, v1.0.x-dev, v1.1.x-dev, v1.2.x-dev, v1.3.x-dev, v1.4.x-dev].
    - jenssegers/mongodb v3.4.4 requires mongodb/mongodb ^1.0.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.0-alpha1, 1.0.0-beta1, 1.0.0-beta2, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.1.0, 1.1.0-alpha1, 1.1.1, 1.1.2, 1.2.0, 1.2.0-alpha1, 1.3.0, 1.3.1, 1.3.2, 1.4.0, 1.4.1, 1.4.2, 1.5.x-dev, v1.0.x-dev, v1.1.x-dev, v1.2.x-dev, v1.3.x-dev, v1.4.x-dev].
    - mongodb/mongodb v1.4.x-dev requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb v1.3.x-dev requires ext-mongodb ^1.4.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb v1.2.x-dev requires ext-mongodb ^1.3.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb v1.1.x-dev requires ext-mongodb ^1.2.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb v1.0.x-dev requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.5.x-dev requires ext-mongodb ^1.5.2 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.4.2 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.4.1 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.4.0 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.3.2 requires ext-mongodb ^1.4.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.3.1 requires ext-mongodb ^1.4.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.3.0 requires ext-mongodb ^1.4.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.2.0-alpha1 requires ext-mongodb ^1.2.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.2.0 requires ext-mongodb ^1.3.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.1.2 requires ext-mongodb ^1.2.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.1.1 requires ext-mongodb ^1.2.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.1.0-alpha1 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.1.0 requires ext-mongodb ^1.2.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.5 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.4 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.3 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.2 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.1 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.0-beta2 requires ext-mongodb ^1.1.1 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.0-beta1 requires ext-mongodb ^1.0.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.0-alpha1 requires ext-mongodb ^1.0.0 -> the requested PHP extension mongodb is missing from your system.
    - mongodb/mongodb 1.0.0 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system.
    - Installation request for jenssegers/mongodb ^3.4 -> satisfiable by jenssegers/mongodb[v3.4.0, v3.4.1, v3.4.2, v3.4.3, v3.4.4].

This error seems to be saying MongoDB is missing, even through I had already installed it earlier. Is there anything else I need to do after reloading the Vagrant Box in order to get MongoDB working properly?

Thank you.

PatrickL left a reply on MongoDB And Laravel Passport

@D9705996 - Alright. That’s a shame. Lol

Thank you.

26 Nov
1 week ago

PatrickL started a new conversation MongoDB And Laravel Passport

Hey,

I am building an app that requires using MongoDB as the database backend. For this, I plan to use this package. https://github.com/jenssegers/laravel-mongodb

The app also requires OAuth support. So, I wanted to use Laravel Passport. However, I notice that Laravel passport has its own migrations, which seems to be SQL tables as opposed to NoSQL (MongoDB collections). It also seems I will need to keep track of roles. I was looking into Entrust (https://github.com/Zizaco/entrust) which has its own migrations, hence the same dangling question.

Would I need to use both an SQL and NoSQL database to support all these requirements or is there a way to only use MongoDB for everything?

Thanks.

20 Nov
2 weeks ago

PatrickL started a new conversation Select Validation In Laravel

I have a select input in my view like this:

<div class="form-group row">
                            <div class="col-md-8 offset-md-2" name = "type">
                               <select class="selectpicker">
                                    <option>--Subscription Type--</option>
                                    <option value = "consumer">I am a Consumer</option>
                                    <option value = "business">I am a Business Owner</option>
                                </select>

                                @if ($errors->has('type'))
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $errors->first('type') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

In my controller, my validation rule looks like this:

'type' => 'required|in:"consumer", "business"'

But, when I test it, I get this error

Method Illuminate\Routing\ResponseFactory::redirect does not exist.

For reference, my entire method looks like this:

 public function subscriptionTypesPage(Request $request)
    {

        // list the validation rules

        $rules = [
            'email' => 'required|email',
            'type' => 'required|in:"consumer", "business"'
        ];

        // get the email
        $data = $request->only(['email', 'type']);

        // validate the request
        $validator = validator::make($data, $rules);

        // check if validator fails

        if ($validator->fails())
        {
            // return error
            return response()->redirect()->back()->withErrors($validator);
        }

        $email = $data['email'];
        return response()->view('suboptions', ['email' => $email], 200);
    }

and the form view looks like this:

<form method="POST" action="{{ route('subscriptions') }}">
                        @csrf

                        <div class="form-group row">
                            <div class="col-md-8 offset-md-2">
                                <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required placeholder="e-mail">

                                @if ($errors->has('email'))
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group row">
                            <div class="col-md-8 offset-md-2" name = "type">
                               <select class="selectpicker">
                                    <option>--Subscription Type--</option>
                                    <option value = "consumer">I am a Consumer</option>
                                    <option value = "business">I am a Business Owner</option>
                                </select>

                                @if ($errors->has('type'))
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $errors->first('type') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>


                        <div class="form-group row mb-0">
                            <div class="col-md-8 offset-md-4">
                                <button type="submit" class="btn btn-primary">
                                    {{ __('Keep Me Updated') }}
                                </button>
                            </div>
                        </div>
                    </form>

When I comment out the validation rule for the type (the select input) in my controller, everything seems to work fine. So, I think the error might be ckoming from how I defined the validation rule (second snipet) in the controller. But, this error message isn't really helping much in determinating the cause of the error.

Thanks for the help.

10 Nov
4 weeks ago

PatrickL left a reply on Migration Error On Laravel 5.7

@ARTHVRIAN - Ah okay. Turns out MySQL was running on port 8889. Thanks :)

PatrickL started a new conversation Migration Error On Laravel 5.7

I am getting this wierd error when I try to run my migrations on localnost. First, here is my env file (the connections part at least).

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=cgn
DB_USERNAME=root
DB_PASSWORD=root

My credentials look right on my sql database. However, when I run migrate, I get the following error:

Illuminate\Database\QueryException  : SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = cgn and table_name = migrations)

I change the DB_HOST property to "localhost". But, now I get this error.

  Illuminate\Database\QueryException  : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = cgn and table_name = migrations)

Any suggestions what's going on?

03 Nov
1 month ago

PatrickL started a new conversation Fatal Error: Uncaught Error: Call To Undefined Method CLI\Commands\NewContextCommand::initSphconfig() In /Users/patrickluy/Documents/Developer/Spheracle-Library/SphereLI/src/Commands/NewContextCommand.php:87

Hey Hey.

I am writing a little CLI for one of my projects. But, I am getting this really strange error I cannot figure out.

Fatal error: Uncaught Error: Call to undefined method CLI\Commands\NewContextCommand::initSphconfig() in /path/to\my/CLI/Project/src/Commands/NewContextCommand.php:87

Here is a stripped down version of NewContextCommand.php.


<?php

namespace CLI\Commands;


require_once __DIR__ . '/../../vendor/autoload.php';


use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Filesystem\Filesystem;

use CLI\Commands\CompositeCommand;


class NewContextCommand extends CompositeCommand
{
    
    /**
    * constructor
    */

    public function __construct()
    {
        parent::__construct();
    }

    

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        
        // get hte project name
        $project = $input->getArgument('project_name');

        // get the directory name
        $context = $input->getArgument('context_name');

        // get the context directory
        $directory = getcwd(). DIRECTORY_SEPARATOR . $context;

        $output->writeln("<info>Obtained arguments</>");
        
        try
        {
            // make sure directory name is valid

            if (!$this->validDirectoryName($context))
            {
                throw new \RuntimeException("Context name is invalid");
            }

            $output->writeln("<info>Obtained arguments</>");

            

            // check if directory is available to use

            if (!$this->directoryNameIsAvailable($directory))
            {
                throw new \RuntimeException("Context already exists");
            }

            // create context directory
            $this->filesystem->mkdir($directory);

            // initialize sphconfig
            $this->initSphconfig($directory, $context, $project);


        }
        catch(\RuntimeException $e)
        {
            $errorMsg = "<info>Error: " . $e->getMessage() . "\nReverting back to previous state</>";
            $output->writeln($errorMsg);

            // Revert back to original state
        }
    }
}

?>

Line 87 is this line


 $this->initSphconfig($directory, $context, $project);

The error is saying the initSphconfig(() function is not defined. initSphconfig() is defined in CompositeCommand, which is the parent class of this class. Again, a stripped down (you probabbly don't need to see all of its code) version of CompositeCommand.php is shown below.


<?php

namespace CLI\Commands;

require_once __DIR__ . '/../../vendor/autoload.php';

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use CLI\Configuration;


class CompositeCommand extends Command
{
    
    /**
        * @var Symfony\Component\Filesystem\Filesystem
        */

        protected $filesystem;


        /**
     * the spfconfig settings
     */

        protected $sphConfig;


        /**
    * constructor
    */

    public function __construct()
    {
        $this->filesystem = new Filesystem();
            $this->sphConfig = null;
            parent::__construct();
    }

        /**
        * initialize configuration
     */

        protected function initSphConfig(string $directory, string $context, string $project = null)
     {
            $configContents = Configuration::generate$context, $project);
            $path = $directory . DIRECTORY_SEPARATOR . Configuration::CONFIG_FILENAME;

            // check if file exists.
            if (is_file($path))
            {
                    throw new \RuntimeException("Directory already contains a configuration file.");
            }

            $this->filesystem->dumpFile($path, $configContents);
        }
}

?>

The NewContextCommand class should have inherited the initSphconfig(). So, I am puzzled to why I am getting that error when I run this command.

Any suggestions?

30 Oct
1 month ago

PatrickL left a reply on Custom Library Not Getting Pushed To GitHub

@D9705996 Oh. That worked. Thanks :)

PatrickL left a reply on Custom Library Not Getting Pushed To GitHub

@Cronix I only have one branch right now.

PatrickL left a reply on Custom Library Not Getting Pushed To GitHub

@D9705996 It says

    modified:   lib/Javelin (new commits)

PatrickL left a reply on Custom Library Not Getting Pushed To GitHub

@D9705996 My project doesn't actually have a gitignore. Could that be the problem?

PatrickL left a reply on Custom Library Not Getting Pushed To GitHub

@D9705996

That is what I have been doing. But, let me check my gitignore.

PatrickL started a new conversation Custom Library Not Getting Pushed To GitHub

I am having this wierd thing going on with my project. So, my project is structured like this. This is a Valinalla PHP project by the way. It is meant to contain all the application logic and will be called within the Laravel app to do the main tasks of the application. I do it this way to decouple my app from Laravel's infrastructure, just in case I want to move it to a different framework later.

Anyways, so, my app logic project looks like this.

Project
- src/
- - // project logic
- lib/
-- Javelin/ (Javelin is a Library I wrote generalizing the concepts of Domain Driven Design)
- // other stuff

My problem is every time I push this project to GitHub, the contents of lib/Javelin are left empty. So, in my application logic (src), when I pull to do Unit Testing or throw it into my Laravel app, it keeps complaining that the classes located in lib/Javelin do not exist.

In the past, I have had to copy/paste the Javelin library to fix this. But, I'd like for it to be included every time I push to GitHub.

How would I fix this?

25 Oct
1 month ago

PatrickL started a new conversation Sending Emails With Laravel Using Google App Engine

Hey,

in a Laravel App, I am creating, which will be run on Google Cloud's App Engine, I need to be able to have the application send emails. I know this can easily be done with services like AWS. But, is there a way to have Laravel's built-in mail features work with Google App Engine? Like, a Google Cloud equivalent to AES?

Thanks.

06 Oct
2 months ago

PatrickL started a new conversation Error On Laravel Entrust When Running Entrust:migration

I keep getting this error when running entrust:migration on a new Laravel install.

ReflectionException : Method Zizaco\Entrust\MigrationCommand::handle() does not exist

Not sure what is going on. Any advice?

19 Sep
2 months ago

PatrickL left a reply on Stripe API And Widholding Funds

@AlbertLabarento Alright. That makes sense. Would it be a good idea to use a separate stripe account to handle this, and use my primary one to collect fees (revenue source)? Or is it okay to clump them into one?

PatrickL left a reply on Stripe API And Widholding Funds

@shez1983 I have it set up so that both the buyer and seller have to agree that the transaction is completed. This can be initiated by either party. Additionally, there are other measures in place to deal with users that try to abuse the system.

Am I going to need two separate Stripe Accounts to do this though? Like, one to collect transaction fees and the other to hold these funds?

PatrickL started a new conversation Stripe API And Widholding Funds

I have a question related to the Stripe API for PHP. What I am building is a platform marketplace, quite similar to an e-commerce platform using the Stripe Connect service as a payments provider. One of the requirements for this platform is the application widholds the funds of a customer’s purchase until the seller fulfills said purchase. This is mostly to protect the platform from fraudulant activity.

Is there a way to implement this kind of mechanism or can Stripe handle this automatically?

17 Sep
2 months ago

PatrickL started a new conversation Converting A A Float Representation Of A Date To Carbon Object

One of the components of my application needs to convert a date (in float format), that it receives from another component, back into a Carbon object for processing and other stuff. But, I am uncertain how to go about converting it.

My app's first component returns a float (using Carbon's valueOf() method). The reason I chose this approach is to make it ideal to pass into javascript. Bur, other components of the application's backend also need to receive and process such dates.

So, how would I go about converting a date in float format, (i.e. float(1349479571124)) to a Carbon object, or, at the very least, a datetime string that I can parse into a Carbon object.

Thanks.

07 Sep
3 months ago

PatrickL left a reply on Address Validation In PHP And Laravel

@Cronix Alright. I’ll try it out. But, if I end up having to spend money, I might as well just use the Geocoder I am using on my other component lol

PatrickL left a reply on Address Validation In PHP And Laravel

@Cronix Preferrably world wide. My plan is to store all user data, including user addresses (this component) in one component. And then have another component dedicated to geocoding and doing stuff with this data.

PatrickL started a new conversation Address Validation In PHP And Laravel

Are there any recommended packages for validating addresses? I have my app split across several projects, each their own bounded context. In my User Bounded Context, I need to validate the address entered by the user to be used in the application. I just need to make sure the address exists. Nothing more (at least for this component).

Any advice.

01 Sep
3 months ago

PatrickL left a reply on Multiple Ids In Route

The variables in your route need to be unique. Once that’s done, in your controller function, include arguments matching the order of the variables in your route. They will then be injected automatically.

PatrickL left a reply on What Front End Framework Is Use In Laracasts ?

Vue is what is included in Laravel. But you are free to use others as well, like React.

PatrickL started a new conversation File Not Found Error In Use Statement In Namespaced File

So, my folder structure looks like this:

Javelin (Project name)
- src
- - Utils
- - - ID
- - - ID.php (has the namespace "Utils")
- - - IDInterface.php (has namespace "Utils")
- - Value
- - - ValueInterface.php (has namespace "Domain\Value")
- - - Value.php (has namespace "Domaini\Value")
- tests
- - IDTest.php
- vendor
- // other stuff

On my IDTest, when I run it with PHPUnit, I get the following Error:

PHP Fatal error:  Interface 'Javelin\Value\ValueInterface' not found in path/to/Documents/projects/Javelin/src/Value/Value.php on line 23

The error is referring to Value.php, which has the following definition.

<?php

namespace Value;

use Javelin\Value\ValueInterface;
use Javelin\Exception\IllegalStateChangeException;

/**--------------------------------------------------------------------------
|
|   Value
|
-----------------------------------------------------------------------------
|
|   A Value represents a Value Object. A Value Object is an object that 
|   represents a descriptive aspect of a domain with no conceptual 
|   identity. Value Objects are instanciated to implement design elements
|   in which we only care about what they are. 
|
-----------------------------------------------------------------------------
*/


abstract class Value implements ValueInterface // This is line 23
{
    // definition here
}

This leads me to believe there is something wrong with how I namespaced my file. But, it all seems correct from what I can tell. For reference, ValueInterface.php looks like this:

<?php

namespace Value; 

/**--------------------------------------------------------------------------
|
|   ValueInterface
|
-----------------------------------------------------------------------------
|
|   A Value represents a Value Object. A Value Object is an object that 
|   represents a descriptive aspect of a domain with no conceptual 
|   identity. Value Objects are instanciated to implement design elements
|   in which we only care about what they are. 
|
-----------------------------------------------------------------------------
*/


interface ValueInterface{}

And, IDTest.php looks something like this:


use PHPUnit\Framework\TestCase;
use Javelin\Utils\ID\ID;

/**===========================
||          IDTest
==============================
*/

class IDTest extends TestCase
{
    public function testConstructFromString()
    {
        $id = new ID("foo");
        $this->assertSame("foo", $id->value());
    }
}

?>

What am I doing wrong?

26 Aug
3 months ago

PatrickL left a reply on Interface Not Found Error In PHP

@crnkovic Oh, so I should have used

use Javelin\Domain\ValueInterface;

instead?

How does the autoloading work with regards to namespaces and directory structure?

In a test for my ID class in the same project, it throws an error when I do

use Javelin\Utils\ID;

On a class located in src/Utils/ID/ID.php with a namespace of Utils. But, doing this instead would work just find:

use Javelin\Utils\ID\ID;

even though the namespace of the files should just be Utils. I think this might be the cause of my mix up. Lol

Thanks for the help.

PatrickL started a new conversation Interface Not Found Error In PHP

Hey, so, I am getting this error when running my PHP script.

PHP Fatal error:  Interface 'Javelin\Value\ValueInterface' not found in /Users/PatrickL/Documents/Developer/Javelin/src/Value/Value.php on line 23

It is referring to the following file.

<?php

namespace Domain;

use Javelin\Value\ValueInterface;
use Javelin\Exceptions\IllegalConversionException;

/**--------------------------------------------------------------------------
|
|   Value
|
-----------------------------------------------------------------------------
|
|   A Value represents a Value Object. A Value Object is an object that 
|   represents a descriptive aspect of a domain with no conceptual 
|   identity. Value Objects are instanciated to implement design elements
|   in which we only care about what they are. 
|
-----------------------------------------------------------------------------
*/


abstract class Value implements ValueInterface
{
    // Class definition here.
}

More specifically, line 23 is the following:

abstract class Value implements ValueInterface

For reference, ValueInterface (the interface it cannot find) looks like this.

<?php

namespace Domain; 

/**--------------------------------------------------------------------------
|
|   Value
|
-----------------------------------------------------------------------------
|
|   A Value represents a Value Object. A Value Object is an object that 
|   represents a descriptive aspect of a domain with no conceptual 
|   identity. Value Objects are instanciated to implement design elements
|   in which we only care about what they are. 
|
-----------------------------------------------------------------------------
*/


interface ValueInterface
{
    /**
    * equals() determines if the object is equal to the target
    * @param mixed
    * @return bool
    */

    public function equals($target): bool;
}

?>

And finally, directory structure looks like this:

Javelin
- src
- - Entity
- - Value
- - - Value.php
- - - ValueInterface.php
- <other files and folders>

Any idea on what the issue is? I have a feeling I am not understanding something about namespaces and automatic includes. But, what do you all think?

Thanks for the help.

24 Aug
3 months ago

PatrickL started a new conversation Adding Laravel Generator Artisan Commands To Custom Library

Hey,

I recently made a kind of skeleton library for domain-driven design elements (Entities, Value Objects, Domain Services, etc...). So, what I want to do is include some laravel artisan commands to make generating these templates easier. For example, I want to have a command like the following:

php artisan make:aggregate Customer 

which would then generate a file in the directory Project/App/Aggregates/Customer/Customer.php, containing the template for the Aggregate class, which I already have defined in my Library.

Likewise, I would have a command like:

php artisan make:value Name --path="app/Aggregates/Customer"

Would create a file called Project/app/Aggregates/Customer/Name.php containing the predefined template file for a Value Object that I have previously defined.

I want to be able to include this in my future projects via composer. How would I go about doing this?

Thank you for your help.

12 Aug
3 months ago

PatrickL left a reply on JSON API Format And Laravel

@bobbybouwmann Thanks. This helps a lot.

Would I also be able to check for media type parameters using this same fashion?

Thanks for the help.

10 Aug
3 months ago

PatrickL left a reply on Instantiating Objects

I believe what you need to do is require the autoload file.

require_once(__DIR__ . "/autoloader.php");

// Class instantiation here

PatrickL started a new conversation JSON API Format And Laravel

I am making an API in Laravel that is compliant with the JSON API standard, which can be fund here: http://jsonapi.org/format/

I have two questions though. Both of them have to do with the Server responsibilities section of the spec.

The first question has to do with the following requirement:

"Servers MUST respond with a 415 Unsupported Media Type status code if a request specifies the header Content-Type: application/vnd.api+json with any media type parameters."

My question is how do I check request headers for media types and if they have parameters. (This check will be done using middleware).

My second question is regarding whether or not there is a way to modify responses automatically to include the required metadata in JSON API? Like, instead of adding the necessary media type (Content-Type: application/vnd.api+json) in each and every response, can I just define it in one place and have it automatically added in all my application's API responses? This is not really a requirement. It would just make things easier to modify or update in the future.

Thanks.

PatrickL left a reply on Trigger Notification On Bulk Insert

To bulk insert, you could probably use Database Transactions.


DB::transaction(function() {
    // your insert code here
    
    foreach($appointments as $appointment){
        event(new AppointmentNew($appointment);
    }
}, 5);

Then you can just create the appropriate listener to actually send the notification. I assume you mean a notification sent to the end user when you say "notification".

Also, be sure to make the event queue.

Hope this helps :)

05 Aug
4 months ago

PatrickL started a new conversation Are There Any Widely Accepted Standards For JSON APIs?

I’m building a Laravel App backend, which is intended to provide data to an Angular Front End and, eventually, a Flutter mobile app. As I’m designing this, I start to wonder if there are any widely accepted standards for formatting JSON API responses.

Is there a widely accepted standard? Or, is it more of a do it your own way thing?

Thanks.

04 Aug
4 months ago

PatrickL started a new conversation Checking Scopes In Microservices Using Passport

I have a Microservice-based application I am building. And, I decided to use Passport as an OAuth2 server on my Accounts service. The question I am wondering is how do I verify token scopes within other services (suppose a Posts Service)? Do I need to have Passport installed in every Microservice?

Or is there another way?

Appreciate the help. :)

03 Aug
4 months ago

PatrickL started a new conversation Question About OAuth2 And Microservices

I’m designing an e-Commerce application using a Microservice Architecture (This is my first time building a Microservice based application). After some research, I discover that OAuth is the ideal way of securing microservices.

I find this package that I can use to implement an OAuth Auth server. https://github.com/dusterio/lumen-passport

The thing I’m wondering now has to do with scopes. As shown in this great lecture describing how OAuth2 works: https://youtu.be/996OiexHze0

The Auth Server has a list of pre-defined scopes a client can choose from. Each Microservice then checks the access token they receive with the request to see if they have the right scope (permissions) to perform tasks with the resource.

So, my question is what is the best way for the distinctive microservices to verify scopes?

Do I have have to query the Auth server? Do I just have a list of scopes supported by each Microservice as an array of constants? Or what?

Like, suppose I have an Accounts Microservice (which has the OAuth Auth server) and an Orders Microservice. And the the client application has gone through the code flow and is now requesting to the Order service that an order be placed.

How does the Order service verify that the client has the right scope?

Thanks for the help.

31 Jul
4 months ago

PatrickL left a reply on Misunderstanding Of Composer Autoloading

@lostdreamer_nl Fixed. Thank you for the help :)