这是我的控制器中的代码:
class ArticlesController extends Controller {
public function index()
{
$articles = Article::all();
return view('articles.index',compact('articles'));
}
}
Run Code Online (Sandbox Code Playgroud)
我的App.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
<meta charset="UTF-8">
<meta name=description content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<div class="container">
@yield('content')
</div>
@yield('footer')
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Bootstrap JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
和index.blade.php
<?php
@extends('app')
@section('content')
<h1>Articles</h1>
@stop
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
FatalErrorException in 5f3efcdeb3d9812b22b5491d0cba9f22 line 3:
syntax error, unexpected 'extends' (T_EXTENDS)
Run Code Online (Sandbox Code Playgroud)
请帮忙.
解决方案如下 …
我需要根据用户输入替换某些Word文档中的内容。我正在尝试读取模板文件(例如“ template.docx”),并替换名字{fname},地址{address}等。
template.docx:
To,
The Office,
{officeaddress}
Sub: Authorization Letter
Sir / Madam,
I/We hereby authorize to {Ename} whose signature is attested here below, to submit application and collect Residential permit for {name}
Kindly allow him to support our International assignee
{name} {Ename}
Run Code Online (Sandbox Code Playgroud)
Laravel 5.3中有没有办法做到这一点?
我正在尝试使用phpword,但是我只能看到编写新的word文件的代码-但不能读取和替换现有的word文件。另外,当我只是读和写时,格式被弄乱了。
码:
$file = public_path('template.docx');
$phpWord = \PhpOffice\PhpWord\IOFactory::load($file);
$phpWord->save('b.docx');
Run Code Online (Sandbox Code Playgroud)
b.docx
To,
The Office,
{officeaddress}
Sub:
Authorization Letter
Sir / Madam,
I/We hereby authorize
to
{Ename}
whose signature is attested here below, to submit a
pplication …Run Code Online (Sandbox Code Playgroud) 我刚开始在AWS AMI实例上使用Nginx,并且遇到了一些启动问题。
我已经按照此链接安装了php-fpm和nginx https://gist.github.com/sumardi/5559803
除非我不需要mysql,所以我没有运行此命令 sudo yum -y install mysql-server mysql
我的/etc/nginx/conf.d/default.conf样子是这样的:
location / {
root /var/www/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/
html$fastcgi_script_name;
include fastcgi_params;
}
Run Code Online (Sandbox Code Playgroud)
我的 /etc/php-fpm.d/www.conf
; Start a new pool named 'www'.
[www]
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port; …Run Code Online (Sandbox Code Playgroud) 将变量添加到可跨控制器和视图访问的Laravel框架的最佳方法是什么?
我不想.env用于存储变量,因为它不能通过Git获得.
我正在尝试建立一个用户旅行数据库,其中涉及存储:
请注意,两个机场可以位于不同的时区。我需要计算出该航班的时差和天数等。
我不知道如何解决这个问题。我应该添加更多列来存储本地日期时间和 UTC 时间吗?
另外,我看到 Laravel 有dateTimeTz()列类型。但是它似乎没有存储任何有关时区的信息?
帖子表:
$table->dateTimeTz('newTime')->nullable();
Run Code Online (Sandbox Code Playgroud)
设置新时间:
$p->newTime = \Carbon\Carbon::now('Asia/Kolkata')
=> Carbon\Carbon {#841
+"date": "2017-03-28 16:23:33.490926",
+"timezone_type": 3,
+"timezone": "Asia/Kolkata",
}
>>> $p
=> App\Post {#836
id: 1,
user_id: 1,
title: "Et quaerat deserunt qui ullam voluptas.",
body: "Aut eos id ut qui laborum. Tempore rerum ut quas deserunt voluptas optio.",
slug: "et-quaerat-deserunt-qui-ullam-voluptas",
newTime: "2017-03-28 16:23:33",
created_at: "2017-03-28 10:51:36",
updated_at: "2017-03-28 10:51:36",
}
Run Code Online (Sandbox Code Playgroud)