Algo-Web / POData-Laravel

Composer Package to provide Odata functionality to Laravel
MIT License
34 stars 29 forks source link

how to use \AlgoWeb\PODataLaravel\Models\MetadataTrait; #175

Open yuri1994 opened 6 years ago

yuri1994 commented 6 years ago

i try to put \AlgoWeb\PODataLaravel\Models\MetadataTrait in my model class but after call the odata it return me <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

404 Resource not found for the segment 'userlocation'.

The model class is:

use AlgoWeb\PODataLaravel\Models\MetadataTrait; use Illuminate\Database\Eloquent\Model;

class userlocation extends Model { use MetadataTrait;

protected $fillable = array("WORKER_ID", "LOCATION_ID");
public $timestamps = false;

public function user(){
    return $this->belongsTo(remoteusers::class)->select(['id','userid as user_id']);
}

public function location(){
    return $this->belongsTo(location::class)->select(['id','code as location_id']);
}

}

how i can resolve this issue?

dsv4890 commented 6 years ago

you need to write this line in place of use MetadataTrait; Inside class userlocation

CyberiaResurrection commented 6 years ago

@yuri1994 , "userlocation" is the name of the entity type, while "userlocations" , plural, is the endpoint by default.

The base endpoint of odata.svc will give you a list of endpoints.

@dsv4890 , real life has caught up with me, I'm currently too busy to look at your issue. Thank you for jumping in on this one.

yuri1994 commented 6 years ago

@CyberiaResurrection, when i call base endpoint it return me `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

Default `
yuri1994 commented 6 years ago

i gone to debug and i found pice of code where checked for classes with MetadataTrait and then expect this class to be instance of Controller class, but in case the real instance is Model class. Maybe i have missed some config but i don't know what exactly

CyberiaResurrection commented 6 years ago

What's your metadata returning? odata.svc/$metadata

Have you hooked the service providers up?

yuri1994 commented 6 years ago

$metadata

`

` i put the providers in config/app.php AlgoWeb\PODataLaravel\Providers\MetadataProvider::class, AlgoWeb\PODataLaravel\Providers\MetadataRouteProvider::class, AlgoWeb\PODataLaravel\Providers\QueryProvider::class, AlgoWeb\PODataLaravel\Providers\MetadataControllerProvider::class,
c-harris commented 6 years ago

just to tick off the obvious things first. have you migrated? what database engine are you using?

yuri1994 commented 6 years ago

i use Firebird database engine

Migration file

`class Userlocation extends Migration { /**

yuri1994 commented 6 years ago

Which class in POData project get the name table and make request to database?

c-harris commented 6 years ago

Podata makes no direct requests to the database, they are passed into Podata Laravel via the laravel query provider.

In POdata laravel MetadataProvider, is responsible to for fetching the information from models that have the trait.

I have not heard of Firebird but will look into it.

is there any chance you could dump out the variable passed to the unify method in MetadataProvider?

yuri1994 commented 6 years ago

@c-harris @CyberiaResurrection
The problem for me was the database engine. Now i change the code for Firebird engine and work well for GET requests. The new problem where is front to me is POST requests. How i can insert or update with POST request? Can anyone give me some example with POST?