Hello. I'm starting using lumen and laravel, but I got problem with Intelephense Autocomplete, The Model that's extends doesn't show static where and other function that's supported by the model, can you make it shown on the intelephense? Because I'm using intelephense and really heavy user of it, I nearly can't work without autocomplete.
see https://laravel.com/docs/5.8/eloquent#retrieving-models
Thanks
The MHUser.php
<?php
namespace App\Models\API;
use Illuminate\Database\Eloquent\Model;
class MHCustomer extends Model
{
/**
* This is the default basic settings of the Model
*/
protected $primaryKey = 'nomor';
protected $table = "mhcustomer";
public $timestamps = false;
public $incrementing = true;
}
foo.php
use App\Models\API\MHUser;
$data = MHCustomer::where("foo", "=", "bar"); // The where won't autocomplete
You're defining MHCustomer, but you're trying to use MHUser is this intentional mismatch?
You're defining
MHCustomer, but you're trying to useMHUseris this intentional mismatch?
Oh Sorry it's MHCustomer.
From what I found where is handled by ___callStatic, but there isn't @method describing static functions, thus extension has no way of knowing about that method.
Eloquent has a lot of __call and __call_static which obscures which methods are available. Are you using any stub files like https://github.com/barryvdh/laravel-ide-helper ? Note that @mixin is not currently supported when using the linked stubs.
Eloquent has a lot of
__calland__call_staticwhich obscures which methods are available. Are you using any stub files like https://github.com/barryvdh/laravel-ide-helper ? Note that@mixinis not currently supported when using the linked stubs.
So I just need to install it and IT will automatically add helper?
@benyaminl , not quite. Your models must extend \Eloquent if you are using the helper I linked to.
Below is the Illuminate\Database\Eloquent\Model specific part renamed the same as the actual class ie Illuminate\Database\Eloquent\Model instead of Eloquent. Dropping this in your project should also work without having to extend a different class.
@benyaminl , not quite. Your models must extend
\Eloquentif you are using the helper I linked to.Below is the
Illuminate\Database\Eloquent\Modelspecific part renamed the same as the actual class ieIlluminate\Database\Eloquent\Modelinstead ofEloquent. Dropping this in your project should also work without having to extend a different class.
I put it on Laravel Folder? Replace the laravel one?
No, they are stubs, not real code.
No, they are stubs, not real code.
Oh So I just need to add it and rename as .php and the autocomplete with automatically shown?
Will your Intelephense support php strom meta file?
Eloquent has a lot of
__calland__call_staticwhich obscures which methods are available. Are you using any stub files like https://github.com/barryvdh/laravel-ide-helper ? Note that@mixinis not currently supported when using the linked stubs.
Anyway I have tried this, It's not working to autocomplete on Intelephense, the model doesn't show ::where.
When will @mixin supported sir ? @bmewburn
Okay Waiting for https://github.com/bmewburn/vscode-intelephense/issues/123
@benyaminl , not quite. Your models must extend
\Eloquentif you are using the helper I linked to.Below is the
Illuminate\Database\Eloquent\Modelspecific part renamed the same as the actual class ieIlluminate\Database\Eloquent\Modelinstead ofEloquent. Dropping this in your project should also work without having to extend a different class.
Not working on Lumen btw. It need the eloquent stub that you give to me. The _ide_helper.php that the barrys extension generate doesn't refrence any of it.
Yep I tried fresh laravel and only work on Laravel. Uhm..
I don't think there's anything further to add here.
To summarise:
__call and __call_static.@mixin or to extend \Eloquent when creating models.@mixin is currently not supported by this extension and is being tracked in #123. Extending \Eloquent is the recommended approach when using the above helper and this extension.Thanks you I'll be waiting for it. Also if possible for PHPstrom meta file that also generated. Thanks.
On October 8, 2019 5:13:18 PM GMT+07:00, Ben Mewburn notifications@github.com wrote:
I don't think there's anything further to add here.
To summarise:
- Some methods are not suggested with Laravel/Lumen because they use
__calland__call_static.- To get suggestions an ide helper is needed like
https://github.com/barryvdh/laravel-ide-helper which generates/adds
stubs or helper classes to your project. It has a detailed readme on
how to install and use.- The above ide helper suggests adding
@mixinor to extend
\Eloquentwhen creating models.@mixinis currently not supported by this extension and is being
tracked in #123. Extending\Eloquentis the recommended approach when
using the above helper and this extension.--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/bmewburn/vscode-intelephense/issues/708#issuecomment-539447683
--
Sent from my ASUS Pegasus X005 with K-9 Mail.
PHPStorm meta overrides are supported. PHPStorm meta expected arguments is tracked in #471
I use eloquent without laravel. Hard to guess how to install ide-helper in that case.
I use eloquent without laravel. Hard to guess how to install ide-helper in that case.
hahahahaa.... * I laugh very hard on this case *
@bmewburn
When you install it will install all laravel dependencies https://github.com/barryvdh/laravel-ide-helper/blob/master/composer.json#L14-L16
"illuminate/support": "^5.5|^6|^7",
"illuminate/console": "^5.5|^6|^7",
"illuminate/filesystem": "^5.5|^6|^7",
I think you need to call the function manually I guess. the generate function
I use eloquent without laravel. Hard to guess how to install ide-helper in that case.
hahahahaa.... * I laugh very hard on this case *
https://www.cloudways.com/blog/eloquent-illuminate-in-php-without-laravel/
@Serhioromano , you could grab the generated eloquent stub from here and just rename it to whatever class your models extend. https://gist.github.com/barryvdh/5227822#file-_ide_helper-php-L12166
I use eloquent without laravel. Hard to guess how to install ide-helper in that case.
hahahahaa.... * I laugh very hard on this case *
https://www.cloudways.com/blog/eloquent-illuminate-in-php-without-laravel/
I know it support outside laravel, what I'm talking about is when we install the ide-Helper, I don't know how to generate the Helper file if it's not laravel project sir. It's just a joke.
Oh mighty @benyaminl, I am glad that I made you laugh! Dumb people are funny, aren't they?
@bmewburn Thank you. I did. Now models do have to autocomplete. Only one thing is left. When I use $this->db = $capsule class to run something like $this-db->raw('SHOW TABLES'), it does not show autocomplete. In my class property, I define it as
/**
* @var \Illuminate\Database\Capsule\Manager
*/
public $db;
Because this is what I use to create $capsule. But I think I have to point to another class because this class does not have those functions inside.
No I mean I myself don't know how to access it so I mean for myself, how to
access it. Just it. I'm not looking down on other people. Sorry if seems
that I looking down to other people. I just thinking that it won't be
possible to generate the auto complete for the model, if we only use
_ide_helper.php.
Regards,
Benyamin Limanto
sent from my Sony XPERIA XZ Premium
On Mon, Mar 2, 2020, 15:16 Sergey Romanov notifications@github.com wrote:
Oh mighty @benyaminl https://github.com/benyaminl, I am glad that I
made you laugh! Dumb people are funny, aren't they?@bmewburn https://github.com/bmewburn Thank you. I did. Now models do
have to autocomplete. Only one thing is left. When I use $this->db =
$capsule class to run something like $this-db->raw('SHOW TABLES'), it
does not show autocomplete. In my class property, I define it as/** * @var \Illuminate\Database\Capsule\Manager */public $db;
Because this is what I use to create $capsule. But I think I have to point
to another class because this class does not have those functions inside.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bmewburn/vscode-intelephense/issues/708?email_source=notifications&email_token=AAVP2NGY25D46Z5VW3RRUDLRFNTMXA5CNFSM4I5XDV42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENOKWEQ#issuecomment-593275666,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAVP2NDS52ZWFLYRQXNBZGTRFNTMXANCNFSM4I5XDV4Q
.
I just took eloquent.php.txt file that was linked here and saved in project root as eloquent.php. that is it. Now I have models autocomplete.
For whereFoo(1)
Does it works?
Like whereActiveStatus(1). It won't complete right?
Regards,
Benyamin Limanto
sent from my Sony XPERIA XZ Premium
On Mon, Mar 2, 2020, 15:23 Sergey Romanov notifications@github.com wrote:
I just took eloquent.php.txt file that was linked here and saved in
project root as eloquent.php. that is it. Now I have models autocomplete.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bmewburn/vscode-intelephense/issues/708?email_source=notifications&email_token=AAVP2NHB62UJMN54Y6QJ2TDRFNUIRA5CNFSM4I5XDV42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENOLLTI#issuecomment-593278413,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAVP2NBGM4ENB6J36K3O2WDRFNUIRANCNFSM4I5XDV4Q
.
I found following solution.
Instead of, e.g:
$post = Post::where('slug', $slug)->firstOrFail();
try to
$post = Post::query()->where('slug', $slug)->firstOrFail();
`
I found following solution.
Instead of, e.g:
$post = Post::where('slug', $slug)->firstOrFail();
try to
$post = Post::query()->where('slug', $slug)->firstOrFail();`
I use this one now, It works well on development env.
Eloquent has a lot of
__calland__call_staticwhich obscures which methods are available. Are you using any stub files like https://github.com/barryvdh/laravel-ide-helper ? Note that@mixinis not currently supported when using the linked stubs.
Not on non lumen/laravel package.
Most helpful comment
Eloquent has a lot of
__calland__call_staticwhich obscures which methods are available. Are you using any stub files like https://github.com/barryvdh/laravel-ide-helper ? Note that@mixinis not currently supported when using the linked stubs.