Skip to content

Source and Source Types

Alfred Nutile edited this page May 8, 2023 · 8 revisions

Source Model

These get attached to the Model

And example is the app/Source/Types/WebFile.php file.

This will get called here app/Models/Source.php:40

    /**
     * @throws SourceTypeMissingException
     */
    public function run()
    {
        $statusType = $this->type->label();
        try {
            app("App\Source\Types\\".$statusType, [
                'source' => $this,
            ])->handle();
        } catch (\Exception $e) {
            logger($e);
            throw new SourceTypeMissingException();
        }
    }

Then it will get the file and download it.

You can put your own types in here as long as the extend the BaseSourceType

Order Field

This field will be used if there are multiple sources and they need to be batched

Type Field

This is cast to app/Source/SourceTypeEnum.php:5 see more below.

MetaData Field

Encrypted array cast field to hold needing config data for the different source types

Source Types

You can see the types in app/Source/SourceTypeEnum.php

Any thing in the app/Source/Types folder can then be used as a type.

There is a meta_data field that it is encrypted. Depending on the type will be expected fields.

Types

WebFile

This is ready to use, point it to a url with a web file and it will download it.

You can see in database/factories/SourceFactory.php:40

[
    'type' => SourceTypeEnum::WebFile,
    'meta_data' => [
      'url' => 'https://wikipedia.com/foo.pdf',
      'username' => 'foo',
      'password' => 'bar',
      'auth' => 'basic',
  ],
];

WebUpload [COMING SOON]

WebUpload Source that will then make a UI in LaraChain for the user to use

Web [COMING SOON]

Simple example of getting a web page for later transformation

S3Dir [COMING SOON]

Get files from S3 Dir

TODO

  • Get Basic Auth Setup
  • Get Bearer Auth Setup