laravel-4

How to make update query with parameters and CASE statement in Laravel 4

微笑、不失礼 提交于 2019-12-22 20:44:49
问题 I'm trying to create mysql UPDATE query that will take parameters. In addition I want to append to the end of the field if the field isnt empty. For that I'm using CASE statement. Here's my query in doctrine (from silex): $query = "UPDATE table SET filed = ( CASE WHEN field = '' THEN :param1 ELSE concat(field, :param1) END) WHERE id=:param2"; $app['db']['test_db']->executeUpdate($sql, array('param1' => $user_text, 'param2' => $selected_id)); Now I want to convert it to fluent or raw query so

How to make update query with parameters and CASE statement in Laravel 4

半世苍凉 提交于 2019-12-22 20:43:09
问题 I'm trying to create mysql UPDATE query that will take parameters. In addition I want to append to the end of the field if the field isnt empty. For that I'm using CASE statement. Here's my query in doctrine (from silex): $query = "UPDATE table SET filed = ( CASE WHEN field = '' THEN :param1 ELSE concat(field, :param1) END) WHERE id=:param2"; $app['db']['test_db']->executeUpdate($sql, array('param1' => $user_text, 'param2' => $selected_id)); Now I want to convert it to fluent or raw query so

Actual directory overwriting Laravel route

戏子无情 提交于 2019-12-22 19:59:40
问题 I'm working in my first project with Laravel, it's a simple website with an admin panel: In my "public" folder I have a directory called "admin" where I put all the styles and scripts corresponding to the admin panel. I've also defined a route in my app to handle the "admin" GET: Route::get('/admin', 'Admin\DashboardController@index'); The problem is that since I have that "admin" folder in my public directory Laravel is ignoring the "admin" route I defined, so I can't access the proper

How can I setup an Laravel project on IIS 7.5?

半腔热情 提交于 2019-12-22 18:57:05
问题 I have a php application that I write using Laravel framework. I developed it using XAMPP server which was running fine. I want to move it to a production server where I can use IIS 7.5 to manage my applications. Here is what I have done I installed IIS I installed PHP Manager Created a folder called laravel in C:\inetpub\wwwroot 2. Using PHP Manager I changed the PHP version to 5.6.18 3. In my php.ini of the version 5.6.18 I enabled the following lines extension_dir = "ext" cgi.force

General error: 1364 Field 'remember_token' doesn't have a default value

假装没事ソ 提交于 2019-12-22 18:44:28
问题 I m new to laravel. I wanted to insert the admin credentials into database. public function verify() { $username = Input::get('username'); $password = Input::get('password'); if (!Admin::count()) { $user = new Admin; $user->username = Input::get('username'); $user->password = $user->password = Hash::make(Input::get('password')); $user->save(); return Redirect::to('/admin/login'); } else { if (Auth::attempt(array('username' => $username, 'password' => $password))) { echo("i m in if"); if

Laravel 4, how to access reverse one-to-many relation?

心不动则不痛 提交于 2019-12-22 18:31:42
问题 Code: <?php class Catering extends \Eloquent { protected $table = 'catering'; public $timestamps = FALSE; public function offers() { return $this->hasMany('Offer', 'cid'); } } class Offer extends \Eloquent { protected $table = 'catering_offer'; public $timestamps = FALSE; public function catering() { return $this->belongsTo('Catering'); } } I am able to do $offers = Catering::find(1)->offers; but , the inverse is not working: $catering = Offer::find(1)->catering; is always returning NULL.

Laravel 4 inherited attributes are null

坚强是说给别人听的谎言 提交于 2019-12-22 18:12:39
问题 I have a model, which inherits from the Toddish\Verify Laravel package (https://github.com/Toddish/Verify-L4/blob/master/src/Toddish/Verify/Models/User.php) All I want to do is add some attributes: use Toddish\Verify\Models\User as VerifyUser; class User extends VerifyUser { public function __construct (array $attributes = array()) { parent::__construct($attributes); $this->fillable = array_merge ($this->fillable, array( 'salutation', 'title', 'firstname', 'lastname', 'phonenumber',

Getting the current row's rank with Laravel

落爺英雄遲暮 提交于 2019-12-22 17:40:08
问题 In my Laravel 4 app, my users table has a votes column. I'd like to find the current user's rank. I can already get the top 10 users with User::orderBy('votes', 'desc')->take(10) , but I'd like to display the current user's rank below that list. Ideally, this would go something like: Auth::user()->rank('orderBy', 'votes', 'desc'); I get the logged in user, I ask for his rank assuming I order the users table by votes. Does anybody know if there's some way I can do this with Eloquent? 回答1:

Laravel - Method link_to_route does not exist

一笑奈何 提交于 2019-12-22 16:35:03
问题 I get an error when i use HTML::link_to_route, but not when i use HTML::Link Why? {{ HTML::decode(HTML::link_to_route('homepage', '<div class="logo"></div>')) }} The same for: {{ HTML::link_to_route('about', 'WHAT IS IT') }} The error: BadMethodCallException Method link_to_route does not exist. Version 4.0.x 回答1: Fixed it, it seems that the documentation is really out-dated, or that laravel 4.0 is just really new ;) replaced "link_to_route" with "linkRoute". Found it by looking into the

Laravel Facebook-Login / missing email

家住魔仙堡 提交于 2019-12-22 14:05:15
问题 I am trying to create a Facebook-Login in my Laravel application. However, the array I get with all the user information does not contain the users email even though I already ask for permission to receive the email. This is my code: Route::get('login/fb', function() { $facebook = new Facebook(Config::get('facebook')); $params = array( 'redirect_uri' => url('/login/fb/callback'), 'scope' => 'email', ); return Redirect::to($facebook->getLoginUrl($params)); }); Route::get('login/fb/callback',