laravel-4

Populate a dropdown on selecting an option from another dropdown Laravel

℡╲_俬逩灬. 提交于 2019-12-13 01:43:18
问题 Hope you're having a nice day and i'm much clear to describe my problem :) I have a table of categories and a table of sub-categories. In my view, I want to let the user select a sub-category belonging to a category, for adding a product (Every product belongs to a sub-category). For that purpose, I want to show the user sub-categories when he selects a category. Like when he selects Clothes from Categories, I want to show Sub-categories like tops, shorts etc. How do I do that? Just an idea

Automatically Assign Values To $fillable attribute (Laravel 4)

流过昼夜 提交于 2019-12-13 01:24:02
问题 I'm trying to Sync data from a Localhost database to a Live one using Laravel 4. Everything works fine except for a table where columns' are dynamic. So in my Model I did something like: <?php class myModel extends \Eloquent { protected $fillable = []; protected $connection = 'live'; protected $table = "myLiveTable"; public function __construct() { $this->setFillable(); } public function setFillable() { $fields = someSQLHandler::getColumns('myLocalTable'); $this->fillable = $fields; } } in

Call to a member function getAction() on a non-object

随声附和 提交于 2019-12-13 00:48:48
问题 Hi there i followed these instructions (http://pietervogelaar.nl/php-xdebug-netbeans-vagrant/) to get XDebug up and running with vagrant and NetBeans . It now works .... almost. Anytime i run a code that fire a breakpoints, NetBeans works fine allowing me to do my debug thing with no problems. The thing is at the end of the request Laravel will always return that error : Call to a member function getAction() on a non-object , specifying a code location that looks weird : xdebug:/­/­debug-eval

How to overwrite Laravel's database connection

*爱你&永不变心* 提交于 2019-12-13 00:42:30
问题 Folks, I've been trying to overcome this issue for more than 10 hours now and I've decided to look for help before going insane. What I'm trying to achieve is some sort multi-tenancy where I have a dedicated database for each customer and depending on the issuer of the request the concrete database should be loaded. E.g. if customer A sends a request, load database A, if B sends the request, load database B. We have thousands of customers, so having all configs predefined in the databse.php

How to create token-based authentication in laravel 4?

点点圈 提交于 2019-12-13 00:12:54
问题 I've been suggested to use token-based authentication, in order to secure my webservices, and to create another filter that verifies tokens, apart from auth. The idea is to use the auth filter for log-in, which I have already done in the backend, and to create a new filter for webservices. Could someone recommend a good tutorial on how to do this, or give me an example? 回答1: This is what i use, specifically for mobile app web services: https://github.com/lucadegasperi/oauth2-server-laravel

MySQL Query in Laravel Eloquent

放肆的年华 提交于 2019-12-13 00:11:13
问题 How can I do the equivalent in Eloquent (i.e. Model::where(...)->join(...) ?: DB::select('SELECT users.id, users.username FROM users, teams, teams AS teams2 WHERE users.team_id = teams2.id AND teams.id = ? AND teams2.l BETWEEN teams.l AND teams.r', [$id]) 回答1: Edited: $team = Team::find($id); $users = User::join('teams', 'teams.id', '=', 'users.team_id') ->whereBetween('teams.l', [$team->l, $team->r]) ->get(['users.id', 'users.username']); 来源: https://stackoverflow.com/questions/41714718

Laravel dependency cannot be retrieved via composer. Alternative for getting L4 source ?

↘锁芯ラ 提交于 2019-12-13 00:07:57
问题 I have a error happening for 2 days now I simply cannot get full L4 source via Composer no matter what I try. I'm behind Windows 8 & WAMP x64 PHP 5.4 mod_ssl and openssl_module enabled. I tried multiple locations/pc's/networks all throw same error. http://nodeload.github.com/php-fig/log/zip/fe0936ee26643249e916849d48e3a51d5f5e278b Following resource cannot be retrived by composer. Here is copy paste out of my terminal: Mode LastWriteTime Length Name ---- ------------- ------ ---- d---- 9/6

Laravel 4 - public directory being treated as a route - image not showing

旧城冷巷雨未停 提交于 2019-12-12 22:45:20
问题 I have this problem with Laravel 4's view. The code in view.blade.php is: {{ HTML::image("public/images/storage/$user_upload->image.jpg") }} which yields http://dev.local/public/images/storage/1_thy9WFfBw.jpg That is the correct image location, yet as being accessed by the framework, it turns out to be not accessible (i.e. HttpNotFound exception thrown). See screenshot: http://imgur.com/kKLu30L I think the framework somehow treats this URL as a route resource rather than a public asset. Is

Associating a child model in a polymorphic relationship causes an infinite loop?

不打扰是莪最后的温柔 提交于 2019-12-12 21:24:35
问题 I have a base Message class for an inbox using a polymorphic relationship to attach custom message types which all implement the same interface and behave differently in views based on their type. Display of that all works swimmingly, but I hit a snag when I tried to actually add these with code. This is the Message class: <?php class Message extends Eloquent { public function author() { $this->belongsTo("User", "author_id"); } public function recipient() { $this->belongsTo("User", "recipient

Laravel - getting largest object based on attribute value

纵然是瞬间 提交于 2019-12-12 18:35:22
问题 I have been trying to get the four highest objects based on an attribute in them. I can successfully get the one with the highest value by doing the following: {{ Bid::where('auction_id', '=', $auction->id)->max('bid_amount') }} Which gets the object which have the highest bid_amount value. Now I could potentially make a loop and loop all bids through but Laravel must have a smarter way of doing it and I have not been able to find this in their documentation. 回答1: You may try this Bid::where(