laravel-4

Laravel Eloquent get results grouped by days

佐手、 提交于 2019-12-17 21:47:00
问题 I currently have a table of page_views that records one row for each time a visitor accesses a page, recording the user's ip/id and the id of the page itself. I should add that the created_at column is of type: timestamp, so it includes the hours/minutes/seconds. When I try groupBy queries, it does not group same days together because of the seconds difference. created_at page_id user_id ========== ======= ======= 10-11-2013 3 1 10-12 2013 5 5 10-13 2013 5 2 10-13 2013 3 4 ... ... ... I'd

Controller class not found in Laravel 4

浪子不回头ぞ 提交于 2019-12-17 21:21:14
问题 I have the following error while trying to run my controller Controller class not found I have this code in my routes.php file Route::get('cms/create-page', 'AdminCMSController@create_page'); Route::post('cms/createpage','AdminCMSController@createpage'); Route::controller('cms','AdminCMSController'); And this is the code in my Controller class AdminCMSController extends BaseController { public function create_page() { } public function createpage() { } } How can I fix it? 回答1: If you didn't

Get all routes, Laravel 4

試著忘記壹切 提交于 2019-12-17 19:48:53
问题 What I want is just to use one controller at the moment which should handle every request that comes to my laravel 4 application. The problem is that none of the solutions on stackoverflow or elsewhere are working for me. That's what i currently have: Route::any('(.*)', function(){ return View::make('hello'); }); Now when browsing to the page I get an error everytime saying: Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException Hope somebody could help me out! 回答1: Regular

How to fix Composer error: “could not scan for classes inside dir”?

社会主义新天地 提交于 2019-12-17 19:08:10
问题 I'm trying to install composer in terminal by entering this command: php composer.phar install it starts to install required packages but I'm getting this error type: [RuntimeException] Could not scan for classes inside "app/commands" which does not appear to be a file nor a folder How can I overcome this issue? 回答1: Usually this happens when you have some corrupted files or any composer update has crashed or interrupted. To solve, just delete the vendor folders and run composer install 回答2:

Group By Eloquent ORM

一世执手 提交于 2019-12-17 19:07:19
问题 I was searching for making a GROUP BY name Eloquent ORM docs but I haven't find anything, neither on google. Does anyone know if it's possible ? or should I use query builder ? 回答1: Eloquent uses the query builder internally, so you can do: $users = User::orderBy('name', 'desc') ->groupBy('count') ->having('count', '>', 100) ->get(); 回答2: Laravel 5 This is working for me (i use laravel 5.6 ). $collection = MyModel::all()->groupBy('column'); If you want to convert the collection to plain php

Laravel - Limit each child item efficiently

喜夏-厌秋 提交于 2019-12-17 18:58:47
问题 I have this: $commentReplies = Comment::whereIn('comment_parent_id', $CommentsIDs) ->take(2)->get(); Where $CommentsIDs is an array of 3 parent comment ids (1,2,3). I am trying to retrieve 2 replies for each of the $commentsIDs if they exist. So a total of 6 replies (2 for each comment) should come back with the query, if the replies exist, nothing more. However, with take(2) in there, it limits the replies to 2, and we only get 2 replies for one of the comments. How can it be setup to get 2

Laravel - Union + Paginate at the same time?

两盒软妹~` 提交于 2019-12-17 18:37:03
问题 Brief: I am trying to union 2 tables recipes and posts then add ->paginate(5) to the queries. But for some reason I get this error: Cardinality violation: 1222 The used SELECT statements have a different number of columns (SQL: (select count(*) as aggregate from posts Code: $recipes = DB::table("recipes")->select("id", "title", "user_id", "description", "created_at") ->where("user_id", "=", $id); $items = DB::table("posts")->select("id", "title", "user_id", "content", "created_at") ->where(

How to deploy laravel 4.2 on shared hosting?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-17 18:29:41
问题 I developed an application with laravel 4.2.8 and now I am having trouble deploying it. I followed this answer https://stackoverflow.com/a/16683938/3153380 but its not working. I am getting a white screen and the headers are returning a 500 Internal Server Error status. I read around that laravel 4.2 is a bit tricky to set up on shared hosting is this true? I can seem to find a working solution so those that have deployed 4.2 before please help. My folder structure is like below root/ laravel

Laravel 5 - Add a stylesheet only if on a certain page/controller (page specific asset)

吃可爱长大的小学妹 提交于 2019-12-17 18:20:13
问题 My Laravel layout is currently as follows (removed navbar etc..): <link href="//maxcdn.bootstrapcdn.com/bootswatch/3.3.4/flatly/bootstrap.min.css" rel="stylesheet"> <link href="{{ asset('/css/app.css') }}" rel="stylesheet"> <!-- Fonts --> <link href='//fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'> <!-- Scripts --> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5

How do I set up Bootstrap after downloading via Composer?

拥有回忆 提交于 2019-12-17 18:15:43
问题 I'm a beginner with Composer, so I know little about it and have little experience with web application development. I was reading the Nettuts+ Tutorial, and have a basic question about Composer. { "require": { "laravel/framework": "4.0.*", "way/generators": "dev-master", "twitter/bootstrap": "dev-master", "conarwelsh/mustache-l4": "dev-master" }, "require-dev": { "phpunit/phpunit": "3.7.*", "mockery/mockery": "0.7.*" }, "autoload": { "classmap": [ "app/commands", "app/controllers", "app