我正在使用laravel php框架,版本4.1和wkhtml2pdf包.我在routes.php中使用以下代码:
Route::get('/test/export', function() {
return PDF::url('http://google.com');
});
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误说WKHTMLTOPDF didn't return any data:
我也试过使用这样的内部视图:
Route::get('/test/export', function() {
return PDF::html('Auth.home');
});
Run Code Online (Sandbox Code Playgroud)
但我得到了同样的错误,我也试过给我的整个项目递归权限,但也没有解决它.我在2011年的macbook pro上运行OS X 10.9并使用mamp
我正在使用新的whereHas方法在Laravel 4.1中为急切加载的关系添加约束.
$broadcast = $broadcast->whereHas('season', function( $query ) use ( $parameterValues ){
$query->where('name', '2011-12' );
});
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我正在寻找足球/足球广播,其中的关系是广播belongsTo季节
我想为团队(俱乐部)添加约束,其中关系是广播hasOne家庭俱乐部和广播hasOne离开俱乐部.我想要一个团队(利物浦)是主场或客场俱乐部的结果,所以我尝试使用orWhereHas- L4.1中添加的一个特色
$broadcast = $broadcast->with('homeClub')->whereHas('homeClub', function( $query ) use ( $parameterValues ){
$query->where('abb', $parameterValues['club_abbs'] );
});
$broadcast = $broadcast->with('awayClub')->orWhereHas('awayClub', function( $query ) use ( $parameterValues ){
$query->where('abb', $parameterValues['club_abbs'] );
});
Run Code Online (Sandbox Code Playgroud)
但这似乎取消了我在第一个例子中提到的对赛季的限制.就像通过链接orWhereHas一样,我的where方法"忘记了"他们所约束的东西.
任何帮助,非常感谢 - 谢谢
乔恩.
我的数据库1中有两个表:项目3:用户并尝试登录用户并且它正常工作,但我的问题是我没有提到它将从哪个表中获取数据,但它是从自动需要的表格?它是Laravel的特征还是我做错了什么?或者我不明白为什么会这样?
形成
{{ Form::open(array('class'=> 'forming')) }}
{{ Form::text('username',null,array( 'placeholder' => 'Username' ,'class' => 'insi')); }}<br>
{{ Form::password('password',array('placeholder'=>'Password', 'class'=>'paswor')); }}<br>
{{ Form::submit('SignIn!',array('class'=> 'but-n')); }}
{{ Form::close() }}
Run Code Online (Sandbox Code Playgroud)
和AuthController
class AuthController extends Controller{
public function getLogin(){
return View::make('login');
}
public function postLogin(){
$rules = array('username'=> 'required', 'password'=>'required');
$validator = Validator::make(Input::all(),$rules);
if($validator->fails()){
return Redirect::route('login')
->withErrors($validator);
}
$auth = Auth::attempt(array(
'username' => Input::get('username'),
'password' => Input::get('password')
), false);
if(!$auth){
return Redirect::route('login')
->withErrors(array(
'Invalid'
));
}
return Redirect::route('home');
}
}
Run Code Online (Sandbox Code Playgroud) 我有以下RegEx使用和工作:
/\B@(@?\w+(?:::\w+)?)([ \t]*)(\( ( (?>[^()]+) | (?3) )* \))?/x
这个字符串@extends('template', 'test')正确分组并给我我需要的地方.
问题是如果字符串在引号内包含一个未闭合的括号 - 它将失败:
@extends('template', 'te)st')给出@extends('template', 'te)输出
如何告诉此RegEx忽略引号内的括号('或者")
以下是问题的RegExr演示:http://regexr.com/v1?396ci
这是一个应该能够通过的字符串列表:
@extends('template', 'test') // working
@extends('template', $test) // working
@extends('template', 'te()st') // working
@extends('template', 'te)st') // broken
@extends('template', 'te())st') // broken
@extends('template', 'te(st') // broken
@extends('template', 'test)') // broken
@extends('template', '(test') // broken
Run Code Online (Sandbox Code Playgroud)
我把它缩小了 - 我想我需要能够说出来
(
\( <-- only if not inside quotes
(
(?>[^()]+) | (?3)
)*
\) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用通配符创建一个路由,使用我从L3知道的语法,但我一直得到404.
我注册了我的路线routes.php:
Route::get("get_cities/(:num)","QueryController@get_cities");
Run Code Online (Sandbox Code Playgroud)
当我删除通配符时,控制器和函数存在并找到.语法有变化吗?
虽然我在谈论它:有没有我可以提到类似问题的文档,还是尚未编写?
在PhotosController为API执行AJAX调用的网站创建资源控制器之后,资源控制器似乎可以在普通网站和API上使用.
这将显示Photoid = 1 的HTML页面
http://domain.com/photos/1
Run Code Online (Sandbox Code Playgroud)
和Javascript使用以下更新Photo资源并返回JSON响应
PUT http://domain.com/api/v1/photos/1
Run Code Online (Sandbox Code Playgroud)
问题:我们是否有2个PhotoControllers,一个用于处理API使用,一个用于非API?
我遇到了一些与L4(可能是symfony2?)路由的怪癖,我似乎无法在网上或在精彩的Code Bright中找到任何资源,并在IRC中显得空洞.
我正在尝试通过控制器使用带有命名路径的可选参数,但在加载视图时会收到错误.
Route::get('/topic/{topicID?}', array(
'as' => 'topicDetails',
'uses' => 'TopicController@showTopic'
));
Run Code Online (Sandbox Code Playgroud)
class TopicController extends BaseController {
public function showTopic($topicID = null)
{
$data['topicID'] = $topicID;
return View::make('topic_view', $data);
}
}
Run Code Online (Sandbox Code Playgroud)
<a href="{{ route('topicDetails') }}">XXX</a>
Run Code Online (Sandbox Code Playgroud)
Parameter "topicID" for route "topicDetails" must match "[^/]++" ("" given) to generate a corresponding URL.
Run Code Online (Sandbox Code Playgroud)
我假设这并没有将null价值传递给$param我,但我对L4不太熟悉,弄清楚为什么它不起作用,而且我已经耗尽了我所有的资源.
任何线索将不胜感激谢谢!
我正在使用Laravel并创建工匠命令但我需要通过调用在start/artisan.php中注册每个命令
Artisan::add(new MyCommand);
Run Code Online (Sandbox Code Playgroud)
如何获取目录中的所有文件(app/commands/*),并在数组中实例化它们中的每一个?我想得到类似(伪代码)的东西:
$my_commands = [new Command1, new Command2, new Command3];
foreach($my_commands as $command){
Artisan::add($command);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试用Laravel实现一个非常简单的页面跟踪系统,只是为了知道访问最多的页面.
起初我想到创建一个具有访问日期,请求URL(来自Request::path())和用户ID的表,就这么简单.
但是我必须在报告上显示页面标题,为此我需要一些方法将请求URI转换为其页面标题.有什么想法吗?有没有更好的方法来实现这一目标?
目前我从Blade视图文件中设置页面标题@section('title', ...).
先感谢您!
<?php
class Product extends Eloquent {
protected appends = array('category');
public function category()
{
return $this->belongsTo('Models\Category',
'category_id');
}
}
Run Code Online (Sandbox Code Playgroud)
如何实现呢?
laravel ×9
laravel-4 ×8
php ×7
eloquent ×1
mysql ×1
regex ×1
regex-group ×1
restful-url ×1
wkhtmltopdf ×1