laravel-3

Laravel 3 Schema Table Column Collation

柔情痞子 提交于 2021-02-06 09:34:49
问题 I'm learning laravel, and I'm stuck on a simple process. I want the tables to be generated as UTF-8 but varchar and text fields are like latin-1. Schema section in guide did not help at all. I found this GitHub entry but it does not work neither (throws me errors). I have a schema like this: <?php class Create_Authors_Table { /** * Make changes to the database. * * @return void */ public function up() { Schema::create('authors',function($table){ //$table->charset('utf8'); //does not work //

Laravel - Pass more than one variable to view

二次信任 提交于 2020-01-27 03:21:33
问题 I have this site and one of its pages creates a simple list of people from the database. I need to add one specific person to a variable I can access. How do I modify the return $view->with('persons', $persons); line to also pass the $ms variable to the view? function view($view) { $ms = Person::where('name', 'Foo Bar'); $persons = Person::order_by('list_order', 'ASC')->get(); return $view->with('persons', $persons); } 回答1: Just pass it as an array: $data = [ 'name' => 'Raphael', 'age' => 22,

Laravel - Using (:any?) wildcard for ALL routes?

五迷三道 提交于 2020-01-18 21:37:27
问题 I am having a bit of trouble with the routing. I'm working on a CMS, and i need two primary routes. /admin and /(:any) . The admin controller is used for the route /admin , and the view controller should be used for anything else than /admin . From the view controller, i will then parse the url and show the correct content. This is what i have: Route::get(array('admin', 'admin/dashboard'), array('as' => 'admin', 'uses' =>'admin.dashboard@index')); Route::any('(:any)', 'view@index'); The first

Laravel - Using (:any?) wildcard for ALL routes?

拟墨画扇 提交于 2020-01-18 21:37:08
问题 I am having a bit of trouble with the routing. I'm working on a CMS, and i need two primary routes. /admin and /(:any) . The admin controller is used for the route /admin , and the view controller should be used for anything else than /admin . From the view controller, i will then parse the url and show the correct content. This is what i have: Route::get(array('admin', 'admin/dashboard'), array('as' => 'admin', 'uses' =>'admin.dashboard@index')); Route::any('(:any)', 'view@index'); The first

Laravel - Using (:any?) wildcard for ALL routes?

拥有回忆 提交于 2020-01-18 21:36:10
问题 I am having a bit of trouble with the routing. I'm working on a CMS, and i need two primary routes. /admin and /(:any) . The admin controller is used for the route /admin , and the view controller should be used for anything else than /admin . From the view controller, i will then parse the url and show the correct content. This is what i have: Route::get(array('admin', 'admin/dashboard'), array('as' => 'admin', 'uses' =>'admin.dashboard@index')); Route::any('(:any)', 'view@index'); The first

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

你离开我真会死。 提交于 2020-01-13 05:39:11
问题 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

Protecting all admin/ routes with auth in Laravel

℡╲_俬逩灬. 提交于 2020-01-12 03:30:10
问题 I am brand new to laravel and am setting up admin panel authorization on my first application. The way I have my files setup currently setup is: controllers/ admin/ dashboard.php settings.php non-admin-controller1.php non-admin-controller1.php views/ admin/ dashboard.blade.php login.blade.php template.blade.php non-admin-view1.php non-admin-view1.php non-admin-view1.php ...and these are my routes Route::get('admin/login', function() { return View::make('admin.login'); }); Route::get('admin

How to run php script on the command line while accessing laravel environment and classes

旧城冷巷雨未停 提交于 2020-01-04 04:45:09
问题 I have a laravel 3 environment on a web server but I want to run a php script on the command line. I'd like to access the same classes and methods that any php script within the laravel environment (for example a controller, model or view file) accesses. How can I do that? 回答1: I would highly recommend that you migrate your PHP script over to an artisan command. You can find more information here: http://laravel.com/docs/commands This basically gives you access by default, as well as a lot of

Use automatic controller routes in Laravel is a bad idea

丶灬走出姿态 提交于 2020-01-02 04:19:07
问题 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? 回答1: 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

Can someone explain session table laravel

喜欢而已 提交于 2019-12-24 08:56:47
问题 Ok so I want to check if my users are online or not, I think a good way of doing this is using the sessions table that laravel provides. I'm a newbie though so can anybody first of all explain to me what this data means. CREATE TABLE sessions ( id VARCHAR(40) NOT NULL, last_activity INT(10) NOT NULL, data TEXT NOT NULL, PRIMARY KEY ( id ) ); last_activity is a unix timestamp, that one is clear to me. My id = lGBzJ0dIWiebrwjFlkQAE19NHuNHvsPRVS7e4CRO This is equal to the cookie value but that