laravel-4

Laravel 4: fetching only models that have related models

半城伤御伤魂 提交于 2019-12-11 06:26:15
问题 I want to only retrieve a model(s) when they have a specific related model present e.g. $posts = Post::has('comment')->get(); that works fine although the opposite does not: $comments = Comment::has('post')->get(); I get the following error: Has method invalid on "belongsTo" relations. Basically the reason i want to do this is that in exceptional circumstances there are cases that when i call a related model in a view, that model may not have a related model present (even when it should)

Laravel 'User' model no id column

徘徊边缘 提交于 2019-12-11 06:22:52
问题 I'm getting an error when trying to Auth::attempt() with the User model saying that I do not have a 'id' column in my table. I am using the 'username' field as the primary key in my table and I didn't want to make an int 'id' column as the primary key. Is there anyway I can change the primary key column in the User model? Error: My user model: <?php use Illuminate\Auth\UserTrait; use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableTrait; use Illuminate\Auth\Reminders

laravel/framework v4.2.9 requires d11wtq/boris ~1.0 -> no matching package found

风格不统一 提交于 2019-12-11 06:13:08
问题 I have following composer.json: { "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "require": { "laravel/framework": "4.2.*", "zizaco/entrust": "1.2.*@dev", "zizaco/confide": "~4.0@dev", "mailchimp/mailchimp": "~2.0", "guzzlehttp/guzzle": "~4.0", "intervention/image": "2.2.1", "webpatser/laravel-uuid": "1.*", "hugofirth/mailchimp": "2.0.*", "jenssegers/agent": "~2.1", "roumen/sitemap": "2.4.15", "maatwebsite/excel": "

user login laravel 4

拜拜、爱过 提交于 2019-12-11 06:07:34
问题 can't manage to login anybody an idea? i still get redirected back to the login page Route::post('login', function() { // get POST data $email = Input::get('username'); $password = Input::get('password'); if ( Auth::attempt(array('email' => $email,'password' => $password) )) { return Redirect::to('home'); } else { // auth failure! lets go back to the login return Redirect::to('login') ->with('login_errors', true); } }); 回答1: change if ( Auth::attempt(array('email' => $email,'password' =>

Adding where clause dynamically to a query with pagination in Laravel

萝らか妹 提交于 2019-12-11 05:57:11
问题 I have a list of items that I want to be able to filter using some buttons in the view (show, which are active, show only ones that start with a certain letter, etc) and I was making a different query for each possible combination and that was getting out of hand as soon as I have more than 3 buttons to filter. So I want to add a where clause to my initial query depending on the buttons pressed, but what I have so far isn't working and I don't know if it's the pagination: (This is an example

Multiple user types in Laravel 4

雨燕双飞 提交于 2019-12-11 05:42:50
问题 I'm building a B2B2C system (i.e. our system provides functionality for other businesses to serve their customers). For example, a car-garage. Our system would handle multiple garages, each of whom would have their own customers, etc. As you can imagine, there are three distinct types of users for the system: Us (i.e. our admin/sales staff) Our customers (i.e. the businesses) Their customers (i.e. the end users) The current authentication system (as far as I can tell) assumes one type of user

Laravel model inheritance

一曲冷凌霜 提交于 2019-12-11 05:34:29
问题 I am using the Toddish/Verify library for Laravel as it includes 99% of what I need for my project. All I need is to add some fields. I have added them in a migration, and I want to add them also to mass creation: use Toddish\Verify\Models\User as VerifyUser; class User extends VerifyUser { public function __construct () { array_merge ($this->fillable, array( 'salutation', 'title', 'firstname', 'lastname', 'phonenumber', 'mobilenumber' )); } } However, when I run my creation test: public

Emberdata 1.0.0

≡放荡痞女 提交于 2019-12-11 05:31:03
问题 I'm using Laravel 4 with emberjs and I need to list a collection of relationship data on emberjs app, but L4 print collection a little bit different, and so, I am trying to change the REST serialization but no work for now.. My Ember Data version is 1.0.0-beta.7+canary.238bb5ce. somebody help? My JSON DATA: { "names": [ { "id": "1", "description": "List 2014", "user_id": "3", "squares": [ { "id": "1" } ] } ], "squares": [ { "id": "1", "name": "squa1", "role_id": "1" }, { "id": "2", "name":

Laravel whereHas not working in newQuery()

ⅰ亾dé卋堺 提交于 2019-12-11 05:23:40
问题 I'm having some troubles getting a piece of code to work in laravel. I have a SecuredEloquent class that all my 'secured' models extend. what it does is simply add a whereHas clause to the query in the newQuery function I override: class SecuredEloquent extends Eloquent { public function newQuery($excludeDeleted = true) { $query = parent::newQuery($excludeDeleted); $context = App::make('Wall\Context\Context'); $query->whereHas('permissions', function($q) use ($context) { $q->where('context_id

Is Laravel File Uploading Secure if considered only image

蓝咒 提交于 2019-12-11 05:02:17
问题 Laravel basically have following below functions for input type file . // Determine if a file was uploaded Input::hasFile('filename'); // Access file properties Input::file('name')->getRealPath(); Input::file('name')->getClientOriginalName(); Input::file('name')->getClientOriginalExtension(); Input::file('name')->getSize(); Input::file('name')->getMimeType(); If i use getClientOriginalExtension to find correct image extension, getSize to restrict file upload size & getMimeType to check the