laravel-4

Multiple where queries, using orWhere, in fields of model and related models

风流意气都作罢 提交于 2019-12-07 20:33:48
问题 I have many tables (user facing, not SQL) with filter boxes per column. The columns have not only the tables' fields but fields of related models. I'm trying to add a feature where one can use a comma as an OR separator when filtering data. I need to do it generally as I have a rather large amount of tables, fields and relations. Plus some tables are built dynamically. The code that adds the where clauses for the models own fields is this: foreach ($filters as $column => $filter) { $q->where

Submitting an Array of Checkbox Values with AngularJS & Laravel 4. Checkboxes not Checking (Visually)

半世苍凉 提交于 2019-12-07 20:18:16
问题 Update After experimenting more with the solution(s) from: How do I bind to list of checkbox values with AngularJS? I am a bit closer. This is what I've updated my <input type="checkbox"> to: <input type="checkbox" name="items[]" value="{{ $item['item_id'] }}" ng-checked="formData.items.indexOf({{$item['item_id']}}) > -1" ng-click="toggleSelection({{$item['item_id']}})" /> Now, I can see the data being updated/logged to the console and watching the HTML via dev-tools I can see the checked=

Laravel Custom Auth

感情迁移 提交于 2019-12-07 19:46:07
问题 Here i do the Login Validation $LoginData = Input::except(array('_token')) ; if(Auth::attempt($LoginData)) { return 'success'; } My Table is different so, here i change the table name in auth.php 'table' => 'administrators' But I have the dropdown to choose for the usertype. So how can i choose the tables for Authentication according to the usertypeinput. i.e., Table may be administrators or parents or employees 回答1: I don't know whether Laravel supports the change of auth table name on fly

Laravel schema builder primary key as foreign key

只谈情不闲聊 提交于 2019-12-07 18:46:25
问题 I'm using the Laravel 4.2 schema builder to create some tables referencing each other, and am having some issues. I have a simplified ERD. Note that only relevant columns are shown: Note that I cannot modify the tblcurrencies and tbldomains tables in any way, since I am developing a module to hook into an existing system. I am trying to achieve the following: The extensions table contains extra information about rows in the tbldomains table The prices table contains pricing information about

Laravel 4: Prevent form re-submissions

早过忘川 提交于 2019-12-07 17:54:17
问题 I have gone through this question, but the answer posted their doesn't solve my problem. The problem that occurs is that if the user hits the back button of the browser to return to the submitted form, the entered data persists and the user is able to "re-submit" the form. How can I prevent this behaviour (laravel's way)? my route.php looks like Route::group(array('after' => 'no-cache'), function() { Route::get('/', 'HomeController@index'); Route::ANY('/search','HomeController@search'); Route

How to implement user permissions in Laravel 4?

梦想与她 提交于 2019-12-07 17:32:07
问题 What I basically want is user permissions. I've got an table called 'accounts' in my database. There is a column called 'group_id'. I want to set it when the 'group_id' = 3, then the user is admin. Then he can view special sites, buttons, and things like that. I've tried to implement something like that: public function ($roleName) { $role = $this->roles; if ($role->name == $roleName) { return true; } return false; } Also, I don't know what and how the model is needed, do I need an new one

Laravel use Hash as Validator

半城伤御伤魂 提交于 2019-12-07 17:31:44
问题 i'm using Hash::check() to check current password with entered password. i use this if for check this action $HashPassowrd = Hash::make(Input::get('password')); if( ! Hash::check( Input::get('currPassword') , $data->password ) ) { return Redirect::to('profile.update') ->withErrors('Current Password in Incorrect!'); } how to use that as validator ? for example in this rules $rules = array( 'name' => 'required|alpha', 'family' => 'required', 'email' => 'required|email', 'currPassword'=>

Laravel session table add additional column

北战南征 提交于 2019-12-07 17:31:26
问题 I want to add an extra column user_id on session table. The reason is, some time there are spammer to sign up fake account, once I know that the user is spammer, I want to log the user out by deleting the session record. Is it possible to achieve this? 回答1: This is the session migration schema: Schema::create('sessions', function($table) { $table->string('id')->unique(); $table->text('payload'); $table->integer('last_activity'); $table->integer('user_id')->unsigned(); //// ADD IT! }); You can

Laravel Eloquent setting a default value for a model relation?

为君一笑 提交于 2019-12-07 17:07:28
问题 I have two models: class Product extends Eloquent { ... public function defaultPhoto() { return $this->belongsTo('Photo'); } public function photos() { return $this->hasMany('Photo'); } } class Photo extends Eloquent { ... public function getThumbAttribute() { return 'products/' . $this->uri . '/thumb.jpg'; } public function getFullAttribute() { return 'products/' . $this->uri . '/full.jpg'; } ... } This works fine, I can call $product->defaultPhoto->thumb and $product->defaultPhoto->full and

Make session expiration redirect back to login?

匆匆过客 提交于 2019-12-07 16:33:00
问题 When user logs in and is authenticated, I use Auth::user()->username; to show username of user on dashboard. However, for some reason when session expires the class Auth doesn't seem to work and dashboard page throws error as trying to get property of non-object for Auth::user()->username; . How can I redirect the user back to the login page when he clicks any link or refreshes the page after the session has expired? I tried the Authenticate.php middleware but it always redirects back to