laravel-4

Select all rows with a date of right now [closed]

耗尽温柔 提交于 2019-12-23 04:52:47
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I need to create a cron job that will run every minute and search a mysql database for all rows that have a date field that is equal to the current date and time rounded to the minute. My problem is what is the proper query and perhaps the best way to store the event date. The basic use case here is that I have

Laravel Response::json gives cross domain error i browser even if header is Access-Control-Allow-Origin:*

血红的双手。 提交于 2019-12-23 04:43:21
问题 I got this Laravel 4 problem that is really confusing to me. I Created these two methods on the same controller. The controller in declared to be restful. The ajax request is from a different domain. Does not work public function getOwnlist(){ $test = User::with(array("images", "images.category"))->find(Auth::user()->id); return Response::json($test, 200, array('Access-Control-Allow-Origin' => '*')); } Works public function getLatest(){ $images = DB::table("images")->where("public","=","1")-

unable to pass array from controller to view in laravel

*爱你&永不变心* 提交于 2019-12-23 04:36:14
问题 i am new to laravel and i have been following the documentation and several videos but for hours now i have been trying to pass an array from the controller to a view but i keep getting this error in the view: Undefined variable: quiz This is the controller code: public function SetQuestions($id) { $query = Quiz::find($id); $quiz = array( 'id' => $query->id, 'noQuestions' => $query->no_questions, 'totalQuizScore' => $query->total_quiz_score ); return View::make('quiz.set-questions')->with(

Laravel using UNION in query builder

拈花ヽ惹草 提交于 2019-12-23 04:25:05
问题 I have an SQL query that works fine and I'm trying to convert into fluent:: SELECT DISTINCT tags.tag FROM tags, items WHERE tags.taggable_type = 'Item' AND items.item_list_id = '1' UNION SELECT DISTINCT tags.tag FROM tags, itemlists WHERE tags.taggable_type = 'ItemList' AND itemlists.id = '1' This is what I have so far in fluent, it all seems right as far as I can tell from the docs and the individual queries both work on their own, it's just when I UNION them it throws an error: $itemTags =

laravel 4 Eager load as a list of ids

拜拜、爱过 提交于 2019-12-23 04:25:01
问题 I would like to make eager load of a related model. however, instead of getting the whole related model, i'd like to retrieve just its id. so at the end, i'll have something like the following: { "error": false, "invoices": { "id": 5, "biz_id": 7, "doc_num": 0, "type": 1, "due_date": "0000-00-00", "status": null, "to": null, "**related_model**": [1,2,3,4] } I'd prefer avoiding loops. UPDATE as I understand I couldn't make it without loops, i have done the following: $data = array(); //get

installing php.5.5 with mcrypt on AWS Linux

给你一囗甜甜゛ 提交于 2019-12-23 04:00:41
问题 This is kind of a n00b question, but I'm a much better developer than a sys admin. Im setting up an Amazon Linux instance on EC2 and can't seem to get php 5.5 with mcrypt installed. yum seems to throw php 5.3 at me each time i try to do a group install or just as a dependency of mcrypt. Any suggestions? This is for a Laravel 4.1 application. Thanks! 回答1: If you are using amazon linux, you will need to install the php packages that start with php55 . Older packages are kept for compatability.

Laravel Eloquent Join

喜夏-厌秋 提交于 2019-12-23 03:46:25
问题 I have two tables and I want to join them. I have looked at other examples and just can't figure it out. My tables are as follows. Clubs id name Members id club_id name A club has many members A member belongs to a club I can list my clubs and after listing my clubs i can list the members of the club ok, but what I want to do is list all my members and show their club. So my output would be ID, Name, Club Name This is my code setup so far // clubs controller public function index() { $clubs =

Correct Postman Settings when testing file uploading in Laravel 4?

*爱你&永不变心* 提交于 2019-12-23 03:00:57
问题 Does anybody know what settings to configure when using Postman extension for Chrome for testing file uploading in a Laravel 4 app? $file = Input::file('media'); var_dump($file); Returns null. 回答1: Turns out check your PHP.ini settings and restart apache and PHP. I was testing video files which exceeded the POST and upload size limits in my configuration, hence the results. 来源: https://stackoverflow.com/questions/23441991/correct-postman-settings-when-testing-file-uploading-in-laravel-4

uploading posted file to amazon s3

馋奶兔 提交于 2019-12-23 02:45:12
问题 I'm trying to upload a file to Amazon S3 via Laravel 4. After user submit a form, the file will be passed to a function where I need to use Amazon PHP SDK and upload the file to Amazon S3 bucket. But how do I upload the file straight away to Amazon S3 without saving the file onto server. My current code looks like this, private function uploadVideo($vid){ $file = $vid; $filename = $file->getClientOriginalName(); if (!class_exists('S3'))require_once('S3.php'); if (!defined('awsAccessKey'))

Using multidimensional array input names with Laravel 4.2 Form facade throws error on postback

杀马特。学长 韩版系。学妹 提交于 2019-12-23 01:13:14
问题 I'm having an issue in Laravel 4.2 with the Form facade when using input names that represent multidimensional arrays. The form will load, display, and post data correctly unless there are values set in Input::old() (because of failed validation, etc.). Here is a simple example that shows the problem: routes.php: Route::get('input-test', function() { return View::make('input_test.index'); }); Route::post('input-test', function() { return Redirect::back()->withInput(Input::all()); }); input