有没有办法捕获无限级别的子页面URL.我的应用程序允许任何用户创建任何级别的子页面.在我的页面表中,我有parentID.
/{page}/{subpage} // this captures 2 level of pages
/{page} // this captures 1 level of page
Run Code Online (Sandbox Code Playgroud)
我想要捕获范围从的所有URL
site.com/food/healthy/fruit/red/apple 到 site.com/fruit/organge 或 site.com/grapes 或 site.com/a/b/c/d/e/f/g/h/i/ j等等.
什么是最有效的方式?
我有一个噩梦得到一个crontab/cronjob来运行Artisan命令.
我有通过cronjob运行的另一个Artisan命令没有问题但是第二个命令不会运行.
首先,当我执行'crontab -e'并编辑要包含的文件时:
0 0 * * * /usr/local/bin/php /home/purple/public_html/artisan feeds:send
Run Code Online (Sandbox Code Playgroud)
cronjob根本不运行.
如果我去cPanel并在那里添加cronjob,它运行但我收到以下错误:
open(public/downloads/feeds/events.csv): failed to open stream: No such file or directory
Run Code Online (Sandbox Code Playgroud)
问题是文件存在且目录具有正确的权限.如果我以root身份通过SSH登录或者用户紫色(php artisan feeds:send)运行命令,该命令运行完美并完成其任务没有问题.
如果在cPanel中,我编辑cronjob使用:
0 0 * * * php /home/purple/public_html/artisan feeds:send
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
There are no commands defined in the "feeds" namespace.
Run Code Online (Sandbox Code Playgroud)
有趣的是,我的其他命令在crontab文件中注册并且工作,并且在cPanel中根本没有引用.
任何帮助将非常感激.为简洁起见,我已经包含了命令使用的命令和模型.
Feed.php型号:
DataFeedController.php控制器:
SendFeeds.php命令:
启动/ artisan.php:
FeedInterface.php接口:
正如您所看到的,有一个GetRates命令,它可以工作.
我发出命令:
php artisan generate:scaffold order --fields="customer_id:integer(11), order_date:date, notes:text”
Run Code Online (Sandbox Code Playgroud)
当它进行迁移时,它以错误结束:
General error: 1 table "orders" has more than one primary key (SQL: create table "orders" ("id" integer not null primary key autoincrement, "customer_id" integer not null primary key autoincrement, "order_date" date not null, "notes" text not null))
Run Code Online (Sandbox Code Playgroud)
我试图customer_id在模式中引用一个Customer模型和相应的表.但是,它不应该是orders表的主键.
以下是up()阻止迁移运行的代码:
Schema::create('orders', function(Blueprint $table)
{
$table->increments('id');
$table->integer('customer_id', 11);
$table->date('order_date');
$table->text('notes');
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
我如何让它工作?
我正在使用Laravel 4.1,我想与Eloquent建立联系:所以我有3个表:
表1(池):id,name
表2(贡献):id,amount,pool_id,contributer_id
表3(贡献者):id,last_name
顺便说一句,我有3个模型:池,贡献者和贡献,提前谢谢.
从http://local.dev/test-laravel/这样的地址运行本地开发服务器的artisan命令是什么?
test-laravel是我安装laravel的文件夹.
当我运行一个命令,就像php artisan serve --host=local.dev/test-laravel/它说服务器开始于http://local.dev/test-laravel:8000(这不起作用)
理想情况下,网址应为http://local.dev:8000/test-laravel
我该如何实现这一目标?
如何从失败的验证器查看 Laravel 控制器中的错误?
我知道我可以使用这个:
return Redirect::route('account-create')->withErrors($validator)->withInput();
Run Code Online (Sandbox Code Playgroud)
但是我需要一个字符串以相同的方法对其进行操作,那么如何使用 foreach 迭代错误并将其附加到单个字符串?
型号:Comment.php
class Comment extends Eloquent {
protected $table = 'comments';
public $timestamps = true;
}
Run Code Online (Sandbox Code Playgroud)
控制器:PageController.php
class PageController extends BaseController {
$top_comments = Comment::take(3)->get();
return View::make('page', array('top_comments' => $top_comments));
}
Run Code Online (Sandbox Code Playgroud)
查看:page.blade.php
@foreach ($top_comments as $comment)
user #{{ $comment->user_id }}:<br />
{{ $comment->comment}}
@endforeach
Run Code Online (Sandbox Code Playgroud)
这与page.blade.php我可以定义为route(/page)的视图完美配合.但是,我似乎无法弄清楚如何在全球范围内实现这一目标.
示例:我希望能够在我的文件中使用@foreach包含.现在,如果我是使用上面的,它的伟大工程上,但不是在,,$top_commentsmaster.blade.php/page//about/tos
我已经使用类别迁移创建了类别表,然后我尝试使用另一个迁移创建产品表,其中包含产品表中的外键关键字category_id到产品表中的id.
请在下面找到我的迁移.
Categories migration
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCategoriesTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories',function(Blueprint $table)
{
$table->increments('id');
$table->string('category_name', 255);
$table->string('category_description', 255);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('categories');
}
}
Products migration
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProductsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function …Run Code Online (Sandbox Code Playgroud) 我正在使用Laravel的Auth类来验证我网站上的用户(基本Auth::attempt(...)内容)。
最近有一个新的要求(是利益相关者!),现在需要用户创建新用户(辅助用户)。由于主要用户的登录是通过第三方系统进行的,因此我无法将辅助用户与主要用户存储在一起(并重用当前的身份验证系统)。
我想到的是以某种方式告诉Auth类登录并在Auth::user()方法上强制设置用户。
有没有办法做到这一点?
昨晚,我将应用程序从5.0升级到5.1.
除注册外,一切似乎都运转正常.
在输入信息和注册时,我收到此错误:
BadMethodCallException in Controller.php line 282:
Method [validator] does not exist.
Run Code Online (Sandbox Code Playgroud)
无法弄清楚我在哪里解决这个问题.
RegistersUsers.php
namespace Illuminate\Foundation\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Services\Registrar;
trait RegistersUsers
{
use RedirectsUsers;
public function postRegister(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException(
$request, $validator
);
}
Auth::login($this->create($request->all()));
return redirect($this->redirectPath());
}
}
Run Code Online (Sandbox Code Playgroud)
Controllers.php
public function __call($method, $parameters)
{
throw new BadMethodCallException("Method [$method] does not exist.");
}
Run Code Online (Sandbox Code Playgroud)