我不想在laravel 4上运行All Outstanding Migrations。我有5次迁移。 现在我只想运行一个迁移。 而不是做:php artisan migrate我想运行一个特定的迁移,如:php artisan migrate MY_MIGRATION_TO_RUN
我刚开始与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' ]; […]
我有两个相关的模型: 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); } }
我正在浏览特定职位作者发表的所有评论。 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
我很难在laravel eloquent ORM写查询。 我的查询是 SELECT book_name,dt_of_pub,pub_lang,no_page,book_price FROM book_mast WHERE book_price NOT IN (100,200); 现在我想把这个查询转换成laravel雄辩。
我可以更改Eloquent模型主键吗? 我想设置主键,例如admin_id而不是'id'? 我知道我可以改变模型的表名 protected $table = "admin"; 主键有类似的东西吗?
我有一个多对多的关系设置和工作,添加一个项目,我用的车: $cart->items()->attach($item); 它将一个项目添加到数据透视表(应该如此),但是如果用户再次点击链接添加一个他们已经添加的项目,它会在数据透视表中创build一个重复的项目。 是否有内置的方式来添加一个数据透视表,只有当一个不存在? 如果没有,我怎样才能检查数据透视表,find一个匹配的logging是否已经存在?
我想知道是否有人知道在Web主机SUBDIRECTORY /子文件夹中安装Laravel 4的方法,同时不会将/ app /文件夹和其他合理的文件暴露给主机的公开访问部分。 这个想法是,我可以访问http://mydomain.com/mylaravel/ ,以便能够使用Laravel,但同时我想避免任何人进入http://mydomain.com / app /或http://mydomain.com/mylaravel/app/ ,基本上可以看到我的configuration文件和其他代码。
我正在处理Angular应用程序。 我试图用ng-if和在ng-repeat内部切换,但是没有成功。 我有像这样的数据: **[{"_id":"52fb84fac6b93c152d8b4569", "post_id":"52fb84fac6b93c152d8b4567", "user_id":"52df9ab5c6b93c8e2a8b4567", "type":"hoot",}, {"_id":"52fb798cc6b93c74298b4568", "post_id":"52fb798cc6b93c74298b4567", "user_id":"52df9ab5c6b93c8e2a8b4567", "type":"story",}, {"_id":"52fb7977c6b93c5c2c8b456b", "post_id":"52fb7977c6b93c5c2c8b456a", "user_id":"52df9ab5c6b93c8e2a8b4567", "type":"article",},** $ scope.comments =上面提到的数据 和我的Html一样: <div ng-repeat = "data in comments"> <div ng-if="hoot == data.type"> //differnt template with hoot data </div> <div ng-if="story == data.type"> //differnt template with story data </div> <div ng-if="article == data.type"> //differnt template with article data </div> […]
我们的整个网站将通过https服务。 我在每条路线上都有“https”。 但是,如果他们尝试通过HTTP,我如何将它们redirect到https? Route::group(array('https'), function() { // all of our routes }