laravel-3

Laravel 3 - How to validate checkbox array, for at least 1 checked?

妖精的绣舞 提交于 2019-12-04 11:20:53
I'm starting to learn Laravel and still on the learning curve. Now I'm starting with Laravel 3 but will most probably switch my project into Laravel 4 once I get something working. Now the question being, how to validate an array of checkbox, I want to validate that at least 1 inside the group is enable(checked). I read somewhere on Laravel forum that we just validate them using a required, but when I dd(input::all()) I don't see anything else but the inputs field and checkbox are not part of them... Part of my Blade Create code for the checkbox: <label class="checkbox">{{ Form::checkbox(

Using CKEditor inside blade template [Laravel 3.x]

蓝咒 提交于 2019-12-04 05:36:40
问题 I'd like to use this bundle: laravel-ckeditor but I have troubles in nesting it in my view (all previous installation steps I've done successfully). How can i connect Form::text() with this bundle? When I add <?php $ckeditor = new CKEditor(); $config = array(); $config['toolbar'] = array( array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ), array( 'Image', 'Link', 'Unlink', 'Anchor' ) ); $events['instanceReady'] = 'function (ev) { alert("Loaded: " + ev.editor.name); }'; $ckeditor-

Binding View::composer to match all views using wildcards?

纵然是瞬间 提交于 2019-12-04 05:04:59
I have a navigation bar like this. <li>Account</li> <ul> <li>Register</li> <li>Login/li> ... I want to update this dynamically depending on Auth::check() . For example, if the user is logged in, "Account" will be changed with "My Profile Page" and child siblings will be replaced with an appropriate array. I need to do this without editing View::make calls in my controllers. It looks pretty bad. A solution like this is what I'm looking for; View::composer('home.*', function($view) { if(Auth::check()) return $view->nest('accountArea', 'home.navigation-loggedIn', null); else return $view->nest(

Laravel query builder with AND in query

£可爱£侵袭症+ 提交于 2019-12-03 16:29:32
问题 I want to add an "AND" clause to the end of a query builder, the code looks like this: $orderers = DB::table('address')->where(function($query) use ($term) { $query->where('id', 'LIKE', '%' . $term . '%') ->or_where('name', 'LIKE', '%' . $term . '%') ->or_where('status', 'LIKE', '%' . $term . '%') ->and_clause_goes_here('is_orderer', '=', '1'); })->paginate($per_page); But searching for a AND clause in Laravel I couldn't find any of equivalent. Could you help me with this problem? 回答1: JCS

Laravel (3) Pagination Sorting & Filtering

半世苍凉 提交于 2019-12-03 15:54:38
I have a list of all the "servers" in my "servers" table returned in my view with pagination. I have been struggling to figure out how to get sorting (asc & desc if possible) and filtering (searching within results) working. Here is my controller code: $servers = Server::paginate(5); return View::make('servers.list') ->with('game', '') ->with('servers', $servers); Here is my view code for the sorting: <ul class="nav"> <li class="active"><a href="#"><i class="icon-angle-down"></i>{{ Lang::line('servers.rank')->get() }}</a></li> <li><a href="#">{{ Lang::line('servers.date')->get() }}</a></li>

How can I allow WYSIWYG editors and disable XSS attacks using Laravel?

你说的曾经没有我的故事 提交于 2019-12-03 12:57:52
问题 I have a enterprise level application where logged in users are authorized to post articles to page using a WYSIWYG editor. (You can consider this application as a website builder.) Everything works fine, but the problems are; WYSIWYG editor posts a HTML containing article, also some localised string characters which Laravel doesn't like, so Laravel's alpha_num check can't pass. (Therefore we don't use it on validation checks.) We need to allow characters like < , " , > because they may want

Laravel eloquent - One to many relationships

大憨熊 提交于 2019-12-03 10:19:25
问题 I have just got started with laravel v3 and am trying to wrap my head around eloquent's One-To-Many relationships by creating a blog, I have posts that have a many to one relationship with categories (Each Post is linked to a category). I have the following tables with the following fields: posts : id, title, body, date_created, category_id categories : id, name I have the following two models: class Category extends Eloquent { public function posts() { return $this->has_many('Post'); } }

Best way to handle dynamic amount of form fields in PHP?

烂漫一生 提交于 2019-12-03 10:06:17
问题 I have a system where I need to list an arbitrary amount of employees with a textfield for each day of the week where an "hours worked" value can be entered. So I need to generate a table with a dynamic number of rows, and each row is going to contain 7 text fields. I'm just wondering what is the best convention to use when assigning ID's to these fields to make it easy to iterate over once I receive the input data on my back end? Each row will have an ID number associated with the row that

How to retrieve a result set from a raw query as an array instead of an object in Laravel 3

半城伤御伤魂 提交于 2019-12-03 09:28:01
By default, Laravel's raw query methods return results as arrays of stdClass objects: Array ( [0] => stdClass Object ( [id] => 1 [username] => admin [password] => admin123 [email] => admin@admin.com [created_at] => 2012-12-06 18:57:19 [updated_at] => 2012-12-06 00:00:00 ) [1] => stdClass Object ( [id] => 2 [username] => userna [password] => user [email] => user@gmail.com [created_at] => 2012-12-06 00:00:00 [updated_at] => 2012-12-05 00:00:00 ) ) The question is how to have Laravel return an array of Arrays instead: Array ( [0] => Array ( [id] => 1 [username] => admin [password] => admin123

Laravel query builder with AND in query

时光毁灭记忆、已成空白 提交于 2019-12-03 05:36:24
I want to add an "AND" clause to the end of a query builder, the code looks like this: $orderers = DB::table('address')->where(function($query) use ($term) { $query->where('id', 'LIKE', '%' . $term . '%') ->or_where('name', 'LIKE', '%' . $term . '%') ->or_where('status', 'LIKE', '%' . $term . '%') ->and_clause_goes_here('is_orderer', '=', '1'); })->paginate($per_page); But searching for a AND clause in Laravel I couldn't find any of equivalent. Could you help me with this problem? Collin James JCS solution may still yield some unexpected results due to the order of operations. You should group