将事件从表显示为fullcalendar

I am trying to implement an event calendar inside one of my vue components in Laravel but I am not able to display the events on the calendar from my SQL database. Although, I am able to view the columns of my table using my resource controller. Note:- I am using router-view to display all the content under the id content so there are no blade templates. Any help please!! Thanks in advance.

Dashboard.vue
<template>
<full-calendar :config='config'>
</full-calendar>
</template>
<script>
export default{
 data() {
    return {
      config: {
        defaultView: "month"
      },
methods:{
loadEvents() {
      axios.get("api/event").then(({ data }) => (this.events = data));
    }
},
created(){
this.loadEvents();
}
};
</script>
Controller type:resource

public function index()
    {

            $events = DB::table('events')->get();
            $event = [];

            foreach($events as $row){
                $endDate = $row->end_date."24:00:00";
                $event[] = \Calendar::event(
                    $row->event_title,
                    true,
                    new \DateTime($row->start_date),
                    new \DateTime($row->end_date),
                    $row->id,
                    [
                        'color'=>$row->color,
                    ]
                    );
            }
            $calendar =  \Calendar::addEvents($event);
            return $events;


    }

class CreateEventsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('events', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->foreign('user_id')->references('id')->on('users');
            $table->string('event_title');
            $table->string('event_description');
            $table->string('color');
            $table->datetime('start_date');
            $table->datetime('end_date');
            $table->timestamps();
        });
    }
};
donglian1523
donglian1523 大家好!!你能检查代码并提出一些建议。谢谢!
一年多之前 回复
donglian6625
donglian6625 我们不可能只修改描述。就像一个机械师无法通过手机修理汽车而不看它
一年多之前 回复
dpy87530
dpy87530 欢迎来到SO!请添加代码以了解您所处的位置。
一年多之前 回复
dongzhila3786
dongzhila3786 欢迎来到SO。您应该发布一些代码示例,因为现在我们无法理解您是否能够从数据库中检索数据
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐