laravel-5.2

What is the difference between {{ }} and {!! !!} in laravel blade files?

喜夏-厌秋 提交于 2019-11-27 01:31:45
In the laravel framework we can use blade to add PHP code in html file. We are using both {{ }} and {!! !!} syntax in blade files of Laravel. What is the difference between them? Narendrasingh Sisodia Blade {{ }} statements are automatically sent through PHP's htmlentities function to prevent XSS attacks. If you pass data from your Controller to a View with some HTML styling like: $first = "<b>Narendra Sisodia</b>"; And it is accessed, within Blade, with {{ $first }} then the output'll be: <b>Narendra Sisodia</b> But if it is accessed with {!! $first !!} then the output'll be: Narendra Sisodia

Resize image in Laravel 5.2

人走茶凉 提交于 2019-11-27 01:10:20
问题 Can anyone help me how to implement resizing image in Laravel? I have this code only: if($request->hasFile('image')){ if (Input::file('image')->isValid()) { $file = Input::file('image'); $destination = base_path() . '/public/images/ServiceImages'; $extension = Input::file('image')->getClientOriginalExtension(); $fileName = rand(111,99999).'.'.$extension; if(!empty($data['Image'])){ unlink($destination.$data['Image']); } $file->move($destination, $fileName); $service->image=$fileName; } } 回答1:

Validation error in Laravel - $errors array does not get populated after the validation failure

情到浓时终转凉″ 提交于 2019-11-26 23:31:15
问题 I've ran into a strange issue regarding validations in Laravel 5.2. I reviewed following questions on StackOverflow, but none of them seems to apply to my case: Laravel validation not showing errors Laravel Validation not returning error The thing is, that I am trying to validate a title field, before persisting the Card object into the database. When I submit the form with an empty title field, as expected, It doesn't pass the validations. However, the $errors array doesn't get populated

Uncaught ReflectionException: Class log does not exist Laravel 5.2

若如初见. 提交于 2019-11-26 22:22:42
I am currently trying to clone an existing project of mine from github. After clone I run composer install during the process I receive the following error: Uncaught ReflectionException: Class log does not exist I am running Laravel 5.2 on Centos 7. I have seen references to: Removing spaces within the .env file. Removing the vendor directory & re-installing Removing certain packages required in composer.json I have: Replaced my .env with the example.env to avoid any custom config errors. I have removed & re-cloned the repo. I have used the default composer.json shipped with Laravel to see if

How to pass multiple parameters to middleware with OR condition in Laravel 5.2

天涯浪子 提交于 2019-11-26 21:33:53
问题 I am trying to set permission to access an action to two different user roles Admin, Normal_User as shown below. Route::group(['middleware' => ['role_check:Normal_User','role_check:Admin']], function() { Route::get('/user/{user_id}', array('uses' => 'UserController@showUserDashboard', 'as' => 'showUserDashboard')); }); This route can be accessed by either Admin or Normal_user. But in this middleware configuration, user is required to be both Admin and Normal_User. How can I add OR condition

Laravel 5.2 $errors not appearing in Blade

巧了我就是萌 提交于 2019-11-26 17:38:08
So I'm following along with the Laravel 5 fundamentals tutorial and I am stuck on the form validation. I have followed along exactly with the tutorial but I am getting a Undefined variable: errors in my create articles view. In the tutorial I am following and what I have found online they say the errors variable is always there in the blade file for you to use so I don't know what i am doing wrong? Any help would be appreciated! loving Laravel except for this error! View @if($errors->any()) <ul class="alert alert-danger"> @foreach($errors->any() as $error) <li>{{$error}}</li> @endforeach </ul>

Laravel 5.2 CORS, GET not working with preflight OPTIONS

拜拜、爱过 提交于 2019-11-26 16:33:22
问题 The dreaded CORS Error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost/mysite/api/test. (Reason: CORS header 'Access-Control-Allow-Origin' missing). Laravel route: $router->group(['prefix' => 'api', 'middleware' => 'cors'], function ($router) { $router->get('/test', 'MyController@myMethod'); }); Laravel Cors Middlware: public function handle($request, Closure $next) { header('Access-Control-Allow-Origin: *'); // ALLOW OPTIONS

Laravel 5.2 | Testing UploadedFile Misses the $test Value after Post. Bug?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 16:27:20
问题 Update 2016/04/26 11:30 GMT+2 Workaround Since Laravel 5.2.15, the $test parameter is removed, but there is no clear reason, because Symfony's UploadedFile still has the $test parameter. A workaround is to use Laravel 5.2.14 provisionally. Update 2016/04/26 11:00 GMT+2 Laravel's own UploadedFile doesn't pass the $test parameter. See these resources: https://github.com/laravel/framework/issues/12620 https://github.com/laravel/framework/commit/5062a9b42632e55ee90b7397141c0b12622447e1 I know,

Unit Test Laravel's FormRequest

有些话、适合烂在心里 提交于 2019-11-26 16:07:49
问题 I am trying to unit test various custom FormRequest inputs. I found solutions that: Suggest using the $this->call(…) method and assert the response with the expected value (link to answer). This is overkill, because it creates a direct dependency on Routing and Controllers . Taylor’s test, from the Laravel Framework found in tests/Foundation/FoundationFormRequestTest.php . There is a lot of mocking and overhead done there. I am looking for a solution where I can unit test individual field

Laravel 5.2 Auth not Working

这一生的挚爱 提交于 2019-11-26 12:47:54
问题 As you guys know Laravel 5.2 was released a few days ago. I am trying this new version. I made a new project using the following command on CLI: laravel new testapp As per documentation of Authentication Quickstart, I followed the following command to scaffold routes and views of authentication: php artisan make:auth It worked fine. Registration is working fine. But I am facing problem in Login. After login I tested following in route.php file: Route::get(\'/\', function () { dd( Auth::user()