squirephp / squire Goto Github PK
View Code? Open in Web Editor NEWA library of static Eloquent models for common fixture data.
License: MIT License
A library of static Eloquent models for common fixture data.
License: MIT License
Describe the bug
Every squire model overrides the $sqliteConnection property when it's booted.
Every model ends up with the database path of the last model that loaded.
To reproduce
new Squire\Models\Country;
new Squire\Models\Currency;
Squire\Models\Country::all()
Will throw an exception, since $sqliteConnection
is set to the Currency
model connection.
Illuminate\Database\QueryException with message 'SQLSTATE[HY000]: General error: 1 no such table: countries (SQL: select * from "countries")'�
This is a sample PHP code to show the logic in action:
<?php
class A {
protected static $v;
public static function set($v) { static::$v = $v; }
public static function get() { return static::$v; }
}
class B extends A {}
class C extends A {}
B::set('B');
C::set('C');
echo B::get();
echo C::get();
Will output two CC
instead of the expected BC
.
The same behavior is impacting the static $sqliteConnection
property in all classes that extend Squire\Model
.
The best solution is to set the $sqliteConnection
in every model class, or to convert it to a map.
Expected behavior
Separate models should have different database connections.
Context
Describe the bug
Installed the package then when I was going to use it in the blade that time I got this error.
To reproduce
@foreach (Squire\Models\Country::orderBy('name')->get() as $country) <option value="{{ $country->id }}">{{ $country->name }} {{ $country->flag }}</option> @endforeach
Expected behavior
All country list
Context
Additional details
Did I skip any steps?
Describe the bug
Unable to find source when using extended Country model.
To reproduce
namespace App\Models;
use Squire\Models\Country as SquireCountry;
class Country extends SquireCountry
{
public function users()
{
return $this->hasMany(User::class);
}
}
Call
App\Models\Country::all();
Expected behavior
Expected to show all countries
Context
Additional details
Add any other details about the problem here.
Describe the bug
Squire\Models\Airline::continent(): Return value must be of type Illuminate\Database\Eloquent\Relations\BelongsTo, Illuminate\Database\Eloquent\Relations\HasOneThrough returned
SQLSTATE[HY000]: General error: 1 no such table: countries
To reproduce
Expected behavior
No Error
Context
Additional details
I'm just checking out all the model with relations.. I install all of them (only english -en
) and check base on readme file
All model have use Squire\Models\ModelName
The Illuminate\Foundation\Application::getFallbackLocale()
method does not exist prior to Laravel 7.21. An expression such as
Squire\Models\Country::select(['id', 'name'])->get();
throws the following exception:
PHP Error: Call to undefined method Illuminate/Foundation/Application::getFallbackLocale() in ... /vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 261
Requesting a fix to accommodate Laravel versions prior to 7.12, since there are still a lot of projects out there on v6.x (including mine).
A quick and easy fix would be to grab the fallback locale directly from the config array instead of using the facade:
Change to
$appFallbackLocale = config('app.fallback_locale');
I'll buy you a virtual beer if you can turn this around quickly (the boss is anxious).
Thanks for your excellent package.
Describe the bug
There is a trailing space at the end of the country Bonaire, Saint Eustatius and Saba
so that is displays as "Bonaire, Saint Eustatius and Saba "
To reproduce
Pull in the code and view the country above, notice the extra space that appears at the end.
Expected behavior
No trailing spaces in countries.
Context
squirephp/countries-en
v2.0.5
8.25.0
8.0
Additional details
Looks like its in the CSV file
Describe the bug
When I run command "composer require squirephp/currencies" to install it returns error (see screenshots)
To reproduce
A simplified code example to demonstrate the issue you are facing.
Expected behavior
A clear and concise description of what you expected to happen.
Context
Describe the bug
I've asked this repo discussion forum but no one has been able to answer. In the documentation squire/model is able to manage relationships with eloquent models. I've tried it and it works. But if the squire/model relation is inserted in the eloquent model, it seems that this package doesn't support relations belongsToMany
yet
To reproduce
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Squire\Model;
class Feature extends Model
{
...
public function permissions() : BelongsToMany
{
return $this->belongsToMany(Permission::class);
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Permission extends Model
{
public function features() : BelongsToMany
{
return $this->belongsToMany(Feature::class);
}
}
# migrations
Schema::create('feature_permission', function (Blueprint $table) {
$table->unsignedBigInteger('permission_id');
$table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
$table->unsignedBigInteger('feature_id');
$table->primary(['permission_id', 'feature_id']);
});
Expected behavior
# Get all features with permissions
$features = Feature::with('permissions')->get();
response:
- ok
# Get all permissions with features
$permissions = Permission::with('features')->get();
response:
"message": "SQLSTATE[HY000]: General error: 1 no such table: feature_permission (SQL: select \"features\".*, \"feature_permission\".\"permission_id\" as \"pivot_permission_id\", \"feature_permission\".\"feature_id\" as \"pivot_feature_id\" from \"features\" inner join \"feature_permission\" on \"features\".\"id\" = \"feature_permission\".\"feature_id\" where \"feature_permission\".\"permission_id\" in (1, 2))",
"exception": "Illuminate\\Database\\QueryException"
Context
Additional details
Can anyone provide a solution regarding this problem? So that I can decide for now, whether to use this package or not.
Thank you.
Describe the bug
I have a model with table located in mysql database and that model belong to currency as shown below:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Squire\Models\Currency;
class Product extends Model
{
public function currency()
{
return $this->belongsTo(Currency::class);
}
}
To reproduce
Make a job that contains a call of currency model for example.
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
class NewProduct extends Notification implements ShouldQueue
{
use Queueable;
public function via($notifiable)
{
return ['database'];
}
public function toArray($notifiable)
{
echo $this->product->currency;
}
}
Expected behavior
The job should executed as normal jobs
Context
Additional details
[2022-10-17 23:22:02] local.ERROR: Undefined array key "Squire\Models\Currency" {"exception":"[object] (ErrorException(code: 0): Undefined array key \"Squire\\Models\\Currency\" at /Users/username/Code/php/laravel/org/project/vendor/squirephp/squire/packages/model/src/Model.php:159) [stacktrace] #0 /Users/username/Code/php/laravel/org/project/vendor/squirephp/squire/packages/model/src/Model.php(159): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'Undefined array...', '/Users/username/C...', 159) #1 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1619): Squire\\Model::resolveConnection('mysql') #2 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1425): Illuminate\\Database\\Eloquent\\Model->getConnection() #3 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1342): Illuminate\\Database\\Eloquent\\Model->newBaseQueryBuilder() #4 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1378): Illuminate\\Database\\Eloquent\\Model->newModelQuery() #5 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1331): Illuminate\\Database\\Eloquent\\Model->newQueryWithoutScopes() #6 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php(218): Illuminate\\Database\\Eloquent\\Model->newQuery() #7 /Users/username/Code/php/laravel/org/project/packages/PCsoft/PIM/Models/Product.php(169): Illuminate\\Database\\Eloquent\\Model->belongsTo('Squire\\\\Models\\\\C...') #8 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(690): PCsoft\\PIM\\Models\\Product->currency() #9 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(106): Illuminate\\Database\\Eloquent\\Builder->Illuminate\\Database\\Eloquent\\{closure}() #10 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(694): Illuminate\\Database\\Eloquent\\Relations\\Relation::noConstraints(Object(Closure)) #11 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(662): Illuminate\\Database\\Eloquent\\Builder->getRelation('currency') #12 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(642): Illuminate\\Database\\Eloquent\\Builder->eagerLoadRelation(Array, 'currency', Object(Closure)) #13 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(597): Illuminate\\Database\\Eloquent\\Builder->eagerLoadRelations(Array) #14 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php(102): Illuminate\\Database\\Eloquent\\Model->load(Array) #15 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php(57): Illuminate\\Notifications\\Notification->restoreModel(Object(Illuminate\\Contracts\\Database\\ModelIdentifier)) #16 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/SerializesModels.php(122): Illuminate\\Notifications\\Notification->getRestoredPropertyValue(Object(Illuminate\\Contracts\\Database\\ModelIdentifier)) #17 [internal function]: Illuminate\\Notifications\\Notification->__unserialize(Array) #18 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(97): unserialize('O:48:\"Illuminat...') #19 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(253): Illuminate\\Queue\\CallQueuedHandler->getCommand(Array) #20 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(213): Illuminate\\Queue\\CallQueuedHandler->failed(Array, Object(ErrorException), 'cd9349eb-1b4e-4...') #21 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(192): Illuminate\\Queue\\Jobs\\Job->failed(Object(ErrorException)) #22 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(581): Illuminate\\Queue\\Jobs\\Job->fail(Object(ErrorException)) #23 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(527): Illuminate\\Queue\\Worker->failJob(Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(ErrorException)) #24 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(455): Illuminate\\Queue\\Worker->markJobAsFailedIfWillExceedMaxAttempts('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), 1, Object(ErrorException)) #25 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(432): Illuminate\\Queue\\Worker->handleJobException('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(Illuminate\\Queue\\WorkerOptions), Object(ErrorException)) #26 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(378): Illuminate\\Queue\\Worker->process('redis', Object(Illuminate\\Queue\\Jobs\\RedisJob), Object(Illuminate\\Queue\\WorkerOptions)) #27 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(172): Illuminate\\Queue\\Worker->runJob(Object(Illuminate\\Queue\\Jobs\\RedisJob), 'redis', Object(Illuminate\\Queue\\WorkerOptions)) #28 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(117): Illuminate\\Queue\\Worker->daemon('redis', 'fcm:send', Object(Illuminate\\Queue\\WorkerOptions)) #29 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\\Queue\\Console\\WorkCommand->runWorker('redis', 'fcm:send') #30 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Queue\\Console\\WorkCommand->handle() #31 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #32 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure)) #33 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure)) #34 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL) #35 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call(Array) #36 /Users/username/Code/php/laravel/org/project/vendor/symfony/console/Command/Command.php(298): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #37 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle)) #38 /Users/username/Code/php/laravel/org/project/vendor/symfony/console/Application.php(1028): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #39 /Users/username/Code/php/laravel/org/project/vendor/symfony/console/Application.php(299): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #40 /Users/username/Code/php/laravel/org/project/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #41 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #42 /Users/username/Code/php/laravel/org/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #43 /Users/username/Code/php/laravel/org/project/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput)) #44 {main} "}
Describe the bug
I got this error on installing the squirephp/currencies-en
package :
$ composer require squirephp/currencies-en
./composer.json has been updated
Running composer update squirephp/currencies-en --with-all-dependencies
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- squirephp/currencies-en v3.4.1 requires squirephp/currencies v3.4.1 -> satisfiable by squirephp/currencies[v3.4.1].
- squirephp/currencies-en[v2.0.1, ..., v2.3.2] require illuminate/support ^6.0 || ^7.0 || ^8.0 -> found illuminate/support[v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
- squirephp/currencies-en[v3.0.0, ..., v3.2.1] require illuminate/support ^8.0 -> found illuminate/support[v8.0.0, ..., v8.83.27] but these were not loaded, likely because it conflicts with another require.
- squirephp/currencies-en[v3.3.0, ..., v3.3.1] require illuminate/support ^8.0|^9.0 -> found illuminate/support[v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.10] but these were not loaded, likely because it conflicts with another require.
- squirephp/currencies-en v3.4.0 requires squirephp/repository v3.4.0 -> found squirephp/repository[v3.4.0] but these were not loaded, likely because it conflicts with another require.
- squirephp/currencies v3.4.1 requires akaunting/laravel-money ^1.2|^2.1 -> found akaunting/laravel-money[1.2.0, 1.2.1, 1.2.2, 1.2.3, 2.1.0] but it conflicts with your root composer.json require (^4.0).
- Root composer.json requires squirephp/currencies-en * -> satisfiable by squirephp/currencies-en[v2.0.1, ..., v2.3.2, v3.0.0, ..., v3.4.1].
Context
Additional details
I also tried the recommended commands by composer :
composer require squirephp/currencies-en -W
composer require squirephp/currencies-en:*
composer require squirephp/currencies-en:* -W
Same result.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.