Tag: laravel

Laravel:未知列'updated_at'

我刚刚开始与Laravel,我得到这个错误: Unknown column 'updated_at' insert into gebruikers (naam, wachtwoord, updated_at, created_at)我知道这updated_at事情是从时间戳列当您迁移表,但我不使用updated_at 。 当我遵循Laravel教程时,我曾经使用它,但现在我正在(或试图制作)我自己的东西,即使我不使用时间戳,我也会得到这个错误。 我似乎无法find它被使用的地方。 这是代码: 控制器: public function created() { if ( ! User::isValidRegister(Input::all())) { return Redirect::back()->withInput()->withErrors(User::$errors); } // Register the new user or whatever. $user = new User; $user->naam = Input::get('naam'); $user->wachtwoord = Hash::make(Input::get('password')); $user->save(); return Redirect::to('/users'); } 路由: Route::get('created', 'UserController@created'); 该模型: public static […]

切换到Laravel 5 – 刀片

如何使用刀片模板中的开关? 当我使用: @switch($login_error) @case(1) `E-mail` input is empty! @break @case(2) `Password` input is empty! @break @endswitch 结果我看到这个文本是明文的。 我更喜欢使用less量的代码开关,因为它比我使用if更干净。 但如果不可能的话就写下来。

运行一个特定的laravel 4迁移(单个文件)

我不想在laravel 4上运行All Outstanding Migrations。我有5次迁移。 现在我只想运行一个迁移。 而不是做:php artisan migrate我想运行一个特定的迁移,如:php artisan migrate MY_MIGRATION_TO_RUN

如何评论laravel .env文件?

我正在Laravel的一个项目,我在.env文件设置存储一些设置像几个参数用于testing目的和几个参数是活的工作,所以我只是检查是否有任何方式来评论.env文件的Laravel 。 这是一个例子 /* Test Settings */ ACCESS_KEY=qwsdr ACCESS_TOKEN=Bgcvfsx /* Live Settings */ ACCESS_KEY=985AsdefG ACCCESS_TOKEN=LFP994kL 提前致谢!

Laravel:在哪里存储全局数组数据和常量?

我刚开始与Laravel合作。 我需要重写一个我几年前制作的整个系统,使用Laravel 4作为基础框架。 在我的旧系统中,我使用了一个常量声明的constant.php文件,以及一个包含大量数组集(例如,类别状态,事件types,语言等)的globals.php文件。 通过这样做,我可以使用类似的东西 foreach ( $langs as $code => $domain ) { // Some stuff } 任何地方在我的应用 我的问题是,如何以所谓的“laravel方式”存储信息。 我尝试使用某种对象来存储这些信息,将其设置为服务并为其创build一个外观: 应用程序/库/项目/ Constants.php namespace PJ; class Constants { public static $langs = [ 'es' => 'www.domain.es', 'en' => 'www.domain.us', 'uk' => 'www.domain.uk', 'br' => 'www.domain.br', 'it' => 'www.domain.it', 'de' => 'www.domain.de', 'fr' => 'www.domain.fr' ]; […]

Laravel。 在关系模型中使用scope()

我有两个相关的模型: Category和Post 。 Post模型具有已published范围(方法scopePublished() )。 当我尝试使用该范围的所有类别时: $categories = Category::with('posts')->published()->get(); 我收到一个错误: 调用未定义的方法published() 类别: class Category extends \Eloquent { public function posts() { return $this->HasMany('Post'); } } post: class Post extends \Eloquent { public function category() { return $this->belongsTo('Category'); } public function scopePublished($query) { return $query->where('published', 1); } }

如何使用口才/stream利从单个查询中插入多行

我有以下查询: $query = UserSubject::where('user_id', Auth::id())->select('subject_id')->get(); 和预期一样,我得到以下结果: [{"user_id":8,"subject_id":9},{"user_id":8,"subject_id":2}] 有没有办法将上面的结果复制到另一个表中,以便我的表看起来像这样? ID|user_id|subject_id 1 |8 |9 2 |8 |2 我遇到的问题是$query可以预期任何数量的行,所以我不能确定如何遍历未知数量的行。

用户login后,Laravel 5会话不会持续

我在Laravel 5上遇到一个有趣的问题。 login用户后,login状态不会在页面间持续存在。 显然它与Session:: 。 我login用户的方式非常简单: if (Auth::attempt(['email' => $data['email'], 'password' => $data['password']], isset($data['remember_me']) ? TRUE : FALSE)) { return redirect()->intended('/'); } 一个简单的print_r(Session::all()); 如果用户未login,则向我提供以下信息: Array ( [_token] => wV8o75lZnCZ0f6CMMQgdBBM2AxSYjtWisAXx6TgZ [flash] => Array ( [old] => Array ( ) [new] => Array ( ) ) [_previous] => Array ( [url] => http://localhost/public ) ) 用户login后redirect到/数组看起来像这样: Array […]

刷新Laravel 4中的所有caching

有没有办法刷新Laravel 4中的所有caching? 我正在使用文件进行caching。 我读了你可以使用Cache::forget('key')的文档,但是如果我需要删除所有的caching呢? 一个工匠的命令也可以是有用的,我认为这是回购的问题,但不知道它是否已经实施。 谢谢!

Laravel命令由关系

我正在浏览特定职位作者发表的所有评论。 foreach($post->user->comments as $comment) { echo "<li>" . $comment->title . " (" . $comment->post->id . ")</li>"; } 这给了我 I love this post (3) This is a comment (5) This is the second Comment (3) 我如何通过post_id命令使上面的列表被命令为3,3,5