appstract / laravel-options Goto Github PK
View Code? Open in Web Editor NEWGlobal key-value store in the database
License: MIT License
Global key-value store in the database
License: MIT License
The database column value
needs to be changed to json
Great idea, but get inspiration at https://github.com/edvinaskrucas/settings
Hi there,
Thanks for maintaining this package - I've found it really useful over the years.
I have the need to cache option lookups in the app I'm working on at the moment - and it's not hard to DIY. But I wondered if there was still any appetite to add it into the package itself. I can see a previous discussion #24 and a PR attempted, but I was thinking of something much simpler - either an extra $cacheSeconds
parameter to the option/get code - or just a new getCached()
method to be more explicit.
replicate:
Option('testing' array());
return Option('testing');
How Can I Change Type Key From Varchar To Text?
It would be nice if we could use the exists
method via the helper function, as follows:
option()->exists("key")
This would be better than relying on the alias.
It would be cool if you would be able to store key/value pairs by user so just add the user id to the table and make the option-function only getting the value by key and user.
Hi,
I'm having this problem when updating with composer update with composer install no problem.
Thxs!
Declaration of Appstract\Options\Option::delete($key) should be compatible with Illuminate\Database\Eloquent\Model::delete()
I have continued to investigate, the error appears when I updated your package to 1.1.0
"require": {
"php": "^7.1.3",
"appstract/laravel-options": "^1.0",
"fideloper/proxy": "^4.0",
"intervention/image": "^2.4",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"laraveles/spanish": "^1.1",
"spatie/laravel-permission": "^2.26",
"yajra/laravel-datatables-oracle": "~8.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
Hi, is this upgraded to support Laravel 11
- Root composer.json requires appstract/laravel-options ^5.7 -> satisfiable by appstract/laravel-options[5.7.0].
- appstract/laravel-options 5.7.0 requires illuminate/support ^6.0|^7.0|^8.0|^9.0|^10.0 -> found illuminate/support[v6.0.0, ..., v6.20.44, v7.0.0, ..., v7.30.6, v8.0.0, ..., v8.83.27, v9.0.0, ..., v9.52.16, v10.0.0, ..., v10.48.2] but these were not loaded, likely because it conflicts with another require.```
is there a reason why timestamps are disabled?
Hi,
I have try and it work on local but when i push to live server running MariaDB the migrate error
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'' at line 1 (SQL: create table
options (
idbigint unsigned not null auto_increment primary key,
keyvarchar(191) not null,
value json not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
I think it because MariaDB not support json type. Please advise.
Thank for great tool
After installing this package and migrating I get the following error whenever using the option global helper in a route.
"Declaration of Appstract\Options\Option::delete($key) should be compatible with Illuminate\Database\Eloquent\Model::delete()"
After commenting out the delete($key) method everything seems to work just fine
Is there any possibility that we can add a comment to the key-values. It should be stored separately and should not change when update values. I'm working on it. Will give an update.
Hi,
I have a project where I'd normally pull in this package - but I need to be able to apply a global scope to the Option model. So I was wondering about some way to register the scope(s) which could get applied in a booted()
method on the model. Something like (assuming there was a config/options.php) :
protected static function booted()
{
foreach (config('options.global_scopes', []) as $scopeClass) {
static::addGlobalScope(new $scopeClass);
}
}
I'd happily work on a PR if it was something you'd be interested in allowing for.
Hi,
Are we able to add an array to the option value then we could loop the values via for each in controller or blade.
Cheers
I suggest adding new column for type
because developer may need to get all settings with x
type for any use like (Building admin dashboard for changing those settings)
Please i suggest that cast to json must be an option of developer
I have a few suggestions for the project.
First I think it would benefit if the PRs could have the travis check block merging.
They are enabled on a per branch basis by checking the
https://github.com/appstract/laravel-options/settings/branches
Further recommend removing - COMPOSER_FLAGS="--prefer-lowest"
from the travis.yml file.
And finally in the https://github.com/appstract/laravel-options/settings setting the merge button to squash merge
Squash merging PRs reduces the amount of nit/fix commits to one
Hi , how to remove this package from laravel v7???
Hi,
Now, we can only get options from database, but sometime i do not change them frequently, so in a short time, they seem like constant.
Yep, i want to ask, in the future the project will be added a feature about to cache options from database or not.
Hi @gizburdt
I used this package for my laravel application.
Thank you a lot for creating in package.
i have a problem:
i have some option that call in every page loaded for example logo url
or Footer Copyright text
.
when call every option
method in your package, laravel send separate request to database.
i suggest add a new column autoload in yout option table with format enum(yes,no), that in every request loaded all autoload option in cache. with one request.e.g. select * from options where autoload = yes
this system also usage in option WordPress CMS.
After installing this package and migrating I got the following error. I made this below function in "vendor/appstract/laravel-options/src/helpers.php"
if (! function_exists('option_all')) {
/**
* Get all options in key => value pair
*
* @return array
*/
function option_all()
{
return app('option')->option_all();
}
}
but I am getting this error "BadMethodCallException Call to undefined method Appstract\Options\Option::option_all()" and unable to resolve. It's urgent Please advise.
Hey,
I was wondering, since the instructions mention the migrations, but there's often no need to change them. Is it possible to auto-register the migrations from the Service Provider, as explained here?
I'd love to hear your opinions on this.
Cheers!
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.