laravel-5.1

Using Laravel Auth middleware

谁说我不能喝 提交于 2019-12-18 11:57:49
问题 Laravel 5.1 really had minimal documentation.. I need clear idea about how to protect routes using Auth middileware.. Documentation tells to add "middleware" => "auth" parameter to route. or can do public function __construct() { $this->middleware('auth'); } But How to use Auth middleware for actual user authentication and auto redirection to /login from protected routes ?? 回答1: In Kernel.php - there are registered middlewares under protected $routeMiddleware like this: /** * The application

How to clear Route Caching on server: Laravel 5.2.37

匆匆过客 提交于 2019-12-18 10:39:32
问题 This is regarding route cache on localhost About Localhost I have 2 routes in my route.php file. Both are working fine. No problem in that. I was learning route:clear and route:cache and found a small problem below. if I comment any one route in my route.php file and then run below command php artisan route:cache This will keep the route disabled because the route list is in cache now. Now, go to route.php file and try to remove commented route and then try to run that enabled url. still it

Unencrypted cookie in Laravel

时光怂恿深爱的人放手 提交于 2019-12-18 06:14:09
问题 I need to read a cookie in JS set by my Laravel app. Is there a way to do this in Laravel (as opposed to setting it directly through PHP) without overriding classes? 回答1: See the EncryptCookies Middleware - this allows you to set the exceptions; that is, cookies that are not to be encrypted. namespace App\Http\Middleware; use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter; class EncryptCookies extends BaseEncrypter { /** * The names of the cookies that should not be encrypted. *

Laravel - Set global variable from settings table

最后都变了- 提交于 2019-12-17 22:24:31
问题 I'm trying to store all my settings from my settings table into a global variable, but I'm stucked now(I have no idea what's the next step), this is my actual model and seeder: model - Settings.php class Setting extends Model { protected $table = 'settings'; public $timestamps = false; protected $fillable = [ 'name', 'value', ]; } seeder - SettingsTableSeeder.php class SettingsTableSeeder extends Seeder { public function run() { $settings = [ ['name' => 'title', 'value' => ''], ['name' =>

post request not working Laravel 5

落爺英雄遲暮 提交于 2019-12-17 21:18:47
问题 I am trying to submit a form using post method, but it does not seem to be working. I have enabled error debug on but still no error is shown. After submitting the form the same page is loaded without any errors. This is my route Route::post('/home' , ['as' => 'store-post' , 'uses'=>'FacebookControllers\PostsController@save']); And my form is {!! Form::open(['route'=>'store-post' , 'class'=>'form'])!!} <div class="form-group"> <label for="textarea"></label> <textarea class="form-control" rows

laravel 5 : Class 'input' not found

半世苍凉 提交于 2019-12-17 17:25:28
问题 In my routes.php file I have : Route::get('/', function () { return view('login'); }); Route::get('/index', function(){ return view('index'); }); Route::get('/register', function(){ return view('register'); }); Route::post('/register',function(){ $user = new \App\User; $user->username = input::get('username'); $user->email = input::get('email'); $user->password = Hash::make(input::get('username')); $user->designation = input::get('designation'); $user->save(); }); I have a form for users

disable csrf in laravel for specific route

心不动则不痛 提交于 2019-12-17 15:53:39
问题 I've a payment system, where data is submitted to 3rd party site and than hauled back... When data returns it hits specific url lets say /ok route. $_REQUEST['transaction'] . But because of laravel middleware I'm getting token mismatch. There is no way 3rd party payment API can generate token, so how I disable it? only for this route? or is there a better option? Route::get('/payment/ok', 'TransactionsController@Ok'); Route::get('/payment/fail', 'TransactionsController@Fail'); public function

Laravel 5.1 API Enable Cors

ε祈祈猫儿з 提交于 2019-12-17 02:29:54
问题 I've looked for some ways to enable cors on laravel 5.1 specifically, I have found some libs like: https://github.com/neomerx/cors-illuminate https://github.com/barryvdh/laravel-cors but none of them has a implementation tutorial specifically to Laravel 5.1, I tried to config but It doesn't work. If someone already implemented CORS on laravel 5.1 I would be grateful for the help... 回答1: Here is my CORS middleware: <?php namespace App\Http\Middleware; use Closure; class CORS { /** * Handle an

How to to send mail using gmail in Laravel 5.1?

ⅰ亾dé卋堺 提交于 2019-12-17 02:28:13
问题 I try again and again to test sending an email from localhost but I still cannot. I don't know anymore how to do it. I try search to find solution but I cannot find one. I edited config/mail.php: <?php return [ /* |-------------------------------------------------------------------------- | Mail Driver |-------------------------------------------------------------------------- | | Laravel supports both SMTP and PHP's "mail" function as drivers for the | sending of e-mail. You may specify

How to manually add ClassLoader in Laravel 5

岁酱吖の 提交于 2019-12-14 03:55:51
问题 I want add my class to classloader by this commands $loader = new \Composer\Autoload\ClassLoader(); $loader->addPsr4('test\\', __DIR__ . '/../..' . '/modules/test'); $loader->register(); but dose not work and no error dd($loader) : ClassLoader {#470 ▼ -prefixLengthsPsr4: array:1 [▼ "t" => array:1 [▶] ] -prefixDirsPsr4: array:1 [▼ "test\" => array:1 [▼ 0 => "C:\wamp\www\app\Http\Controllers\admin/../../modules/test" ] ] -fallbackDirsPsr4: [] -prefixesPsr0: [] -fallbackDirsPsr0: []