Giter Site home page Giter Site logo

Comments (4)

kadeprice avatar kadeprice commented on September 26, 2024

That's how it was with the L4 Generator. I assume the script knows it's a new line because there is a space. You can't do it on the comma because then this wouldn't work
--schema="amount:double(15,2), customer_id:integer:index, customer_id:foreign:references('id'):on('customers'):onDelete('cascade')"

It would start a new line at (15,2). So the space is how it knows to start a new column.

from laravel-5-generators-extended.

 avatar commented on September 26, 2024

Yeah - it's tough. I need some kind of split point for the regular expression. I've spent a lot of time trying to find a way to make this optional, but no dice.

The primary issue is that you can do:

--schema="username:string, age:integer"

If it were just this, then we could make the ,[space] optional. But the user can also pass arguments:

--schema="username:string, amount:decimal(1,2)

So, if somebody knows how to split that up into chunks, while allowing no spaces between each field:column, please do let me know. I haven't been able to figure out how.

The regex would need to give me, using the example above, an array with two items:

  • username:string
  • amount:decimal(1,2)

from laravel-5-generators-extended.

BrandonSurowiec avatar BrandonSurowiec commented on September 26, 2024

I did some searching and found how to separate using commas, as long as they weren't in parenthesis. Did some testing and this works for me:

$preg_split = preg_split('/,(?![^()]*+\\))/', $schema);
return array_map("trim", $preg_split);

I had to run trim on the array to get rid of the spaces that may appear in front when using commas and spaces.

[ I added a pull request: https://github.com//pull/9 ]

from laravel-5-generators-extended.

 avatar commented on September 26, 2024

So this is fixed and merged now.

Thanks, all.

from laravel-5-generators-extended.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.