laravel-4

Laravel 4: Two different view pages for a single URI based on auth status

自古美人都是妖i 提交于 2019-12-07 08:21:47
问题 I have recently got into developing with Laravel 4 and I had a question about routes. For '/', I would like to have two different view pages based on the user's auth status. If a user is logged in and is viewing '/', I would like to show them a view with admin controls and when a user is viewing '/' as a regular user without logging in, I would like to offer a general information view. To accomplish this, I've been playing around with filter 'auth' and 'guest' but am having no luck. // app

How to remove save username and password in composer (laravel 4)

≯℡__Kan透↙ 提交于 2019-12-07 07:57:27
问题 I have updated my laravel vendor using composer. I have bought a package which is located in a github private repo. On downloading composer ask username and password, I have entered the wrong password so it gives me an error. After that I run composer update again but this time it just keep the old wrong password it did not ask me to enter the password again, somewhat save in composer cache. How could I remove the old password in composer? 回答1: In your ~/.composer , you'll have a file named

Laravel 4: how to remember a user when logging him in using Auth::login

↘锁芯ラ 提交于 2019-12-07 07:56:49
问题 My users can login using social options (Facebook, Twitter) and so I don't use the Auth::attempt() method, but the Auth::login() . How can I remember my users so the don't have to login every time they restart the browser? 回答1: It is not in the docs, but if you look at the code; public function login(UserInterface $user, $remember = false) So just do Auth::login($user, true); 来源: https://stackoverflow.com/questions/15051979/laravel-4-how-to-remember-a-user-when-logging-him-in-using-authlogin

Laravel 4: how to write the correct nested controller for nested resource?

南笙酒味 提交于 2019-12-07 07:48:06
问题 In Laravel 4, I wish to create a set of restful resources as follows: http://localhost/posts/1/comments http://localhost/posts/1/comments/1 http://localhost/posts/1/comments/1/edit ... So I created two controllers: PostsController and CommentsController (on the same layer), and the routes are written as below: Route::resource('posts', 'PostsController'); Route::resource('posts.comments', 'CommentsController'); I also created a link in /views/comments/index.blade.php referring to routes: posts

Laravel 4: where is to_array()?

守給你的承諾、 提交于 2019-12-07 07:46:15
问题 Man, this is getting frustrating! In Laravel 4, using Eloquent, this works: var_dump(Worker::find(1)); . But if I try to use to_array() , it falls apart: var_dump(Worker::find(1)->to_array()); . This throws the following exception: call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Database\Query\Builder' does not have a method 'to_array' 回答1: Method in Laravel 4 are now camelCased var_dump(Worker::find(1)->toArray()); 来源: https://stackoverflow.com/questions

Laravel Eloquent Join

[亡魂溺海] 提交于 2019-12-07 07:45:30
I have two tables and I want to join them. I have looked at other examples and just can't figure it out. My tables are as follows. Clubs id name Members id club_id name A club has many members A member belongs to a club I can list my clubs and after listing my clubs i can list the members of the club ok, but what I want to do is list all my members and show their club. So my output would be ID, Name, Club Name This is my code setup so far // clubs controller public function index() { $clubs = Club::all(); return View::make('clubs.list')->with('clubs', $clubs); } public function show($id) {

Laravel 4 except filter in controller constructor

巧了我就是萌 提交于 2019-12-07 06:50:38
问题 Currently I have an AdminContoller with a construct method handling some of the before filters. Is there a way to do a before filter on all controller methods except one? I'm using Entrust for Roles and Permissions, but this code is throwing me into an infinite redirect loop. I'm not logged in as a user at all. So this code should redirect me to the /admin/login url which is attached to an unfiltered AdminController@adminLogin method. But it doesn't? // AdminController.php file class

Laravel 4 controller tests - ErrorException after too many $this->call() - why?

北城余情 提交于 2019-12-07 06:19:43
问题 I'd greatly appreciate some help regarding a Laravel 4 issue I'm experiencing. I'm testing controller routes, specifically a controller that is responsible for routing responses for a questionnaire. I'm testing scenarios such as: the user attempting to skip a question, the user requesting a question that doesn't exist... etc. The tests that I've written for all scenarios up until now work as expected using PHPunit. The test I'm currently writing involves several $this->call() or $this->client

Automatically call asset:publish --bench=“vendor/package” during development in Laravel 4

冷暖自知 提交于 2019-12-07 06:09:31
问题 I'm working on a an package and I really need to be able to fire the php artisan asset:publish --bench="vendor/package" command automatically during development. It's very time consuming to write that command every time I do changes to my JavaScript or CSS files in my packages. I've tried to call Artisan in my service provider public function boot() { Artisan::call('asset:publish', array('--bench' => 'arni-gudjonsson/webber')); ... } i got ErrorException: Runtime Notice: Non-static method

How Laravel knows when the scheduler has been updated?

你离开我真会死。 提交于 2019-12-07 06:04:24
问题 My question is more of a general wondering. I have two commands created using Laravel, let's call them A and B. Each one of these commands are scheduled with the ->dailyAt($par) method. But the $par parameter comes from a query. I mean something like this: protected function schedule(Schedule $schedule) { $schedulerTime_commandA = App\Model\CommandsTime::where('id', 1)->first()->time; $schedulerTime_commandB = App\Model\CommandsTime::where('id', 2)->first()->time; $schedule->command('A') -