यह एक मेज https://github.com/lucadegasperi/oauth2-server-laravelLaravel सुवक्ता के बाद बचाने आईडी हो जाता है 0
से पलायन कर तालिका oauth_clients
में है, आईडी के क्षेत्र डेटा प्रकार varchar (40) है, इंट नहीं।
$name = Input::get('name');
$id = str_random(40);
$secret = str_random(40);
$client = new oauthClient;
$client->name = $name;
$client->id = $id;
$client->secret = $secret;
$client->save();
सहेजने के बाद(); $ क्लाइंट-> आईडी '0' बन जाती है, न कि मैंने जो स्ट्रिंग सौंपा है।
इससे निम्न संबंध तालिका विफल हो जाती है।
$endpoint = new OauthClientEndpoint(array('redirect_uri' => Input::get('redirect_uri));
$client->OauthClientEndpoint()->save($endpoint);
मैं $client->id
जाँच: के बाद बचाने के लिए, यह 0 हो जाता है और मैं इसे मिलाकर कोई त्रुटि मिलती है:
(SQL: insert into `oauth_client_endpoints` (`redirect_uri`, `client_id`, `updated_at`, `created_at`) values (http://www.xxxxx.com, 0, 2014-09-01 11:10:16, 2014-09-01 11:10:16))
मैं मैन्युअल रूप से अब के लिए इस त्रुटि को रोकने के लिए एक अंत बिंदु को बचा लिया। लेकिन मैं इस मुद्दे को कैसे हल करूं?
यहाँ मेरी मॉडल है:
class OauthClient extends Eloquent {
protected $table = 'oauth_clients';
public function OauthClientEndpoint(){
return $this->hasOne('OauthClientEndpoint', 'client_id', 'id');
}
}
class OauthClientEndpoint extends Eloquent {
protected $table = 'oauth_client_endpoints';
protected $fillable = array('redirect_uri');
public function OauthClient(){
return $this->belongsTo('OauthClient', 'client_id', 'id');
}
}
class CreateOauthClientsTable extends Migration {
public function up() {
Schema::create('oauth_clients', function (Blueprint $table) {
$table->string('id', 40);
$table->string('secret', 40);
$table->string('name');
$table->timestamps();
$table->unique('id');
$table->unique(array('id', 'secret'));
});
}
public function down() {
Schema::drop('oauth_clients');
}
}
class CreateOauthClientEndpointsTable extends Migration {
public function up() {
Schema::create('oauth_client_endpoints', function (Blueprint $table) {
$table->increments('id');
$table->string('client_id', 40);
$table->string('redirect_uri');
$table->timestamps();
$table->foreign('client_id')
->references('id')->on('oauth_clients')
->onDelete('cascade')
->onUpdate('cascade');
});
}
public function down() {
Schema::table('oauth_client_endpoints', function ($table) {
$table->dropForeign('oauth_client_endpoints_client_id_foreign');
});
Schema::drop('oauth_client_endpoints');
}
}
क्या आप अपना ऑउथ क्लाइंट मॉडल पोस्ट कर सकते हैं? – JofryHS
कृपया आपके द्वारा बनाए गए क्लाइंट मॉडल को – lagbox
बनाए गए मॉडल प्रदान करें। –