【问题标题】:How can I give HyperLink in my full calender?如何在我的完整日历中提供超链接?
【发布时间】:2019-12-11 04:41:18
【问题描述】:

我正在日历中显示我的活动。它将正确显示。但我希望当我点击该事件时,它会重定向到特定的 event_detail 页面。

我是 laravel 的初学者,你能帮帮我吗???

这是我的控制器文件

<?php

namespace App\Http\Controllers\Admin;

use Carbon;
use Calendar;
use App\Event;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class CalendarController extends Controller
{

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    /*
    *Display All The Events In Calendar
    *
    */
    public function calendar()
    {
        $event = [];
        $allEvent = Event::all();

        if($allEvent->count())
        {
            foreach ($allEvent as $key => $eventList) 
            {
                $event[] = Calendar::event(
                    $eventList->name,
                    true,
                    new \DateTime($eventList->event_date),
                    new \DateTime($eventList->evet_date)
                );
            }
        }
        $showInCalendar = Calendar::addEvents($event);
        return view('admin.calendar.event_calendar', compact('showInCalendar', 'allEvent'));
    }
}

这是很多刀片文件

@extends('admin.layout.default')

@section('css')
<link href="{{ url('assets/plugins/calendar/dist/fullcalendar.css') }}" rel="stylesheet" />
@endsection

@section('content')

<div class="row page-titles">
    <div class="col-md-5 col-8 align-self-center">
        <h3 class="text-themecolor">Calendar</h3>
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{{ url('/home') }}">Dashboard</a></li>
            <li class="breadcrumb-item active">Calendar</li>
        </ol>
    </div>
</div>


<div class="row">
    <div class="col-lg-12">
        <div class="card card-outline-info">
            <div class="card-body">
                <div class="container">
                    <div class="row justify-content-center">
                        <div id="calendar">                            

                            {!! $showInCalendar->calendar() !!}

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('jsPostApp')
{!! $showInCalendar->script() !!}
<script src="{{ url('assets/plugins/calendar/jquery-ui.min.js') }}"></script>
<script src="{{ url('assets/plugins/moment/moment.js') }}"></script>
<script src="{{ url('assets/plugins/calendar/dist/fullcalendar.min.js') }}"></script>
<script type="text/javascript">
</script>
@endsection

我不知道如何处理该超链接以打开该特定事件的详细信息页面。

【问题讨论】:

  • 只需为您的每个事件设置url 属性。有关详细信息,请参阅 fullCalendar“事件对象”文档。
  • 我知道要设置URL属性,但不知道怎么写,请大家帮忙写代码???

标签: php ajax laravel eloquent fullcalendar


【解决方案1】:

实现这种行为非常容易。

您需要在事件对象中设置属性url。一旦你有了它,你可以使用回调eventClick 来重定向用户。默认情况下,eventClick 将始终重定向到url 内的链接。

如果您想在不同的选项卡或弹出窗口中显示它,请查看我在此处发布的事件单击链接中的取消默认行为部分。

【讨论】:

  • 我知道要设置URL属性,但是不知道怎么写,请大家帮忙写代码???
【解决方案2】:

哦,我找到了解决方案

public function calendar()
    {
        $event = [];
        $allEvent = Event::all();

        if($allEvent->count())
        {
            foreach ($allEvent as $key => $eventList) 
            {
                $event[] = Calendar::event(
                    $eventList->name,
                    true,
                    new \DateTime($eventList->event_date),
                    new \DateTime($eventList->event_date),
                    null,
                    [
                        'url' => 'event/' .$eventList->id,
                    ]

                );
            }
        }

【讨论】:

    猜你喜欢
    • 2011-07-11
    • 1970-01-01
    • 1970-01-01
    • 2017-10-16
    • 2015-04-04
    • 1970-01-01
    • 2017-06-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多