You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Eloquent ouside Laravel, and I found this useful package. In composer.json there are no dependency on the laravel framework, only on illuminate/support, but in Cloneable.php there's a dependency on App which i think is a reference to illuminate/foundation:
/** * Clone the current model instance * * @return Illuminate\Database\Eloquent\Model The new, saved clone */publicfunctionduplicate() {
return App::make('cloner')->duplicate($this);
}
/** * Clone the current model instance to a specific Laravel database connection * * @param string $connection A Laravel database connection * @return Illuminate\Database\Eloquent\Model The new, saved clone */publicfunctionduplicateTo($connection) {
return App::make('cloner')->duplicateTo($this, $connection);
}
It would be good if we could remove that dependency, as then this package would be usable outside laravel. I'm willing to provide a PR but I'm not familiar with laravel's dependency resolver, but maybe we could replace it with something like
I think yes. Laravel's helper resolve function resolves a given class or interface name to its instance using the service container (doc).
That function only calls another helper, app with the class name and without parameters, which calls directly Container::getInstance()so I think it's safe to use that:
/** * Get the available container instance. * * @param string $abstract * @param array $parameters * @return mixed|\Illuminate\Foundation\Application */functionapp($abstract = null, array$parameters = [])
{
if (is_null($abstract)) {
return Container::getInstance();
}
returnempty($parameters)
? Container::getInstance()->make($abstract)
: Container::getInstance()->makeWith($abstract, $parameters);
}
Hi,
I'm using Eloquent ouside Laravel, and I found this useful package. In
composer.json
there are no dependency on the laravel framework, only onilluminate/support
, but inCloneable.php
there's a dependency onApp
which i think is a reference toilluminate/foundation
:It would be good if we could remove that dependency, as then this package would be usable outside laravel. I'm willing to provide a PR but I'm not familiar with laravel's dependency resolver, but maybe we could replace it with something like
I'm overloading the
duplicate()
function of theCloneable
trait and it seems to work correctly.Also there's a dependency on
illuminate\events
that should be added tocomposer.json
The text was updated successfully, but these errors were encountered: