eloquence-mappable icon indicating copy to clipboard operation
eloquence-mappable copied to clipboard

Problems with columns mapping

Open pvm opened this issue 6 years ago • 7 comments

Hi,

I have issuing some problems with column mapping.

Example with dynamic where: Foo::whereId(1);

Example with where: Foo::where([ ['foo', '=', 'bar'] ])->first();

the mapping is not working. The query is generated with old column name.

Model:

`class Foo extends Model { use Eloquence, Mappable;

protected $maps = [
    // ....
];

}`

pvm avatar Jun 14 '18 15:06 pvm

@jarektkaczyk any news?

pvm avatar Jun 20 '18 18:06 pvm

@pvm - Jarek's Eloquence repos aren't heavily-maintained. However, in my view these vanity functions aren't tremendously important.

I.e: MyModel::whereTheValue(100) vs. MyModel::where('the_value', 100), where the latter works and is equally readable; you could argue it is more so than the former.

jsdtaylor avatar Jun 22 '18 15:06 jsdtaylor

@pvm do I get it right that dynamic wheres don't work for you? Or both examples you provided?

If the first is true, then I just strongly suggest not using dynamic wheres - they are very bad concept and lead to issues.

@jsdtaylor thanks for chiming in. True, I don't have much time for maintenance, and will be more than happy to share this responsibility with others :)

jarektkaczyk avatar Jun 23 '18 06:06 jarektkaczyk

Just saying that dynamic where does not work, but where with multiple options too (this we use a lot):

Foo::where([ ['foo', '=', 'bar'], ['baz', '>=', 2]])->first();

pvm avatar Jun 23 '18 17:06 pvm

@jarektkaczyk any news about it? If you don't have time, I'll try to help and send you a PR.

pvm avatar Jul 10 '18 17:07 pvm

@pvm would be lovely :+1:

jarektkaczyk avatar Jul 11 '18 01:07 jarektkaczyk

only select support? when I use get($columns) or first($columns), the mapping is not working

1x481n avatar Aug 06 '18 07:08 1x481n