<?php

namespace App\Http\Controllers\Admin\Share;

use App\Models\DreamInfoModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class InfoController extends Controller
{
    public function view(Request $request){
        $dream = DreamInfoModel::with('img')->find($request->id);
        $times = (strtotime($dream->end_time) -time());
        if ($times>=3600*24) {
            $days =floor($times/3600/24)  .'天';
        } elseif($times>3600 && $times< 3600*24){
            $days = floor($times/3600) .'小时';
        }elseif($times <=0){
            $days = '已结束';
        }else{
            $days =floor ($times/60) .'分钟';
        }
        return view('admin.share',compact('dream','days'));
    }
}
