laravel-4

Find User in Laravel by Username

主宰稳场 提交于 2019-12-19 16:41:09
问题 So typically if you have access to the id of a user in laravel you can run User::find($id), however say you don't have access to the user's id and only their username. Is there a better way than using DB::query to locate the user? This is my current solution and was wondering if someone possibly knew a better way. $user_id = DB::table('users')->where('username', $user_input)->first()->id; 回答1: Yes, even better using the model. just like this User::where('username','John') -> first(); // or

Laravel 4 - no guessers available issue

孤者浪人 提交于 2019-12-19 15:07:17
问题 I get this error: LogicException: Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?) while trying to upload an image. I have enabled the php_fileinfo extension and also restarted the Wamp web server but I still unable to solve this. What am I missing? Thanks Below are my codes: Models: Product.php class Product extends Eloquent { protected $fillable = array('category_id', 'title', 'description', 'price', 'availability', 'image'); public

Laravel 4 - no guessers available issue

╄→尐↘猪︶ㄣ 提交于 2019-12-19 15:07:11
问题 I get this error: LogicException: Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?) while trying to upload an image. I have enabled the php_fileinfo extension and also restarted the Wamp web server but I still unable to solve this. What am I missing? Thanks Below are my codes: Models: Product.php class Product extends Eloquent { protected $fillable = array('category_id', 'title', 'description', 'price', 'availability', 'image'); public

Laravel 4 - no guessers available issue

只谈情不闲聊 提交于 2019-12-19 15:06:28
问题 I get this error: LogicException: Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?) while trying to upload an image. I have enabled the php_fileinfo extension and also restarted the Wamp web server but I still unable to solve this. What am I missing? Thanks Below are my codes: Models: Product.php class Product extends Eloquent { protected $fillable = array('category_id', 'title', 'description', 'price', 'availability', 'image'); public

Using pivot model data as a relationship to another model in Laravel 4's Eloquent

家住魔仙堡 提交于 2019-12-19 10:45:28
问题 I have a pivot table for a many to many relationship which includes a third index parameter for another model. I would like to be able to use Eloquent to access this model. In my application, I have a User who can have many Subjects and many Semesters . When a user has a Subject , it needs to belong to a given Semester as well. I have a users , subjects and semesters table, as well as a subject_user table (which has user_id , subject_id and semester_id ). When I retrieve the User 's subjects,

Laravel Multiple Unions

泪湿孤枕 提交于 2019-12-19 09:25:05
问题 I'm having an issue adding a query with multiple Unions the "laravel way". The I am trying to accomplish a query equivalent to the one generated by the following: $ipsql = ""; for ($n = 1; $n < $total_networks; $n++) { $ipsql .= "(SELECT * FROM ip WHERE network = " . $n . " AND used = 0 LIMIT 5) UNION ALL"; } if ($n == $total_networks) { $ipsql .= "(SELECT * FROM ip WHERE network = " . $n . " AND used = 0 LIMIT 3) ORDER BY ip_addr"; } I haven't found an option for unions with Eloquent so I

Laravel Deployment

让人想犯罪 __ 提交于 2019-12-19 07:58:41
问题 I have a working Laravel application on my desktop. I am trying to deploy it to a godaddy server. The application has been copied and verified on the server in the same structure format as on my desktop. I have changed the database information in the config to the proper entries. When I run from the server I get the error: FatalErrorException Class 'name of the class' not found. The error is generated in the Routes.php file. Again this app works locally, any idea why it errors when deployed?

Laravel case insensitive routes

谁说胖子不能爱 提交于 2019-12-19 07:16:12
问题 How do I define a case insensitive (part of a) route? Example: Route::get('/{userId}/profile'); http://domain.com/123/profile works fine. Any use of uppercase in the fixed part of the route does not work: http://domain.com/123/Profile does not work http://domain.com/123/proFILE does not work I understand how I can make parameters like {parameter} use a regex pattern using ->with(), but that does not help me with the fixed part of the route, like described above. 回答1: This can be solved by

Refund users using paypal rest API

烈酒焚心 提交于 2019-12-19 04:57:08
问题 I'm developping a web application on which I allow the users to buy a ticket for an event. I used the Paypal Rest API for sending money and purchasing the tickets.Everything is working just fine. Now I'm trying to use the refund method to refund all users related to an event when this event will be cancelled. Looking in the REST API documentation I found that there is a way to refund but when I search in the REST API package for laravel I haven't found how to refund or use the refund method.

How to pass query string params to routes in Laravel4

烂漫一生 提交于 2019-12-19 04:16:06
问题 I'm writing an api in Laravel 4. I'd like to pass query string parameters to my controllers. Specifically, I want to allow something like this: api/v1/account?fields=email,acct_type where the query params are passed along to the routed controller method which has a signature like this: public function index($cols) The route in routes.php looks like this: Route::get('account', 'AccountApiController@index'); I am manually specifying all my routes for clarity and flexibility (rather than using