laravel-4

Laravel 4 defining RESTful controllers

狂风中的少年 提交于 2019-12-20 08:39:22
问题 So I'm new to the Laravel framework as of v4 and wondering what is the way to create and use RESTful controllers. Reading through the documentation, I'm a bit confused as to the difference between RESTful controllers and Resource controllers. When defining a RESTful controller, as per the docs, it suggests doing the following in routes.php : Route::controller('posts', 'PostController'); In the PostController , do we define the class methods by prefixing the name of the method with the HTTP

Laravel redirect with logout not working

微笑、不失礼 提交于 2019-12-20 08:18:37
问题 I am Using laravel 4 framework's. When I used redirect after the Auth::logout(), the redirection was not working. I used View::make() too, but same "Whoops, looks like something went wrong." error throws up. public function getLogout() { Auth::logout(); return Redirect::to('users/login')->with('message', 'Your are now logged out!'); } This is the logout code. I am using. Some one please help me with this. routes.php Route::get('/', function() { return View::make('hello'); }); Route:

open_basedir, File() is not within the allowed path

一笑奈何 提交于 2019-12-20 07:29:08
问题 I'm having an issue with Laravel, installed on a Media Temple DV: tempnam(): open_basedir restriction in effect. File() is not within the allowed path(s): (/var/www/vhosts/mywebsite.com/:/tmp/) This is the code that is giving this issue: if (empty($this->cookie_file)) { $this->cookie_file = tempnam("", "phrets"); } I'm thinking that it might be a permissions thing, but I'm really not too sure. 回答1: It seems you need to add directory you use form tempnam into open_basedir or ask your server

Laravel 4 Form::selectMonth prepend month

巧了我就是萌 提交于 2019-12-20 07:27:09
问题 How can I prepend an option into laravel {{ Form::selectMonth('month') }} Result <select name="month"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12"

Vagrant, Codeception & Laravel issue. NotFoundHttpException

和自甴很熟 提交于 2019-12-20 06:41:11
问题 I'm trying to get into using codeception for my acceptance testing. I have the following for one of my tests: <?php use Codeception\Util\Stub; class SomeTest extends \Codeception\TestCase\Test { protected $webGuy; /** * @test */ public function incorrect_login_should_redirect_back() { $I = $this->webGuy; $I->wantTo('fail at logging in'); $I->amOnPage('/'); // <-- This is the line that is failing $I->fillField('email','info@tntstudio.hr'); $I->fillField('password','pass'); $I->click('Login');

Download tcpdf manually without using composer in Laravel 4

放肆的年华 提交于 2019-12-20 06:39:46
问题 I'm trying to download TCPDF library to my project using Composer (Laravel 4), but I can't. Sometimes this error occurs (http://i.stack.imgur.com/aaPDz.jpg) and sometime this error (http://i.stack.imgur.com/quXMB.jpg) I want to download it and add it in laravel manually without using composer. 回答1: When you say "without using composer ", I'm going to assume you mean "without using composer for the download". With the following solution you'll still need to invoke a composer command, but its

Laravel Migration Error :: PDOException, Could not find driver

…衆ロ難τιáo~ 提交于 2019-12-20 06:39:02
问题 I am trying to make a laravel and stucked when migration. when i enter php artisan migrate in terminal, showing PDOException error. attaching my screenshot of terminal and phpinfo. What i sthis issue, How can i solve this, I am using Xampp. Anybody please help me. Thanks 回答1: Try re-installing Xampp? You could use Laravel homestead for a virtual machine, it makes sure you have the proper PHP version and the required dependencies needed to install and avoids having to run Xampp or MAMP or WAMP

Display BLOB image Laravel 4

泪湿孤枕 提交于 2019-12-20 06:27:54
问题 I have added png images as BLOB on mysql but when I try to retrieve them, I got them as files but can't display as images. Below is my code. //Controller public function post_news(){ $image = Input::file('image'); $filename = $image->getClientOriginalName(); $base64 = base64_encode($filename); $news = new News(); $news->title = Input::get('title'); $news->description = Input::get('desc'); $news->image = $filename; $news->save(); return Redirect::to('news')->withErrors(['This news has been

Laravel eager loading with constraints

岁酱吖の 提交于 2019-12-20 06:25:06
问题 So my model has 2 simple relationships. Then eager loading works perfectly like this: Entry::with('author', 'lastModifiedBy')->...; But say I want to add a new relationship that takes a constraint. For example: public function foo() { return $this->hasOne('Foo')->latest('id'); } Then to eager load this relationship, Laravel suggests doing it like so: Entry::with(array('foo' => function($query) use ($id) { $query->where('user_id', $id); }))->...; But if I want to include my author and

Call laravel controler from an ajax request with get / put / delete method

六眼飞鱼酱① 提交于 2019-12-20 06:14:24
问题 I am having a javascript like this which will call two different controller in two diff situation .... Now the problem is it is one get method and one is destroy method ... when the call is generated, the controller functions never triggered. No idea wheather the url method is right or not. It is giving the 500 error. I am also not sure about the response back from the controller. but before that I need to execute the database operation in the controller ... which is not going to execute.