laravel-5.1

Laravel cookie in serviceprovider not comparable

ぐ巨炮叔叔 提交于 2019-12-19 12:45:38
问题 I try to pass a variable based on a cookie value in my compose function to all my view to build my menu, with the use of serviceproviders recommmended here: File: Providers/ViewComposerServiceProvicer.php public function boot(Request $request) { $this->composeTopBar($request);} public function composeTopBar(Request $request) { $cookieValue = $request->cookie('brand'); // if value not set use default value. if($cookieValue == null) { $cookieValue = 1; } $brands = \App\Brand::orderBy('priority'

Redirect back to a specific tab pane in Laravel

天涯浪子 提交于 2019-12-19 10:27:10
问题 I have a index view with 5 tabs. When I click on Hardware tab, this is what I see. When click on create, I launch this Modal As soon as I submit, I got an alert notification, and everything is store fine. But it direct me to my first tab. How can I redirect back to my second tab ? Store Function public function store() { $inputs = Input::all(); unset($inputs['_token']); $cpe_mac = $inputs['mac1'].$inputs['mac2'].$inputs['mac3'].$inputs['mac4'].$inputs['mac5'].$inputs['mac6']; $cpe = []; $cpe[

Laravel asset URL ignoring https

梦想的初衷 提交于 2019-12-19 09:56:41
问题 I am using the following code in my template to load in my CSS file: <link rel="stylesheet" href="{!! URL::asset('css/app.css') !!}"> If I view the page over https on my local machine then the link to the app.css file is also https, however on my live server this isn't happening. If you view the live site over https and view the source you can see that the link to the CSS file is still over normal http and so doesn't load. Does anyone know why this is happening? 回答1: While your users are

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

Change the storage path in Laravel 5

╄→гoц情女王★ 提交于 2019-12-18 19:28:12
问题 I want to change the storage path Laravel 5.1 uses to something like /home/test/storage . This has the advantage that these files are not stored in the repository, which is fairly ugly I think. In Laravel 4 this was very simple with bootstrap/paths.php . In Laravel 5 it this works by using $app->useStoragePath('/path/') in bootstrap/app.php . However, I want to define the storage path with a config option, like $app->useStoragePath(config('app.storage_path') . The config option calls an

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',

TokenMismatchException in VerifyCsrfToken - Laravel 5.1

╄→гoц情女王★ 提交于 2019-12-18 16:32:22
问题 I am building a REST API using Laravel 5.1 and I am getting this error: TokenMismatchException in VerifyCsrfToken.php line 53: Here is my routes.php: Route::controller('city' , 'CityController' ); CityController: class CityController extends Controller { public function postLocalities() { $city = Input::get('cityName'); $response = $city; return $response; } } Here is the Stacktrace of the error when I hit the URL http://localhost:8000/city/localities?cityName=bangalore with POST method.

Response to preflight request doesn't pass access control check Laravel and Ajax call

纵饮孤独 提交于 2019-12-18 16:30:13
问题 I have a REST api made in Laravel 5.1 hosted in a remote server. Now, I', trying to consume that API from another website (that I have in local). In Laravel I set the required lines to send the CORS headers. I also tested the API using Postman and everything seems to be ok! In the Frontend Then, in the website I sent the POST request using ajax, with this code: var url="http://xxx.xxx.xxx.xxx/apiLocation"; var data=$("#my-form").serialize(); $.ajax({ type: "POST", url: url, data: data,

How to change enum type column in laravel migration?

妖精的绣舞 提交于 2019-12-18 14:06:10
问题 I am using Laravel 5.1 and I have a table called packages with this structure: id int(11) weight decimal(10,2) weight_unit enum('Kg.', 'Gm.') I would like to change the weight_unit enum to: weight_unit enum('Grams','Kgs.','Pounds') For this I create the following migration: public function up() { Schema::table('packages', function ($table) { $table->enum('weight_unit', array('Grams','Kgs.','Pounds'))->nullable()->change(); }); } But when I run the migration I receive an error: Unknown

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