laravel-5.1

find_in_set within left join in Laravel

孤者浪人 提交于 2019-12-23 03:07:58
问题 How can I use the find_in_set() with laravel query builder. Here is my raw query: SELECT * FROM table1 as t1 LEFT JOIN table2 as t2 ON find_in_set(t2.country, t1.fk_country_id) 回答1: You can use DB::raw like as DB::table('table1')->leftJoin('table2', function($join){ $join->on(DB::raw("find_in_set(table2.country, table1.fk_country_id)",DB::raw(''),DB::raw(''))); }); 回答2: you can use DB:raw as in DB::table('table1')->leftJoin('table2', function($join){ $join->on(DB::raw("find_in_set(table2

Laravel sessions and error log files are enormous

╄→гoц情女王★ 提交于 2019-12-23 02:53:28
问题 I noticed something recently that has me a little concerned and at a loss for an explanation. Last week I spun up an EC2 instance running Ubuntu 14.04 to start working on a new Laravel app. Today, I noticed it was taking an unusually long time to sync. I noticed that my sessions folder was close to 1 gig and my log file was over 300 Mb. The log file was full of Token Mismatch Exceptions. Does anybody have any ideas on why this is happening? I should add that everything is working normally. I

How to create Dynamic menus in laravel 5.1?

自古美人都是妖i 提交于 2019-12-23 02:39:09
问题 I am developing an website there I need to create dynamic menus like wordpress .but i am new to laravel .before asking question here, followed below tutorial but didn't got how to do? Refereed: http://learninglaravel.net/laravel-dynamic-menu-tutorial/link http://laravel.io/forum/04-16-2014-dynamic-menu-system https://laracasts.com/discuss/channels/general-discussion/dynamic-menu 回答1: Better late then never, but I've just started learning Laravel too. Start with the following basic tutorials.

Load objects with parameters from Laravel IoC container

半腔热情 提交于 2019-12-23 01:54:28
问题 I need a way to load objects via IoC provider depending on a request parameter. Right now I'm loading my objects directly with App::make(xy, [$urlParamter] which I want to refactor, so that I can use dependency injection the way it is supposed to. To describe my current architecture I need to show you quiet some information and in the end you find my concrete questions I have about it. I'm building up a general CMS framework which provides an import architecture that is extendable with a

Laravel Middleware Auth for API

99封情书 提交于 2019-12-22 12:17:16
问题 I am currently developing and application that has an API which I want to be accessible through middleware that will check if the user is authenticated using either Laravel's default Auth middleware and Tymone's JWT.Auth token based middleware so requests can be authenticated either of the ways. I can work out how to have one or the other but not both, how could I do this? I'm thinking I need to create a custom middleware that uses these existing middlewares? I am using Laravel 5.1 Thanks 回答1

Write output to console from helper class

自古美人都是妖i 提交于 2019-12-22 11:08:06
问题 I have a console command that runs a helper class and I want to write output with $this->info() to the console from the helper class. My code looks like this: App/Http/Console/Commands/SomeCommand.php function handle(Helper $helper) { return $helper->somefunction(); } App/Http/SomeHelper.php function somefunction() { //some code $this->info('send to console'); } Is there any way to write the output to console from the helper? 回答1: I finally figured this out (works in Laravel 5.6) In the

Ajax Post not Working in laravel 5.1

浪尽此生 提交于 2019-12-22 11:06:11
问题 I am trying to post data using ajax in laravel but it seems to be not working. I have followed following is my code login.blade.php <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="csrf_token" content="{{ csrf_token() }}" /> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> <script src="https://ajax.googleapis

How to invalidate particular session in Laravel (with user using remember me feature)

廉价感情. 提交于 2019-12-22 10:49:25
问题 Using Laravel 5.1 & 'file' Session Driver , I'm trying to provide facility to user to track their sessions and invalidate them anytime they wish by keeping a record of their session_id within the database. With Database, I mean, I maintain a table called user_sessions which associates user_id with their session_id (obtained by Session::getId() ). So, to invalidate Session, I tried the following code, $sessionId = Session::getId(); Session::setId($sessionId); Session::invalidate(); and it

LARAVEL UNIT TEST - Opposite of seeInDatabase

本小妞迷上赌 提交于 2019-12-22 05:26:09
问题 In Laravel 5.1 there is a method that asset if some data are in database using the seeInDatabase($table,$fields)... Is there a way to assert if the some data arent in database? Something like dontSeeInDatabase... Similiar to dontSeeJson 回答1: Laravel v5.6 Assertion name has changed ->assertDatabaseMissing(string $table, array $data, string $connection = null) the opposite would be ->assertDatabaseHas(string $table, array $data, string $connection = null) Previous Laravel versions There are two

.ENV file is visible

时间秒杀一切 提交于 2019-12-22 02:01:08
问题 I am using Laravel 5.1 I recently uploaded my project in shared hosting. but when i browse http://siteAddress.com/local/.env my .env file is visible. Is there any way to hide this file or redirect people if they want browse the site with folder view? 回答1: Finally I hide .env and disable index view of the folder named local . I create a .htaccess in folder local . And here is the code of .htaccess # Disable index view Options -Indexes # Hide a specific file <Files .env> Order allow,deny Deny