dev-lav / api-generator Goto Github PK
View Code? Open in Web Editor NEWCreate restful APIs in OctoberCMS
Create restful APIs in OctoberCMS
Hello,
when I try to access the default endpoint that I created for blog posts (/api/v1/posts) it works fine, lists all blog posts. But if I try to do, for example /api/v1/posts/1 I get an exception with the following
count(): Parameter must be an array or an object that implements Countable
public funtion show($id) {
$data = $this->Post->where('id',$id)->first();
if( count($data) > 0){
return $this->helpers->apiArrayResponseBuilder(200, 'success', $data);
}
on
/apigenerator/controllers/api/postController.php line 34
Any help? Thanks
An image loaded via Media Finder after outputting to JSON does not have a full path. Therefore, using it through the API is not possible. If any solution?
As-Salamu Alaykum brother, thanks for this plugin, it's awesome !
I just have a question : when i register two endpoints, it doesn't work !
The last created works but the first one doesn't. Is there anything i made wrong ?
Hello!
Any news? Is project is dead?
After updating today to the latest October CMS via update in the backend, API Generator no longer works with the error:
Cannot make non static method Illuminate\Routing\Controller::getMiddleware() static in class AhmadFatoni\ApiGenerator\Controllers\ApiGeneratorController
In file: <full_path>/plugins/ahmadfatoni/apigenerator/controllers/ApiGeneratorController.php line 336
Changing the second to last function in the ApiGeneratorController.php ( getMiddleware() ) to a non-static method fixes the issue. Thought you should be aware.
The following exception was thrown the first time I tried to access the plugin inside the admin dashboard. This only happened the first time. It worked fine in subsequent visits.
InvalidArgumentException: Route [fatoni.generate.api] not defined. in /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:305
#0
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(788):
Illuminate\Routing\UrlGenerator→route('fatoni.generate...', Array, true)
#1
/var/www/html/plugins/ahmadfatoni/apigenerator/controllers/apigeneratorcontroller/create.htm(71): route('fatoni.generate...')
#2
/var/www/html/modules/system/traits/ViewMaker.php(244):
include('/var/www/html/p...')
#3
/var/www/html/modules/system/traits/ViewMaker.php(110):
Backend\Classes\Controller→makeFileContents('/var/www/html/p...')
how to create api for mobile . i want to create login api. so please tell me how can i create login api for mobile android app. i want to pass username and password to login url and after that i want some response from server side. this thing a want to do
so please guide me
Hey - lemme start with that you developed an awesome plugin!
However I'd like to know whether it's somehow possible to add conditions - either by params to your url e.g. yourhost/api?id=X
or directly in the json condition thing like:
{ "fillable": "discord_tag,is_captain > 0" }
Thanks in advance!
I wrote this condition:
{ "fillable": "id", "relation": [{ "name": "team", "fillable": "title" }]}
where my model is created like this:
QueryModel
public $belongsTo = [
'team' => [
'Rikki\Heroeslounge\Models\Team',
'key' => 'team_id',
'otherKey' => 'id'
],
'user' => ['RainLab\User\Models\User'],
'role' => [
'Rikki\Heroeslounge\Models\SlothRole'
]
];
Relation Model
public $hasMany = [
'sloths' => ['Rikki\Heroeslounge\Models\Sloth', 'order' => 'is_captain desc'],
'apps' => ['Rikki\Heroeslounge\Models\Apps']
];
But the resulting query only shows null.
what am I doing wrong here?
When we install your plugin it does not add any table into database, because you never reference your migration file in version
This is your version file:
1.0.1: - 'Initialize plugin.' 1.0.2: - 'Database implementation' 1.0.3: - 'add builder plugin on requirements dependency' 1.0.4: - 'fixing bug on PHP 7'
And it should be like this:
1.0.1: - 'Initialize plugin.' 1.0.2: - 'Database implementation' - builder_table_create_ahmadfatoni_apigenerator_data.php 1.0.3: - 'add builder plugin on requirements dependency' 1.0.4: - 'fixing bug on PHP 7'
Thanks for a good plugin. However I am unable to get the model for RainLab Pages from the drop down.
Hello, how would it be possible to have authenticated (JWT) requests ? Thanks
how to implement an authentication for requests ?! like passport in Laravel
Hi,
First, i would like to say you thanks for this plugin cause it's a real pleasure.
Second, i'm trying to create an API for my model but my data have an AttachMany which refers to System/Files (upload).
i've write this relation
{ "fillable": "id,name,image" ,"relation": [{ "name": "gallery", "fillable": "id,disk_name" }]}
but the result is :
{ "status_code": 200, "message": "success", "data": [ { "id": 1, "name": "Hotel Le Mottaret", "image": "/Rooms/cropped-images/XQ7A6799-0-0-0-0-1521716260.jpg", "gallery": [] }, { "id": 2, "name": "Hôtel Ibiza", "image": "/JD1_6391.jpg", "gallery": [] } ] }
How can i get all my files attach to my data and show their link in the result ?
thanks
I've multiple photos for a Model
but when if trying to display it, it show empty []
It also not working for normal table relationship with hasMany attribute:
{ "fillable": "id,center_name,center_zone,center_address,contact_number,email,landmark,user_id,state_id,country_id", "relation": [{ "name": "state", "fillable": "id,name,code" }, { "name": "country", "fillable": "id,name,code" }, { "name": "franchises", "fillable": "name,email" }, { "name": "center_photos", "fillable": "id" }] }
This is what ive written
Here franchises is declared as has many and belongs to relation ship with main table
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.