السلام عليكم ممكن طريقة استعمال Polymorphic Relations اريد اضافة تعليقات لنوعين من المقالات : simple post and blog post و اريدها ان تتم عن طريق functi...
السلام عليكم
ممكن طريقة استعمال Polymorphic Relations
اريد اضافة تعليقات لنوعين من المقالات : simple post and blog post
و اريدها ان تتم عن طريق function واحدة
// Comment Model public function commentable() { return $this->morphTo(); } public function user() { return $this->belongsTo('App\User', 'foreign_key'); } //Article and Simple post Model public function user() { return $this->belongsTo('App\User', 'foreign_key'); } public function comments() { return $this->morphMany('App\Comment', 'commentable'); } //function send $comment = Auth::User()->comment(); $comment->content = $request->input('content'); $comment->commentable_id = $request->input(?); $comment->commentable_type = $request->input(?); $comment->save();
لا يوجد تعليقات حتي الان