0

I migrated my laravel app from 4 to 5 and i am having an issue with this query:

$ids = AssetCustomTag::whereIn('custom_tag_id', $custom)->lists('asset_id')->all();

where $custom is an array of ids.

The error thrown from laravel is this one.

Declaration of AssetCustomTag::create(array $input) should be compatible with Illuminate\Database\Eloquent\Model::create(array $attributes = Array)

Not sure what that means as I am very new to laravel.

This is the create method. What do i need to do to it?

public static function create(array $input)
{
    $name = $input['name'];
    $account_id = $input['account_id'];
    ...
    ....
    return $tag;
}
Leon
  • 1,262
  • 3
  • 20
  • 41
  • It looks like you wrote a `create()` method in your `AssetCustomTag` model? That's where your error is coming from. Maybe post that? – jszobody Sep 28 '16 at 20:30
  • Why would the create method even be called in there? – Leon Sep 28 '16 at 20:32
  • It probably isn't getting called. PHP strict standards are requiring that you make your method signature compatible with the parent class nonetheless. – jszobody Sep 28 '16 at 20:34
  • See here for a quick example: https://3v4l.org/DI6ia. Notice I'm never calling the `foo()` method, but PHP is complaining anyway. – jszobody Sep 28 '16 at 20:36
  • I just added create method, how show i implement it? – Leon Sep 28 '16 at 20:37
  • You probably don't want to add your own `create()` method at all. Typically not needed. You likely need to rethink your whole approach, update your question and explain what you're trying to accomplish. – jszobody Sep 28 '16 at 20:38
  • I fixed it. `public static function create(array $input = [])` did the trick – Leon Sep 28 '16 at 20:39
  • Yes, you made the signature match. That will get rid of this specific error, but you're setting yourself for other problems. Go read through the Eloquent docs, looks at the examples, I don't think you want your own `create` method, rarely a good idea. – jszobody Sep 28 '16 at 20:40
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/124468/discussion-between-leon-and-jszobody). – Leon Sep 28 '16 at 20:41

0 Answers0