Welcome Guest, Not a member yet? Register   Sign In
REST API one-to-many resource relationships
#6

(This post was last modified: 01-23-2021, 02:20 PM by paliz.)

(01-23-2021, 08:55 AM)nicojmb Wrote: Have you seen this addin?

https://github.com/tattersoftware/codeig...-relations
thats oky for database rdbms but not  suitable for url  

url should be like these bellow 

[color=rgba(232, 230, 227, 0.9)]Use forward slash (/) to indicate hierarchical relationships[/color]


http://api.example.com/device-management
http://api.example.com/device-management...ed-devices
http://api.example.com/device-management...evices/{id}
http://api.example.com/device-management...d}/scripts
http://api.example.com/device-management...cripts/{id}





PHP Code:
$routes->get('x/new''X::new');
$routes->post('x/create''X::create');
$routes->post('x''X::create');  // alias
$routes->get('x''X::index');
$routes->get('x/show/(:segment)''X::show/$1');
$routes->get('x/(:segment)''X::show/$1');  // alias
$routes->get('x/edit/(:segment)''X::edit/$1');
$routes->post('x/update/(:segment)''X::update/$1');
$routes->get('x/remove/(:segment)''X::remove/$1');
$routes->post('x/delete/(:segment)''X::update/$1');

$routes->get('x/(:segment)/y/new''Y::new/$1');
$routes->post('x/(:segment)/y''Y::create/$1');
$routes->get('x/(:segment)/y''Y::index/$1');
$routes->get('x/(:segment)/y/(:segment)''Y::show/$1/$1');
$routes->get('x/(:segment)/y/(:segment)/edit''Y::edit/$1/$1');
$routes->put('x/(:segment)/y/(:segment)''Y::update/$1/$1');
$routes->patch('x/(:segment)/y/(:segment)''Y::update/$1/$1');
$routes->delete('x/(:segment)/y/(:segment)''Y::delete/$1/$1'); 


i personly decide not follow sub resource source and  url   


(01-23-2021, 08:55 AM)nicojmb Wrote: Have you seen this addin?

https://github.com/tattersoftware/codeig...-relations
i tested it  and i found  is equlavent to my solution too now it 's up to which  approaches  i choose
Enlightenment  Is  Freedom
Reply


Messages In This Thread
RE: REST API one-to-many resource relationships - by paliz - 01-23-2021, 02:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB