我正在使用AngularJS,我正在尝试在php中生成PDF.这就是我在controller.js中的内容:
$scope.downloadPDF = function(){
$http.post('/download-pdf', { fid: $routeParams.fid })
.success(function(data, status, headers, config){
console.log("success");
})
.error(function(data, status, headers, config){
console.log("error");
});
};
Run Code Online (Sandbox Code Playgroud)
在我的php文件中,我有以下内容来创建带有FPDF库的PDF :
function download_pdf()
{
$id = $_POST['fid'];
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename=' . $id . '.pdf');
$pdf->Output('Order123.pdf', 'D');
}
Run Code Online (Sandbox Code Playgroud)
但请求是响应此而不是打开保存对话框来保存我的pdf.
%PDF-1.3 3 0 obj <> endobj 4 0 obj <> streamx3Rðâ2Ð35W(çrQÐw3T04Ó30PISpêZ*[¤(hx¤æää+çå¤(j*dÔ7Wstndstreamendobj 1 0 obj <endobj 5 0 obj <endobj 2 0 obj <</ProcSet [/ PDF/Text/ImageB/ImageC/ImageI]/Font …
在我的.env文件中,我有以下内容:
IMAP_HOSTNAME_TEST=imap.gmail.com
IMAP_USERNAME_TEST=myemail@gmail.com
IMAP_PASSWORD_TEST=mypw
Run Code Online (Sandbox Code Playgroud)
现在我想在我的控制器中使用它们.我试过这个,但没有结果:
$hostname = config('IMAP_HOSTNAME_TEST');
Run Code Online (Sandbox Code Playgroud)
$ hostname变量等于null.如何在控制器中使用这些配置变量?
我使用js库select2.这是我现在拥有的截图:
开始:
点击下拉列表:

现在可以有一个输入字段,而不是直接下拉列表吗?我知道这是可能的,因为你可以在select2网站上找到它.一个例子是:

但文档非常简短.这就是我现在拥有的:
<input type="text" name="questions[question1]" id="question1" class="question1" style="width:500px"/>
Run Code Online (Sandbox Code Playgroud)
function createQuestionTags(data, question_number){
$(".question" + question_number).select2({
createSearchChoice: function (term, data) {
if ($(data).filter(function () {
return this.text.localeCompare(term) === 0;
}).length === 0) {
return {
id: term,
text: term
};
}
},
data: data,
placeholder: "Enter Question",
allowClear:true
});
}
Run Code Online (Sandbox Code Playgroud)
(数据是从ajax调用接收的)
我在我的Homestead流浪盒上运行Laravel 5.4.我用npm install命令安装了所有npm依赖项.这没有产生任何错误.
在我的webpack.min.js文件中,我有:
const { mix } = require('laravel-mix');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js([
'resources/assets/plugins/jquery-1.11.3.min.js',
'resources/assets/plugins/bootstrap/js/bootstrap.min.js',
'resources/assets/js/main.js'
], 'public/js'
);
mix.combine([
'resources/assets/plugins/bootstrap/css/bootstrap.min.css',
'resources/assets/plugins/font-awesome/css/font-awesome.css',
'resources/assets/css/styles.css'
], 'public/css/all.css');
Run Code Online (Sandbox Code Playgroud)
当我想要运行时,npm …
我在Javascript中有一个函数:
var a = [];
function SaveDataToLocalStorage(data)
{
var receiveddata = JSON.stringify(data);
a.push(receiveddata);
alert(a);
localStorage.setItem('session', a);
}
Run Code Online (Sandbox Code Playgroud)
data参数是JSON对象.
但每次我点击按钮它都会覆盖我本地存储中的数据.
有人知道怎么做这个吗?
我在创建课程时遇到了问题.这是我正在尝试创建表单的数据库方案的一部分:
我正在尝试做的是创建一个课程,我可以创建会话和日期(时刻)附加到该会话.它应该看起来像这样:
在我的CourseAdmin课程中,我有:
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('name', 'text', array('label' => 'Naam'))
->add('description', 'textarea', array('label' => 'Beschrijving'))
->add('materials', 'textarea', array('label' => 'Benodigde materialen'))
->add('numberOfParticipants', 'number', array('label' => 'Aantal deelnembers'))
->add('numberOfDays', 'number', array('label' => 'Aantal dagen'))
->add('price', 'number', array('label' => 'Prijs'))
->add('priceKmo', 'number', array('label' => 'KMO-portefeuille Prijs'))
->add('location', 'sonata_type_model', array('expanded' => true, 'by_reference' => false, 'multiple' => true, 'btn_add' => false))
->add('session', 'sonata_type_collection', array(
'by_reference' => false,
'type_options' => array(
// Prevents the "Delete" option from being …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用jQuery File Upload和angularJS 上传文件.
我有一个多步形式,这是我的多步形式的两个步骤:
<div ng-switch="step">
<div ng-switch-when="1">
<h1>Identity</h1>
<form name="steponeForm" data-file-upload="options" enctype="multipart/form-data" novalidate autocomplete="off">
<input type="submit" ng-click="next(steponeForm.$valid)" value="next" /><br>
<span class="button fileinput-button" ng-class="{disabled: disabled}">
<input type="file" id="fileupload" name="files[]" multiple="" >
</span>
<button type="button" class="btn btn-primary start" data-ng-click="submit()">
<span>Start upload</span>
</button>
<input ng-model="application.lastName" string-pattern required type="text" placeholder="{{ 'Last name'|translate }} *" name="appname" id="appname" />
<div ng-show="steponeForm.$submitted || steponeForm.appname.$touched">
<div class="error" ng-show="steponeForm.appname.$error.required">Last name is required.</div>
<div class="error" ng-show="steponeForm.appname.$error.stringPattern">Doesn't look like a text.</div>
</div>
<input type="submit" ng-click="next(steponeForm.$valid)" value="next" …Run Code Online (Sandbox Code Playgroud) 我的public_html文件夹中有一个Laravel项目.域名是例如domain.com我的.htaccess文件(在public_html文件夹中)是这样的:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
有以下路线:
所以URL的一个例子是http://domain.com/appointment.
现在我想在domain.com上有一个wordpress网站.因此,当您访问domain.com时,您会看到wordpress网站.但是我也希望得到像我的laravel项目的/约会的网址.
什么是最简单,最干净的方法?
我正在使用Backpack for Laravel来提供我的laravel网站的后端区域.
我的数据库结构中有以下表格:
这是为匹配添加集合,并为锦标赛添加匹配.
这些是我的模特:
比赛模型:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Backpack\CRUD\CrudTrait;
class Tournament extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $fillable = ['from', 'to', 'type', 'location', 'place'];
/*
|--------------------------------------------------------------------------
| RELATIONS
|--------------------------------------------------------------------------
*/
public function matches()
{
return $this->hasMany('App\Models\Match');
}
}
Run Code Online (Sandbox Code Playgroud)
匹配模型:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Backpack\CRUD\CrudTrait;
class Match extends Model
{
use CrudTrait;
/*
|--------------------------------------------------------------------------
| GLOBAL VARIABLES
|--------------------------------------------------------------------------
*/
protected $table …Run Code Online (Sandbox Code Playgroud) 我正在使用backpackforlaravel设置我网站的后端区域.我在ProjectCrudController中添加了一个图像字段:
$this->crud->addField([
'label' => "Project Image",
'name' => "image",
'type' => 'image',
'upload' => true,
], 'both');
Run Code Online (Sandbox Code Playgroud)
在我的模型项目中,我有一个像这样的mutator:
public function setImageAttribute($value)
{
$attribute_name = "image";
$disk = "public_folder";
$destination_path = "uploads/images";
// if the image was erased
if ($value==null) {
// delete the image from disk
\Storage::disk($disk)->delete($this->image);
// set null in the database column
$this->attributes[$attribute_name] = null;
}
// if a base64 was sent, store it in the db
if (starts_with($value, 'data:image')) …Run Code Online (Sandbox Code Playgroud) php ×6
laravel ×5
javascript ×4
angularjs ×2
jquery ×2
laravel-5 ×2
.htaccess ×1
ajax ×1
config ×1
elixir-mix ×1
file-upload ×1
fpdf ×1
http ×1
image ×1
input ×1
json ×1
laravel-5.1 ×1
laravel-5.3 ×1
nested ×1
node.js ×1
object ×1
one-to-many ×1
sonata-admin ×1
symfony ×1
webpack ×1
wordpress ×1