laravel-4

Laravel sessions regenerating on every load

故事扮演 提交于 2019-12-03 22:35:58
I'm having a lot of problems and I really can't seem to find a solution. Yesterday, I finished up doing some work on a vagrant box in Laravel. When I shut down the computer, login functionality was working fine. On opening everything up today I find sessions are no longer working. I've tried everything I can think of but I cannot log in now and flash data doesn't work. Every page load a new session is created - e.g using the native driver, if I login, it creates two sessions - one for the login page, and one for the posted login page. If I use a database driver I get the same result. Every

Using Laravel Form class to add the 'disabled' attribute

本秂侑毒 提交于 2019-12-03 22:16:53
Using Laravel 4's Form class, we can create a list using {{ @Form::select('colors', Colors::all()), $color }} Question: How can we add the attribute disabled using Blade without having to rewrite the clean Blade syntax into the usual ugly form? JustinHo Just add array('disabled') in the end like: {{ Form::select('colors', Colors::all(), $color, array('disabled')) }} This should do the work. {{ @Form::select('colors', Colors::all()), array( 'disabled' => 'disabled', 'class' => 'myclass' ) }} Though already answered, IMO both answers weren't neutral enough, so to avoid duplicates the arguments

Foreach inside a Form::select in Laravel 4

我只是一个虾纸丫 提交于 2019-12-03 21:55:36
I try to walk a variable using the helpers of Laravel but it trhows an error, and when I do the same with html tags it works correctly. {{ Form::select('categoria', array( @foreach($enlaceid as $categoria) $categoria->id => $categoria->nombre {{-- I tryed too with englobing with {{ }} )) }} @endforeach <select name="categoria"> @foreach($enlaceid as $categoria) <option value= " {{ $categoria->id }} "> {{$categoria->nombre}} </option> @endforeach </select> Gareth Daine Use the lists() method and pass that to your Form::select() method. Like so: $categories = Category::lists('name', 'id'); In

Laravel: route to storage folder

我的梦境 提交于 2019-12-03 21:54:46
What I'm trying to achieve is to make a route to the storage folder so that I can access it even if it's not under the public directory. For example, user's avatars are located in app\storage\user\avatars\avatar.jpg and I would like to make a route so that I can access those images from something like http://localhost/user/avatars/avatar.jpg . How can I achieve this? Firstly, i would recommend moving the avatars folder to somewhere more publicly accessible. But as its Laravel, you can achieve whatever you want. Route::get('user/avatars/{filename}', function($filename) { $filePath = storage

Laravel 4 Relationship: a message belong to two user

牧云@^-^@ 提交于 2019-12-03 21:53:57
I am making user to user messaging system in laravel 4. So in a simplified version i have to table First table Users user_id | user_name Second table Messages message_id | message_from_user_id | message_to_user_id | message_content | So after reading the documentation I learned that User has many message and message belongs to User. But how do I actually relate them in coding? I am quite confused how will I use the foreign key in this case for a message that will have two user? Check this out: http://laravel.com/docs/eloquent#many-to-many Basically you need a table structure like this Users:

Laravel 4, view composers against @include

只愿长相守 提交于 2019-12-03 21:51:28
I noticed if I pass a second parameter to @include like this: @include('sidebars.pages', array('categories' => Category::all())) Then it is possible to replicate the concept of render partials within views and render partials within partials like in Rails. Do I still need view composers with this functionality? I appreciate any help! While that may be possible it's not the documented use of @include . I'd use caution when doing it like that, and personally, I wouldn't be calling a model within your view. Bind the data you require from your route or controller. Make use of a presenter to

Laravel 4 Blade Templating Engine with Conditional layout

馋奶兔 提交于 2019-12-03 21:48:54
I'm using L4 with Blade. I'd like to be able to conditionally extend a layout. For normal use, I'd like to extend the master layout, and for ajax renders, I'd like to be able to extend the ajax template. I use the following code: @if ( isset($ajax) ) @extends('layouts.ajax') @else @extends('layouts.master') @endif But when the page renders it just prints out @extend('layouts.master'). Does anyone know how to conditionally extend a layout or another? Thanks Try on the first line : @extends('layouts.' . isset($ajax) ? 'ajax' : 'master') EDIT You also can use it this way: @extends(((Request::ajax

Laravel 4 - custom 404 error handling only for missing pages

你说的曾经没有我的故事 提交于 2019-12-03 21:36:35
In Laravel 4.1 I want to redirect the user to my customised 404 page if the page is not exists. That's easy because I already have this: App::missing(function($exception) { return Redirect::to('error404', 303)->with(array('error' => array('url' => Request::url()))); } But the problem is that if any linked file (image, js, css, etc.) is missing on the page I don't get 404 error for that file, but this is showing on console: Resource interpreted as Image but transferred with MIME type text/html: "... So the question is : How can I drop 404 only if a page is missing and leave the default error

Can Delayed Queues in Laravel be used as an alternative to CRON jobs

无人久伴 提交于 2019-12-03 21:25:41
Laravel 4 has a great list of features in terms of Queues. This question is with respect to the Queue method Queue.later() API Documentation the first parameter being the delay . A Cron is basically made use of to execute recurring tasks. If the below snippet were to be made more generic with the time being configurable as well can: This be used as an alternative to CRON jobs? Would this be fail safe approach to use assuming we use IronMQ - class SendEmail { public function fire($job, $data) { //Connect to SMTP and send email $job->delete(); //Recall the queue with a delay Queue::later(60,

IronMq + Laravel4: How make it working

青春壹個敷衍的年華 提交于 2019-12-03 21:19:09
I have a problem concerning the fact that my queues are received by IronMQ but not fire off. Like i ask in this question: https://stackoverflow.com/questions/19200285/laravel4-ironmq-queue-are-not-executed But i see that inside my Iron dashboard, after i subscribe a new domain, then it is not added in any list. Probably IronMQ should display a list of Domains subscribed, isn't it? And this is probably the reason why my queues are not fire off. How can i fix the issue? Thanks! I'm not sure you have done all steps you need to do to have your queues subscribed, so let's take a look at them: