laravel-4

Laravel 4 - Hashing same password gives different values

我只是一个虾纸丫 提交于 2019-12-22 04:53:11
问题 I am trying to authenticate a user using the Auth::attempt() method and it keeps failing, so I eventually ended up with the following code: $arr = array(); $arr['verified'] = Hash::make('1234') . ' ; ' . Hash::make('1234'); return json_encode($arr); and this is the result: {"verified":"$2y$10$V4yXBUcxealfLrzOE\/xAD.sJ8qpNhrMA6K6dENBBXYqaVx1zSETgy ; $2y$10$C9xpOWLTUyfy1KL.Y3Tot.KWADmQYFK\/HAf6uZGGXTKcVh52qHS4m"} As you can see, the first hash gives $2y$10$V4yXBUcxealfLrzOE\/xAD

Laravel 4 Blade {{}} and Hogan.js {{}} Syntax

自古美人都是妖i 提交于 2019-12-22 04:42:42
问题 I am using Laravel 4 with the Blade Templating Engine and Hogan.js. By default my site thinks {{...}} is used by PHP and Laravel. Now I want to use Hogan.js and the syntax is {{...}} too. I am getting an error, because they use the same syntax here. How can I use both? 回答1: You can prepend @ to your Hogan placeholders, and Laravel will ignore them. // This will work only in JavaScript @{{ JavaScript }} // This will be rendered in blade {{ $foo }} 来源: https://stackoverflow.com/questions

Left join to get a single row in Laravel

泪湿孤枕 提交于 2019-12-22 04:39:36
问题 I have been unsuccessfully trying to leftjoin and get the required data Here is my code: $album = Albums::->where('users_id',$user_id) ->leftJoin('photos',function($query){ $query->on('photos.albums_id','=','albums.id'); $query->where('photos.status','=',1); // $query->limit(1); // $query->min('photos.created_at'); }) ->where('albums.status',1)->get(); The comments are some of my several trying... I want to get only a single record from the photos table matching the foreign key album_id which

Eloquent firstOrCreate documentation or usage

早过忘川 提交于 2019-12-22 04:39:20
问题 I'm attempting to seek a table to see if a column named "name" exists if so return the value and if not create that row with a null value i saw firstOrCreate but i cannot figure out how to use it for the life of me. This is what i currently have, can someone lend a hand? class Settings extends Eloquent { protected $table = 'settings'; protected $primaryKey = 'name'; public static function get($settingName) { return self::firstOrCreate(array('name' => $settingName)); // return self::select

Multiple Where In

℡╲_俬逩灬. 提交于 2019-12-22 04:19:13
问题 I'm using eloqent to filter a set of products: Product::whereIn('color', $color)->whereIn('size', $size)->whereIn('price', $price)->get(); Each of the above variables is an array of ids $color = [1,2,4,5] My question is, is this inefficient when the user fails to send through a set of variables, say they did not want any color filters so the array would be: $color = []; I've tried ->toSql and it produces the sql statement: select * from `products` where `color` in (?, ?) and 0 = 1 and `price`

Using Cookies in Laravel 4

被刻印的时光 ゝ 提交于 2019-12-22 04:17:06
问题 How do you use cookies in Laravel 4? I'm sure it's simple and something just isn't clicking with me but I need a little help. As far as I can tell, you have to create a cookie like this: $cookie = Cookie::make('test-cookie', 'test data', 30); Then, aside from returning a custom response, how do you set it? What good is setting it with a custom response? When would I ever want to do this? What if I want to set a cookie and return a view? What good does return Response::make('some text')-

Laravel 4 - understanding View::share()

耗尽温柔 提交于 2019-12-22 04:15:21
问题 From what I understand: View::share('foo','bar'); Will make $foo available in all views. However, is it correct to say View::share() can be used only in the __construct() ? Because from outside __construct() I can't make it to work. 回答1: View::share should be available anywhere within your application. A common place that it is used is in view composers, but it should be usable within a route or wherever you need it. 回答2: Yes, adding: View::share('foo','bar'); in your routes.php file will

Changing database name in Laravel/Homestead

核能气质少年 提交于 2019-12-22 03:58:33
问题 I started learning Laravel just an hour ago and following tutorials. My settings for database are as follow (File: app/config/database.php): 'default' => 'mysql', 'connections' => array( 'sqlite' => array( 'driver' => 'sqlite', 'database' => __DIR__.'/../database/production.sqlite', 'prefix' => '', ), 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'laraveltest', 'username' => 'root', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci',

Laravel 4 Migration error - creates two auto_increment primary keys fields

霸气de小男生 提交于 2019-12-22 03:40:58
问题 I made a migration with this setup: $table->increments('id'); $table->integer('user_id', 10)->unsigned(); // this is meant to be used as a foreign key After doing php artisan migrate it returns an error: [Exception] SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table `transactions` (`id` int unsigned not null auto_increment primary key, `user_id` int unsigned not null auto

Deploying Laravel 4 on shared hosting server (hostgator)

别等时光非礼了梦想. 提交于 2019-12-22 01:20:03
问题 I would appreciate your help. I really don't know where else to turn to. I can't deploy a L4 app to Hostgator. I read the guide on the forums, but my shared HG account already has many apps under public_html so deleting it would be catastrophic and a risk I cannot afford to play with. Is there a way to deploy L4 app like any other normal apps? What I am trying to do is the following: home/myuser/public_html/domain.com/laravel/ <--- where the app should live home/myuser/public_html/domain.com