小编Rob*_*bin的帖子

Laravel访客柜台

我正试图在Laravel建立一个访客柜台....

我不知道最好的地方是把代码放在里面以便它加载到每个页面上......但是我把它放在routes.php里面....

我想我最好把它放在basecontroller里面?

但没关系,我的代码现在看起来像这样:

    //stats

$date = new \DateTime;

$check_if_exists = DB::table('visitor')->where('ip', $_SERVER['REMOTE_ADDR'])->first();

$get_visit_day = DB::table('visitor')->select('visit_date')->where('ip', $_SERVER['REMOTE_ADDR'])->first();

$value = date_create($get_visit_day->visit_date);

if(!$check_if_exists)
{

    DB::table('visitor')->insert(array('ip' => $_SERVER['REMOTE_ADDR'], 'hits' => '1', 'visit_date' => $date));

}else{

    DB::table('visitor')->where('ip', $_SERVER['REMOTE_ADDR'])->increment('hits');
}


$value = date_create($get_visit_day->visit_date);

if ($check_if_exists && date_format($value, 'd') != date('d')) {

    DB::table('visitor')->insert(array('ip' => $_SERVER['REMOTE_ADDR'], 'hits' => '1', 'visit_date' => $date));
}
Run Code Online (Sandbox Code Playgroud)

这工作正常,但问题是,我的数据库列总是添加一个新值.

这是我的数据库: 随桌子'访客'

从表'访客'.

它不断添加新的IP,hit和visit_date ......

如何才能从今天(当天)更新点击量,如果过了一天,设置一个新的IP值并计入该列?

php mysql laravel-4

9
推荐指数
2
解决办法
1万
查看次数

HTML 和 CSS 表溢出不起作用

我正在尝试制作具有自动溢出功能的表格,但这似乎不起作用。

我现在所拥有的:

<div class="panel-group col-sm-offset-1 col-sm-10">
  <div class="panel panel-default">
    <div class="panel-heading">

      <i class="fa fa-folder-open-o fa-fw"></i>
        <strong>Chatbox</strong> 

    </div>

    <div id="forum4" class="panel-collapse collapse in" style="height:248px;">           

      <div class="table-responsive">

        <table class="table table-hover" style="overflow:auto;max-height:248px;">
          <thead>
            <tr>
              <th style="width:5%"></th>
              <th style="width:81%;"></th>
              <th style="width:5%;"></th>
              <th style="width:8%;"></th>
            </tr>
          </thead>
            <tbody>
              <tr>
                <td><b>Robin</b></td>
                <td>Hier komt dan het bericht :D</td>
                <td class="text-right"><small><a href="#"><i class="fa fa-warning" style="color: #CA2B2B;"></i></a></small></td>
                <td class="text-right"><small>16 aug 18:51</small></td>
              </tr>
            </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

这给了我想要的完美东西,除非它需要溢出。因为当它需要溢出时,它会继续运行,没有任何溢出。

当我添加display:block时,table它确实有溢出(自动)但表更短(http://prntscr.com/85c09y)。这就是我想要解决的问题,表格如下所示:http : //prntscr.com/85c1u6

我想 …

html css

7
推荐指数
1
解决办法
7801
查看次数

PHP串口连接读取超时

我正在尝试在这里解决一些问题

我有一个要通过串行端口(在 RPI 上)执行的“序列”。

我在 Laravel 中运行一个受监督的 PHP 命令,该命令连接到 MQTT 代理。

当我向该代理发送消息时,RPI 会拾取该消息并进行处理。现在,我有一个等待用户交互的时刻。这里的问题是,有时用户不与系统交互,PI 一直“等待”串行数据。当用户按下按钮时,我会收到可以处理的串行数据。

我尝试使用一个while (true) {}循环来读取串行数据,但它突然停止了。这是一些示例代码;

$configure = new TTYConfigure();
$configure->removeOption("9600");
$configure->setOption("115200");

$this->serialPort = new SerialPort(new SeparatorParser("\n"), $configure);

$serialDevice = config('app.device_type') === 'usb' ? '/dev/ttyACM0' : '/dev/ttyAMA0';

$this->serialPort->open($serialDevice);

// this is a special one, we add an timeout here of 15 seconds, to prevent that the machine would get stuck.
$timeoutStart = time();
$timeout = $timeoutStart + 15; // 15 seconds of timeout.
$aborted = false;

while …
Run Code Online (Sandbox Code Playgroud)

php serial-port laravel raspberry-pi

7
推荐指数
1
解决办法
687
查看次数

Laravel 两种 404 样式

我有一个主站点和一个管理控制面板。

我希望每个版本都有不同的 404 页。

我该怎么做?我目前在我的app/Exceptions/Handles.php文件中有以下代码:

/**
    * Render an exception into an HTTP response.
    *
    * @param  \Illuminate\Http\Request  $request
    * @param  \Exception  $exception
    * @return \Illuminate\Http\Response
    */
public function render($request, Exception $exception)
{
    if($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException)
    {
        $view = $request->is('admin/*') ? 'acp.errors.404' : 'errors.404' ;

        return response()->view($view, [], 404);
    }
    return parent::render($request, $exception);
}
Run Code Online (Sandbox Code Playgroud)

但是我使用该包spatie/laravel-permission并收到以下错误;

Trying to get property 'role' of non-object (View: F:\Development\RPR\site\resources\views\layouts\acp.blade.php) (View: F:\Development\RPR\site\resources\views\layouts\acp.blade.php)
Run Code Online (Sandbox Code Playgroud)

我使用 in acp.blade.php auth()->user()->role, 来获取用户角色,它可以正常工作,没有任何例外。我应该如何解决这个问题?

php laravel

5
推荐指数
1
解决办法
421
查看次数

如何通过Laravel统计独特的访客并将其显示在图表中?

我想通过Laravel概述我的独特访客(有点像cloudflare).

我已经拥有的东西:

我有一个数据库sheme,但我不认为这是好的: db sheme

我想尽可能多地将数据存储到我的数据库中,但不是存储地点,哪个浏览器等...

我希望能够每天查看所有访问者(唯一的,因此一天内不是同一个IP的两倍),因此请计算IP地址,以及整个月.

例如:

4月份需要在我的视图中显示如下:

['1/04', 5],
['2/04', 58],
['3/04', 496],
['4/04', 654],
['5/04', 854],
['6/04', 756],
['7/04', 254],
['8/04', 887],
['9/04', 452],
['10/04', 985],
['11/04', 745],
['12/04', 120],
['13/04', 985],
['14/04', 745],
['15/04', 321],
['16/04', 852],
['17/04', 753],
['18/04', 951],
['19/04', 791],
['20/04', 167],
['21/04', 761],
['22/04', 349],
['23/04', 741],
['24/04', 258],
['25/04', 963],
['26/04', 317],
['27/04', 482],
['28/04', 341],
['29/04', 654],
['30/04', 751]
Run Code Online (Sandbox Code Playgroud)

因此,每天必须计算IP的数量,并且持续一个月,取决于当前月份.

输出看起来与此类似:

产量

如果可能的话,我想收到一个控制器,视图和数据库.我已经搜索了整个互联网,但没有找到任何东西......如果有人能帮助我,我会非常高兴!

最亲切的问候,

知更鸟

php mysql laravel laravel-4

3
推荐指数
1
解决办法
3527
查看次数

无法将类型为Symfony \ Component \ HttpFoundation \ File \ UploadedFile的对象用作数组Laravel 4.2文件上传

我正在尝试同时使用上载文件负载Laravel 4.2,但是它不起作用。

当我尝试上传2个或更多文件时,laravel仅上传最新选择的文件。

现在我改变了一些东西,这给了我错误Cannot use object of type Symfony\Component\HttpFoundation\File\UploadedFile as array

为什么返回此错误?他为什么不上传所有图像?

我的控制器:

public function postUpload() {
  // getting all of the post data
  $files = Input::file('file');
  //echo "<pre>";
  //var_dump($files);
  //echo "</pre>";
  //die;
  $map = Input::get('mapname');
  // setting up rules
  $rules = array('file' => 'max:10000'); //mimes:jpeg,bmp,png and for max size max:10000
  // doing the validation, passing post data, rules and the messages
  $validator = Validator::make($files, $rules);
  if ($validator->fails()) {
    // send back to the page with …
Run Code Online (Sandbox Code Playgroud)

php arrays symfony laravel-4

2
推荐指数
1
解决办法
5148
查看次数

标题上方的 WPF 数据网格标题

所以我试图让这个数据网格更有条理:

数据网格

目前,我正在绑定一个 Json 文件中的数据,该文件正在 C# 代码中。现在我不想继续写“飞行员 x”、“飞行员 y”等......并在这里重复自己。所以我想知道是否可以在当前标题上方“添加”一个标题。因此,假设我们在一个标题下有“voornaam”、“achternaam”、“club”和“licentie”,下一个“voornaam”、“achternaam”、“club”、“licentie”也在标题下,然后是“merk” , "type" 和 "nummerplaat" 也是。

我的意思是“标题”是这样的;

标题示例

您可以在下面找到 XAML 页面的代码;

<Grid>
        <DataGrid x:Name="list_participants" ColumnHeaderStyle="{StaticResource HeaderStyle}" ColumnWidth="Auto" RowBackground="Transparent" Foreground="#fafafa" AlternatingRowBackground="#555a62" Background="Transparent" BorderThickness="0" AutoGenerateColumns="False">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Team nummer" Binding="{Binding team_number}" />
                <DataGridTextColumn Header="Voornaam" Binding="{Binding team_data.pilot.firstname}" />
                <DataGridTextColumn Header="Achternaam" Binding="{Binding team_data.pilot.lastname}" />
                <DataGridTextColumn Header="Club" Binding="{Binding team_data.pilot.club}" />
                <DataGridTextColumn Header="Licentie" Binding="{Binding team_data.pilot.license}" />
                <DataGridTextColumn Header="Voornaam" Binding="{Binding team_data.navigator.firstname}" />
                <DataGridTextColumn Header="Achternaam" Binding="{Binding team_data.navigator.lastname}" />
                <DataGridTextColumn Header="Club" Binding="{Binding team_data.navigator.club}" />
                <DataGridTextColumn Header="Licentie" Binding="{Binding team_data.navigator.license}" />
                <DataGridTextColumn Header="Merk" Binding="{Binding car_data.brand}" …
Run Code Online (Sandbox Code Playgroud)

c# wpf datagrid datagridview wpfdatagrid

2
推荐指数
1
解决办法
1735
查看次数

C#以特定格式浮动的字符串

我正在尝试转换以下格式的字符串:30,500转换为浮点数30.500(在json中)所以目前我有类似的东西float.Parse(string.Format("{0:00,000}", inp_km.Text), CultureInfo.InvariantCulture.NumberFormat),但是当我将它保存在json中时,它会保存为30500.00.

我在这做错了什么?

我是怎么做到的;

我在这个班上做了一个对象Results;

team_results = new Results()
                        {
                            team_number = selected_team.team_number,
                            results = new Result[2] { new Result{ }, new Result { } }
                        };
Run Code Online (Sandbox Code Playgroud)

现在,当我将新值添加到json(下面的示例)时,我得到的输入是 30,500

[

  {
    "team_number": 101,
    "results": [
      {
        "given_start_time": "20:25",
        "connection_to_start":  "0:00",
        "start_kp": "20:26",
        "stop_kp": "0:0",
        "missed_controls": 0,
        "km": 0.000,
        "gtks": [ "25:00", "30:15", "0:00" ]
      },

      {
        "given_start_time": "21:56",
        "connection_to_start": "0:00",
        "start_kp": "21:57",
        "stop_kp": "0:0",
        "missed_controls": 0,
        "km": 0.000,
        "gtks": …
Run Code Online (Sandbox Code Playgroud)

c# json

1
推荐指数
1
解决办法
82
查看次数