Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 20 2017 15:32
    dklesev opened #131
  • Dec 17 2017 05:46
    edeis53 opened #130
  • Sep 27 2017 13:13
    tooshay edited #128
  • Sep 27 2017 10:58
    tooshay closed #129
  • Sep 27 2017 10:58
    tooshay opened #129
  • Sep 27 2017 10:39
    tooshay edited #128
  • Sep 27 2017 10:30
    tooshay opened #128
  • Sep 13 2017 11:40
    rduque1 opened #127
  • Aug 08 2017 17:53
    fatkhanfauzi commented #124
  • Aug 01 2017 16:56
    fatkhanfauzi opened #126
  • Jun 29 2017 13:24
    pascal08 edited #125
  • Jun 29 2017 13:24
    pascal08 edited #125
  • Jun 29 2017 13:20
    pascal08 closed #125
  • Jun 29 2017 13:16
    pascal08 edited #125
  • Jun 29 2017 13:16
    pascal08 edited #125
  • Jun 29 2017 13:15
    pascal08 edited #125
  • Jun 29 2017 13:15
    pascal08 edited #125
  • Jun 29 2017 13:15
    pascal08 opened #125
  • Jun 24 2017 09:47
    pascal08 commented #124
  • Jun 16 2017 13:58
    GIANTCRAB commented #124
Remo Laubacher
@Remo
anyone here who managed to get this package working?
chwebdude
@chwebdude
Hi. Anyone here?
chwebdude
@chwebdude
Is there a possibility to use values in the link mapper?
Ex: I have a Dir Class with an id and parent. Parent links to a Dir itselfs. So i want two links: self:"api/dirs/2", parent: "api/dirs/1"
Is that possible? Couldn't figure it out... (and I am new to Laravel too)
Nil Portugués Calderó
@nilportugues
hello
yes it’s possible to configure
Nil Portugués Calderó
@nilportugues
/@all just let me know from now on your doubts
nnnikolay
@nnnikolay
Hi, there. Where can I found more examples for this package ? For instance how to read include uri attr section ? How to show relationships and include members in response ?
Nil Portugués Calderó
@nilportugues
I’m thinking on building a full api and share it in a new repository as I get this question asked quite a lot.
relationships are set as urls in JSONAPI as of version 1.0. http://jsonapi.org/format/#fetching-relationships
as it can be read, this requires a jsonapi server. This is a future project but out of the scope of the current project, which only handles representational state
not resource logic given certain actions on certain url types
nnnikolay
@nnnikolay
@nilopc yeah ok.
it's clear
Nil Portugués Calderó
@nilportugues
hmm can I help you with anything else? :)
nnnikolay
@nnnikolay
now I'm reading your code, but if you don't mind I'll ask you if I have questions
Nil Portugués Calderó
@nilportugues
sure ask whenever you feel like it
nnnikolay
@nnnikolay
thx
Abhimanyu Sharma
@abhimanyu003
hey, i'm getting Undefined index: App\Image at DataLinksHelper.php line 107: i'm not sure why
Nil Portugués Calderó
@nilportugues
hello
have you defined a mapping for App\Image?
@abhimanyusharma003 also, try doing a composer update in order to be using the latest version
Abhimanyu Sharma
@abhimanyu003
Yes you are right, sorry about that. App\Image was not correctly defined which is causing this issue.
Nil Portugués Calderó
@nilportugues
@abhimanyusharma003 how are you liking the library?
@abhimanyusharma003 I’m open to suggestions and ideas :)
Abhimanyu Sharma
@abhimanyu003
It's really good, right now i'm trying to understand the json-api standard. One thing i'm not sure about is that does all the relationship data also included in the json or not.
because if a user has many Images, all the images associated with user also gets in output.
Nil Portugués Calderó
@nilportugues
relationships are optional
yeah that’s the point, but on the include section
I’m working on an example repository
with all the possible use cases and edge cases
My recommendation there, is to have 2 eloquent models (I’m assuming you’re using eloquent)
eg
UserLite extends App\User
UserLite has no relationships mapped (as Eloquent does relationships by class name)
that would solve the issue
say UserLite, or something like UserWithoutImages, whatever it fits better
Abhimanyu Sharma
@abhimanyu003
Yes you are right i'm using eloquent..!!
I'm waiting for you example repo to study and understand things in deep..!!
At the current moment I can say that I find little complex to build things with accurate JSON-API standards.
Nil Portugués Calderó
@nilportugues
you may want to use the laravel5-json-transformer instead
or the laravel5-hal-json-transformer maybe
ah, and no new mappings are required
which is good news if you just want to switch, use the classes in the laravel package, and you’re done :D
Abhimanyu Sharma
@abhimanyu003
great..!! I will setup a things with laravel5-hal-json-transformer in few hours. I'm might contact you back :smile:
Nil Portugués Calderó
@nilportugues
sure :)
Jon Phipps
@jonphipps
I have an array of properties that I need to append to a model as attributes. They're pulled in from another model but shouldn't be expressed as a relationship, although technically it's a 'hasMany' relationship. What's the best way to append those attributes?
William Albino Lepinski
@wlepinski
Hey, anybody here?
Hai Phan Nguyen
@pnghai
hey there, how can I append a property (which belongs to another model - aka belongsTo relationship) to the inclusion part?
Sam Greenwood
@samgreenwood
hi guys, i'm having some trouble working out how to define a relationship that i can include with ?include=, any pointers or reference?
Jack Fletcher
@kauhat

Hi folks, I'm not sure if anyone will see this, I'm not ready to submit a proper issue/pull request - but I thought I'd let you know in case you had any ideas.

Using Route::model somewhere else in the app causes errors & failed tests in due to implicit binding in Laravel 5.2. This seems to be confined to the JsonApiTrait trait. I've not got much experience with Laravel, so I'm no sure what the best approach to this is, whether we can disable binding for this plugin, or typecheck the input of show/update/destroy actions in the trait.

Here is the test routes.php file you can use to replicate the errors:

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::group(['prefix' => ''], function () {
        Route::model('employees', 'NilPortugues\Tests\App\Models\Employees');
        Route::resource('employees', 'EmployeesController');
        Route::get('employees/{employee_id}/orders', ['as' => 'employees.orders', 'uses' => 'EmployeesController@getOrdersByEmployee']);
        Route::resource('orders', 'OrdersController');
    });
floh1111
@floh1111
Hi, I have two questions regarding relationships that I could not answer myself by reading the code:
  1. is it true that relationships defined on the model side (hasMany, belongsTo etc.) are always included in the "included"-section of the json document and that certain relationships can only be "excluded" by adding another model that does not have this relationships (as suggested in a post above)?
  2. If 1. is true, what ist the getRelationships() method in the JsonApiMapping transformers for?
Marko Krüger
@mk-conn

hey, just wondering when fetching resource objects, the json response is not formatted as jsonapi.org says it should be (using laravel5-jsonapi)

{
  "links": {
    "self": "http://example.com/articles"
  },
  "data": [{
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON API paints my bikeshed!"
    }
  }, {
    "type": "articles",
    "id": "2",
    "attributes": {
      "title": "Rails is Omakase"
    }
  }]
}

within the ListResource::get() method

if ($results instanceof Collection) {
                $results = json_encode(['data' => $results->toArray()]);
            }

it just json encodes the array of objects... (type attribute is missing for instance) So I'm wondering if one needs to do all the magic himself? You wrote "Package provides a full implementation of the JSON API specification" ... so maybe I overlooked something?