laravel-3

Laravel put array into selectbox

不问归期 提交于 2019-12-07 15:38:10
问题 I am facing some problems with my selectbox, where i will put all available categories into the In my controller i am using this snip: return View::make("stories.add") ->with("title","Indsend novelle") ->with("categories", Category::all()); In my view i am trying to put all categories into the selectbox with this: {{Form::select("category", $categories)}} I could make this, but that won't work, because Form::select has to be as an array? @foreach ( $categories as $category ) {{$category->name

Laravel 4: custom login and check password

心已入冬 提交于 2019-12-07 15:34:35
I would like to customize my login in laravel 4 where username is either his username or email so what I did is: public static function custom_login($uname,$pwd) { $res = DB::select("select * from users where (username = ? or email = ?) and password = ? and active = 1",array($uname,$uname,$pwd)); return $res; } Now, we all know that password are hashed so you cant use password = ? . how can I check the password if it's correct? You can use $password = Hash::make($password); function to get the hash of password, and then check it Andreyco I agree with guys here with the principle, but I would

Laravel - Add trailing slash with Redirect::route()

浪子不回头ぞ 提交于 2019-12-07 05:23:59
问题 I'm trying to add a slash to the end of the URL after I use Redirect::route() with Laravel. I've tried numerous examples but couldnt find an answer. This is what I have so far: routes.php : Route::get('/', function() { return Redirect::route('login'); }); Route::get('/login/', array( 'as' => 'login', 'uses' => 'Controller@login' )); Controller.php : public function login() { return 'Login page'; } When I go to htdocs/laravel_project/ , I get redirected to htdocs/laravel_project/login but I

Laravel put array into selectbox

荒凉一梦 提交于 2019-12-06 01:55:23
I am facing some problems with my selectbox, where i will put all available categories into the In my controller i am using this snip: return View::make("stories.add") ->with("title","Indsend novelle") ->with("categories", Category::all()); In my view i am trying to put all categories into the selectbox with this: {{Form::select("category", $categories)}} I could make this, but that won't work, because Form::select has to be as an array? @foreach ( $categories as $category ) {{$category->name}} @endforeach What to do? I have made this and it works, but it looks too ugly and not user-friendly,

Binding View::composer to match all views using wildcards?

我们两清 提交于 2019-12-05 23:14:55
问题 I have a navigation bar like this. <li>Account</li> <ul> <li>Register</li> <li>Login/li> ... I want to update this dynamically depending on Auth::check() . For example, if the user is logged in, "Account" will be changed with "My Profile Page" and child siblings will be replaced with an appropriate array. I need to do this without editing View::make calls in my controllers. It looks pretty bad. A solution like this is what I'm looking for; View::composer('home.*', function($view) { if(Auth:

Use automatic controller routes in Laravel is a bad idea

假如想象 提交于 2019-12-05 09:40:58
I'm coming From CodeIgniter to Laravel. So, is a bad idea using automatic routes to all of controllers? Route::controller(Controller::detect()); Should I use this instead creating routes in routes.php? Yes this is bad. Controller::detect() is actually not present in Laravel 4 because it is a bit broken. detect() will go through your filesystem and return controller files, but this is a bad idea because the order you define your routes matters . If you have any nested controllers you will find this breaking very easily. detect() will also return files in a different order depending on the file

Laravel - Add trailing slash with Redirect::route()

China☆狼群 提交于 2019-12-05 08:31:42
I'm trying to add a slash to the end of the URL after I use Redirect::route() with Laravel. I've tried numerous examples but couldnt find an answer. This is what I have so far: routes.php : Route::get('/', function() { return Redirect::route('login'); }); Route::get('/login/', array( 'as' => 'login', 'uses' => 'Controller@login' )); Controller.php : public function login() { return 'Login page'; } When I go to htdocs/laravel_project/ , I get redirected to htdocs/laravel_project/login but I want it to be htdocs/laravel_project/login/ I want to add that slash to the end of the URL. If I do

Laravel extending class

别说谁变了你拦得住时间么 提交于 2019-12-04 19:40:24
Are there any other steps required to extend a class in Laravel 3? I created application/libraries/response.php : class Response extends Laravel\Response { public static function json($data, $status = 200, $headers = array(), $json_options = 0) { $headers['Content-Type'] = 'application/json; charset=utf-8'; if(isset($data['error'])) { $status = 400; } dd($data); return new static(json_encode($data, $json_options), $status, $headers); } public static function my_test() { return var_dump('expression'); } } But for some reason, neither the my_test() function, or the modified json() function works

Laravel Migrations - Table Prefix Issue

自作多情 提交于 2019-12-04 17:11:03
I'm building a dummy site to test Laravel 3.x. I'm creating my site migrations right now. Everything was doing just fine until the following error showed up: SQLSTATE[42s02]: Base table or view not found: 1146 Table 'databasenamehere.prefix_laravel_migrations' doesn't exist The issue is that laravel all of a sudden started to prefix the 'laravel_migrations' table (when it is supposed to do it only with the other ones). I wonder if I'm doing something wrong or if it is a known issue. I'm trying to run the following migration (using the php artisan migrate application command): public function

How to list out all items in a nested table in Laravel

你。 提交于 2019-12-04 13:15:30
I am using Laravel's Eloquent ORM and I'm having trouble eager loading items for display. Here is the scenario: Users follow Blogs Blogs have Posts I have a database table named Relationships, this table is used to store the User ID and the Blog ID to show which User is following which Blog. I have a table for Blogs describing the Blog and I have a table for Posts. The Relationships table would be my pivot table to connect the Users with the Blogs tables together. Now, I need to list out all the posts from all the Blogs the User follows in a list. Here is my User model: public function