yanmarques / lincable Goto Github PK
View Code? Open in Web Editor NEWStorage link generator for laravel Eloquent
Home Page: https://yanmarques.github.io/lincable
License: MIT License
Storage link generator for laravel Eloquent
Home Page: https://yanmarques.github.io/lincable
License: MIT License
Lincable\Http\FileRequest
to FileResolver.After cloning the model, the url is starting with a slash, but this invalidates the url when building the full url from file.
As the new implementation on UrlCompiler (#7), the parser can be null, but shouldn't.
Rethink FileRequest class to extend from Illuminate\Foundation\Http\FormRequest
gaining ability to:
Lincable trait is used by the model for linking. For now we only give support for instances of the Lincable\Http\FileRequest
.
We could give support for:
Symfony\Component\HttpFoundation\File\File
When the link is not present on model attributes, a LinkNotFoundException
like this:
"Model [{static::class}] does not a file linked with."
Build failing: #15
Seems like has a mistake type received from method convertCase
on trait, it is receiving string but should received an object too.
$ ./vendor/bin/phpunit
PHPUnit 7.3-g2742185 by Sebastian Bergmann and contributors.
Runtime: PHP 7.1.16-1+ubuntu16.04.1+deb.sury.org+1
Configuration: /home/yanmarques/Documents/Projects/lincable/phpunit.xml
..............E.E............. 30 / 30 (100%)
Time: 74 ms, Memory: 4.00MB
There were 2 errors:
1) Tests\Lincable\Parsers\ParserTest::testThatAddFormattersAddAnArray
TypeError: Argument 1 passed to Lincable\Parsers\Parser::convertCase() must be of the type string, object given, called in /home/yanmarques/Documents/Projects/lincable/src/Lincable/Concerns/BuildClassnames.php on line 26
/home/yanmarques/Documents/Projects/lincable/src/Lincable/Concerns/BuildClassnames.php:105
/home/yanmarques/Documents/Projects/lincable/src/Lincable/Concerns/BuildClassnames.php:26
/home/yanmarques/Documents/Projects/lincable/src/Lincable/Parsers/Parser.php:68
/home/yanmarques/Documents/Projects/lincable/src/Lincable/Parsers/Parser.php:107
/home/yanmarques/Documents/Projects/lincable/src/Lincable/Parsers/Parser.php:108
/home/yanmarques/Documents/Projects/lincable/tests/Parsers/ParserTest.php:35
2) Tests\Lincable\Parsers\ParserTest::testThatParseReturnsFoo
TypeError: Argument 1 passed to Lincable\Parsers\Parser::convertCase() must be of the type string, object given, called in /home/yanmarques/Documents/Projects/lincable/src/Lincable/Concerns/BuildClassnames.php on line 26
/home/yanmarques/Documents/Projects/lincable/src/Lincable/Concerns/BuildClassnames.php:105
/home/yanmarques/Documents/Projects/lincable/src/Lincable/Concerns/BuildClassnames.php:26
/home/yanmarques/Documents/Projects/lincable/src/Lincable/Parsers/Parser.php:68
/home/yanmarques/Documents/Projects/lincable/tests/Parsers/ParserTest.php:63
ERRORS!
Tests: 30, Assertions: 28, Errors: 2.
Change the readme file to be updated with new package releases.
Add a method on model to use the linked file, applying changes and linking it to model again.
Installing the package with composer runs into error.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for yanmarques/lincable ^0.9.0 -> satisfiable by yanmarques/lincable[v0.9].
- yanmarques/lincable v0.9 requires league/flysystem ^1.1@dev -> satisfiable by league/flysystem[1.1.x-dev] but these conflict with your requirements or minimum-stability.
When injecting the file request as argument on controller action, the container will resolve the class instance, but does not boot the object with the current request.
A way to workaround this is add a request argument on file request constructor and boot the it with the request, as the container will resolve the request class. Something like:
use Lincable\Http\FileRequest;
class ImageFileRequest extends FileRequest
{
public function __construct(Request $request)
{
$this->boot($request);
}
}
The correct thing should add a function to automatically boot the file request when resolving a file request instance, we can use the container events for this.
Something like:
'urls' => [
'foo' => 'baz/:uuidV1'
]
Instead of saving the full path to file on storage we just save the relative path to it, and use mutators to build the full url when retriving from model.
set
implementation of the repository should imperative set a key to a given value.Add an helper function to determine wheter the given url has dynamic parameters for the parser.
public function hasDynamics(string $url): bool;
When resolving the FileRequest class on FileResolver, should check wheter is booted, if not, should boot with the request current instance.
The Compiler implementation receives a Parser instance on constructor. But it should also receive null
when creating dummy compilers, that can change the parser in runtime execution.
My last commit 5e9840e that add tests for Lincable\Http\FileRequest
class fails on file validation. The file I commited is failing on some debug code I forgot to remove. This is actual exception and the dump is the errors message:
➜ lincable git:(dev) ./vendor/bin/phpunit
PHPUnit 7.3-gc17423b by Sebastian Bergmann and contributors.
Runtime: PHP 7.1.16-1+ubuntu16.04.1+deb.sury.org+1
Configuration: /home/yanmarques/Documents/Projects/lincable/phpunit.xml
.....E.................................. 40 / 40 (100%)
Time: 78 ms, Memory: 6.00MB
There was 1 error:
1) Tests\Lincable\Http\FileRequest::testThatBootSetTheRequestAndGetFileFromRequest
Illuminate\Validation\ValidationException: The given data was invalid.
/home/yanmarques/Documents/Projects/lincable/vendor/illuminate/validation/Validator.php:306
/home/yanmarques/Documents/Projects/lincable/vendor/illuminate/validation/Factory.php:136
/home/yanmarques/Documents/Projects/lincable/tests/Http/FileRequestTest.php:109
/home/yanmarques/Documents/Projects/lincable/vendor/illuminate/support/Traits/Macroable.php:107
/home/yanmarques/Documents/Projects/lincable/src/Lincable/Http/FileRequest.php:138
/home/yanmarques/Documents/Projects/lincable/src/Lincable/Http/FileRequest.php:61
/home/yanmarques/Documents/Projects/lincable/tests/Http/FileRequestTest.php:33
ERRORS!
Tests: 40, Assertions: 40, Errors: 1.
➜ lincable git:(dev) ✗ ./vendor/bin/phpunit
PHPUnit 7.3-gc17423b by Sebastian Bergmann and contributors.
Runtime: PHP 7.1.16-1+ubuntu16.04.1+deb.sury.org+1
Configuration: /home/yanmarques/Documents/Projects/lincable/phpunit.xml
.....array(1) {
["foo"]=>
array(1) {
[0]=>
string(19) "validation.uploaded"
}
}
Just looking up the code I found that the mimes
validation also checks wheter the file was uploaded with PHP request. I need to find a way to send fake file on request and make the it be validated and stored (fake).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.