laravel-5.2

distinct() with pagination() in laravel 5.2 not working

倖福魔咒の 提交于 2019-12-19 07:27:49
问题 I'm trying to use distinct() with pagination() in laravel 5.2 with fluent and it's given result proper but pagination remain same(Like without apply distinct). I have already reviewed and tested below answers with mine code - laravel 5 - paginate total() of a query with distinct - Paginate & Distinct - Query Builder paginate method count number wrong when using distinct My code is something like: DB::table('myTable1 AS T1') ->select('T1.*') ->join('myTable2 AS T2','T2.T1_id','=','T1.id') -

Laravel 5.2 : Do something after user has logged in?

风格不统一 提交于 2019-12-19 05:06:30
问题 (I'm a beginner of Laravel) I'm using Laravel 5.2 . I have successfully enabled the Authentication; by doing the php artisan make:auth and stuffs. So my login is working. Now i need to do something once someone has logged in. For an simple example: LOGIN: Once a user has logged in, write a value into Session. For example: $request->session()->put('UserAgent', $ClientUserAgent); LOGOUT: Same thing to do, once a user has logged out, delete the custom Session value. For example: $request-

auth()->user() is null in Laravel 5.2

眉间皱痕 提交于 2019-12-19 03:26:07
问题 I just update the composer to Laravel 5.2 and not able to view password protected pages. Basically below line of code is not working. auth()->user() Can somebody suggest why this is not working ? 回答1: Make sure any routes that require sessions (which Auth uses) are behind the 'web' middleware group. Route::group(['middleware' => 'web'], function () { // your routes }); This is a change that is new to 5.2. By default routes do not have this middleware stack applied. The web middleware group

Access files in storage folder only through Auth Middleware and Token based authentication

隐身守侯 提交于 2019-12-18 16:59:15
问题 I have following folder in my Laravel website. /storage/Asset/Media This folder can have info like below /storage/Asset/Media/1/abc.png /storage/Asset/Media/2/abc.png Here 1 or 2 is the folder names. I have following code to secure the folder so that nobody can access the folder without authentication Route::group(['middleware' => ['web', 'auth']], function () { Route::get('/storage/Asset/Media/{ID}/{eded}', array( 'as' => 'Files', 'uses' => 'User\Account\Media\MediaController@DownloadMedia',

what is the difference between X-XSRF-TOKEN and X-CSRF-TOKEN?

浪子不回头ぞ 提交于 2019-12-18 13:06:13
问题 When use hidden field and when use header and why ? X-XSRF_TOKEN when we use? X-CSRF TOKEN when we use? 回答1: when you are submitting your data using ajax you will need headers for CSRF token because ajax will not send the token along with the data. You can use hidden field for ajax request with following code $.ajaxSetup( { headers: { 'X-CSRF-Token': $('input[name="_token"]').val() } }); but you will have to add hidden field for every ajax requests. The difference between the X-CSRF-TOKEN and

Fatal error while upgrading Laravel 5.1 to 5.2

我是研究僧i 提交于 2019-12-18 12:44:38
问题 I'm following the official upgrade guide from 5.1 to 5.2. First sub-section says: If you are installing a beta release of Laravel 5.2, add "minimum-stability": "beta" to your composer.json file. Update your composer.json file to point to laravel/framework 5.2.* . Add symfony/dom-crawler ~3.0 and symfony/css-selector ~3.0 to the require-dev section of your composer.json file. Now, after I introduce the above changes and run composer update , I get the following error(s): PHP Fatal error: Class

How to store multi select values in Laravel 5.2

二次信任 提交于 2019-12-18 12:34:18
问题 I have a form which stores News. Here I am using Multiselect and I want to save all the selected option in the table as say Users,staff,cinemahall as a string. My controller function to store values is public function store(Request $request) { $input=$request->all(); General_news::create($input); return redirect()->back(); } This function store the all submitted fields but for multiselect it stores only last option i.e cinemahall When form is submitted all selected options are displayed but

Eloquent get only one column as an array

拟墨画扇 提交于 2019-12-18 11:38:01
问题 How to get only one column as one dimentional array in laravel 5.2 using eloquent? I have tried: $array = Word_relation::select('word_two')->where('word_one', $word_id)->get()->toArray(); but this one gives it as 2 dimentional array like: array(2) { [0]=> array(1) { ["word_one"]=> int(2) } [1]=> array(1) { ["word_one"]=> int(3) } } but I want to get it as: array(2) { [0]=>2 [1]=>3 } 回答1: You can use the pluck method: Word_relation::where('word_one', $word_id)->pluck('word_two')->toArray();

Laravel dynamic config settings

孤人 提交于 2019-12-18 11:20:17
问题 I'm using a package within my project and it stores a setting inside config/packagename I would like to dynamically change this value inside the config file, this is how the file structure looks currently; <?php return [ 'view_id' => '118754561', 'cache_lifetime_in_minutes' => 60 * 24, ]; I would like to change it to something like this - 'view_id' => Auth::user()->id, Can you do this within the config file, or do you have to store some sort of variable to be updated later within a controller

How to get login with different database table column name in Laravel 5.2?

烂漫一生 提交于 2019-12-18 11:12:51
问题 I have to implement login functionality in Laravel 5.2. I have successfully done so using the official Laravel documentation except that I do not know how to authenticate the user using different database table column names, namely st_username and st_password . I have searched the Internet for clues but to no avail. I don't know which class I need to use (like, use Illuminate.......) for Auth. If any one knows the answer, please let me know. Here is my code: Login View @extends('layouts.app')