laravel-4

nginx - laravel - hhvm-Fastcgi get error 500

拥有回忆 提交于 2019-12-05 11:44:40
I install a LEMP server in ubuntu 12.04 LTS 64 whit HHVM Fastcgi Service and i install laravel via laravel.phar ( and test via composer too ) when in get my site in brwoser do not display any error but in chrome developer console get error 500 i can't see any error in error.log file ( laravel - hhvm , nginx ) the storage directory Permissions is 777 and my nginx.conf and vhosts file have basic configuration when i use PHP CLI or hhvm command it's worked good thanks for help me :) my location block location ~ \.(hh|php)$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_keep_conn on; fastcgi

How to prevent SQL injection in Laravel?

谁都会走 提交于 2019-12-05 11:40:04
问题 In my controller I have this code: public function create($brand_id) { Brand::findOrFail($brand_id); } and this: public function search() { $q = Input::get('q'); $brands = Brand::where('title', 'LIKE', '%'.$q.'%')->take(80)->get(); Is this code safe? By "safe" I mean SQL injection safe. Or should I do some variable clean up here? And what is the best way for cleaning up user input? Thanks a lot for helping me :) 回答1: yes Eloquent uses parameter binding behind the scene, which safely escapes

mockery->shouldReceive() passing when it shouldnt?

不羁岁月 提交于 2019-12-05 11:21:05
I am learning unit testing in laravel using phpunit and mockery. I am currently trying to test UsersController::store(). I am mocking User Model and using it to test the index method and that seems to work. When I take out $this->user->all() the test fails and when its in it passes. When testing the store method though I am using the mock to test that the user model receives validate() once. The store method is empty but the test passes. I have left out the irrelevant pieces of the class for brevities sake <?php class UsersController extends BaseController { public function __construct(User

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

烂漫一生 提交于 2019-12-05 10:12:39
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 Illuminate\Foundation\Artisan::call() should not be called statically, assuming $this from incompatible

How Laravel knows when the scheduler has been updated?

半腔热情 提交于 2019-12-05 09:56:55
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') ->dailyAt($schedulerTime_commandA); $schedule->command('B') ->dailyAt($schedulerTime_commandB); } This is

laravel how to route to a route on a javascript?

时光怂恿深爱的人放手 提交于 2019-12-05 09:56:31
I have this jquery $(".waitingTime .button").click(function () { alert("Ema"); }); I have a a tag like this: <a href="{{ URL::to('restaurants/20') }}"></a> Can I do the same href action in the jquery function? Many Thanks yes this is possible and has nothing to do with Laravel. There are different possibilities. If your query is embedded within the same laravel view, you put the URL directly in your jQuery code, for example like this: $(".waitingTime .button").click(function () { window.location.href = "{{URL::to('restaurants/20')}}" }); But I think the best option is to add the URL on your

Laravel : BadMethodCallException Method [find] does not exist

假如想象 提交于 2019-12-05 09:51:49
when trying to extract some values from the database using the model object User I get the following error : BadMethodCallException Method [find] does not exist Here are my files : Model User <?php use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableInterface; class User extends Eloquent implements UserInterface, RemindableInterface { /** * The database table used by the model. * * @var string */ protected $table = 'users'; /** * The attributes excluded from the model's JSON form. * * @var array */ protected $hidden = array('password'); public function projects() {

How to build a Laravel route that requires a specific URL query parameter?

允我心安 提交于 2019-12-05 09:27:46
Let's say I have URLs like this: localhost/ admin/users/ <--- Main Admin Users page localhost/ admin/users/?data=refresh <---- A typical ajax request made from that page And a simple controller like this: class UsersController extends Controller { public function index() // call some services // return a view } public function dataRefresh { // call some services // return some JSON } } And here's my routes.php I'm working on: Route::get('admin/users', array('as' => 'admin.users', 'uses' => 'Admin\Users\UsersController@index')); Route::get('admin/users????' , array('before' => 'ajax', 'as' =>

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 4 how check if a route only comes/redirected from another route?

你离开我真会死。 提交于 2019-12-05 08:27:15
Say i have localhost/public/admin that redirects immediately to localhost/public/user/login . How am I going to get the admin value in user/login ? You'll need to grab the referer and check if it is contains 'admin'. Try the following $referer = Request::referer(); // or // $referer = Request::server('HTTP_REFERER'); if (strpos($referer,'admin') !== false) { dd('coming from admin') } Edit #1: As pointed out by @tomvo you can also use URL::previous() instead of Request::referer() in L4 Edit #2: It's actually mispelled as referer instead of referrer as point out by @JamesF Edit #3: In Laravel 5