laravel-4

Custom setters and getters in Laravel

被刻印的时光 ゝ 提交于 2019-12-13 15:41:17
问题 Here's a tricky question. I am building a framework in Laravel and I want my objects to interact with Rackspace in a transparent way. From now on I made it possible to upload/delete objects without having in mind Rackspace $model->file = Input::file('thing'); // and it uploads to Rackspace. The next step I want to achieve is to get the route using my config file. The behaviour would be something like $route = $file->source (with source with hello.jpg in the database for instance) and get

Controller Route not found in Laravel 4

柔情痞子 提交于 2019-12-13 15:36:01
问题 I am in the process of migrating from L3 to L4. When registering the HomeController controller that came with the default L4 installation, trying to go to the page www.domain.com/home gives me a ResourceNotFound exception. I did a composer dumpautoload but that did not help. Did I miss out an additional step? routes.php Route::controller('home', 'HomeController'); controllers/HomeController.php <?php class HomeController extends BaseController { public function showWelcome() { return View:

laravel 'Allowed memory size of 134217728 bytes exhausted' on basic query

半世苍凉 提交于 2019-12-13 15:14:48
问题 I have no qlue why I can't get the following to work: DB::table('twitter_hashtags')->paginate(5); Every single time I get (the second number tends to differs) Allowed memory size of 134217728 bytes exhausted (tried to allocate 95735352 bytes) I tried using as in (18776710), but that did not make any difference DB::connection()->disableQueryLog(); Removing ->paginate(5) does not make any difference. When I try: DB::select('SELECT * FROM twitter_hashtags'); It works fine, but then I can't use

Merge collections in laravel from relations

亡梦爱人 提交于 2019-12-13 15:13:59
问题 Suppose I have 3 tables. Images Subject Style The relationship is Many to Many(Images,Subject) and Many to Many(Images,Style). Now I want to do something like: $result=$subjectResult->images()->merge($styleResult->images()) . I want the type of result to be an Images Collection Object. So far I've tried it as: $subjectResult=Subject::with('images')->where(query)->get(); But this returns the subject rows,Image rows and the pivot rows. I want to extract the Images collection from it. Image

Integrating wordpress and laravel user management

喜欢而已 提交于 2019-12-13 15:04:02
问题 I am developing both a blog with wordpress and a rather complex application with laravel. The problem is to integrate one in the other. I do not want the users to need to log into both services seperately. As I need to store more information about a user than just the wordpress basics I want to use Eloquent and everything from Laravel though. I could include the Wordpress core and just use the wordpress authentication, but that would mean to load the whole WP environment everytime, if I am

Laravel 4: if statement in blade layout works strange

安稳与你 提交于 2019-12-13 13:08:27
问题 Could someone explain me why I get blank screen with printed string "@extends('layouts.default')" if I request page normally (not ajax)? @if(!Request::ajax()) @extends('layouts.default') @section('content') @endif Test @if(!Request::ajax()) @stop @endif I'm trying to solve problem with Ajax, I don't want to create 2 templates for each request type and also I do want to use blade templates, so using controller layouts doesn't work for me. How can I do it in blade template? I was looking at

How can I paginate an array of objects in Laravel?

本秂侑毒 提交于 2019-12-13 12:28:47
问题 I'm building an application using Laravel 4.2. I have a model for units and another for users and pivot table user_units . Every user in this application can select a unit and add it to his favorite list then he can publish this unit with his information as an ad. I want to select all units published by all users The user_units (pivot) table has the following columns: id user_id unit_id publish adtype addinfo created_at updated_at With relations methods on models public function users() {

Laravel 5.1: How to limit account access so one account can be accessed at one time

一曲冷凌霜 提交于 2019-12-13 12:16:48
问题 I am relatively new to Laravel, but I would like to restrict account access so that only one account can be logged into at one time. For example, if I were to log into my account on my work computer and then I logged in at my home computer simultaneously, it would not log me in and prompt me to logout of the first computer. What is the best and correct way of doing this? Many Thanks 回答1: This is more a 'logic' question than one about Laravel. In short I would build something like this; Add a

Difference between Laravel's raw SQL functions

房东的猫 提交于 2019-12-13 11:45:15
问题 It seems I'm not the only person struggling with the differences between Laravel's DB::raw(), DB::select(), DB::statement(), and DB::unprepared() methods. It seems as if one almost needs to try a given SQL statement with all 4 to identify which will work. Can anybody clarify how they relate to each other, and which to use for what purposes? 回答1: I will try to clarify: DB::raw() It generates a raw and sanitized SQL string, to be passed to other query/statements, preventing SQL injections. Is

_token error in laravel 4 on update

老子叫甜甜 提交于 2019-12-13 10:19:55
问题 I am running a laravel 4 framework and I get a Whoops! error with just the message "_token" when I try to update an instance of an eloquent model class. What does this mean? I use Form::model to create the form and I am able to update records of other model classes. 回答1: This is usually a result of either a missing or mismatched CSRF token. If you haven't placed a token in your form, do so by echoing the function 'Form::token()' somewhere inside your form. Otherwise I believe this is handled