laravel-5.2

getting error while updating Composer

女生的网名这么多〃 提交于 2019-11-27 10:07:16
问题 I have a project in Laravel-5.1 and I have changed my platform from win10 to Ubuntu. Showing error: Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - laravel/framework v5.2.9 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system. - laravel/framework v5.2.8 requires ext-mbstring * -> the requested PHP extension mbstring

How to get last inserted ids in laravel

為{幸葍}努か 提交于 2019-11-27 08:19:20
问题 I am inserting multiple rows at the same time, say 2 rows $multiple_rows = [ ['email' => 'taylor@example.com', 'votes' => 0], ['email' => 'dayle@example.com', 'votes' => 0] ]; DB::table('users')->insert($multiple_rows); How can I get those inserted ids. I am doing it, this way for now. foreach($multiple_rows as $row){ DB::table('users')->insert($row); $record_ids[] = DB::getPdo()->lastInsertId(); } Any other good way to do it, without inserting single row each time. 回答1: You could do

How to allow Laravel and WordPress to share logins?

耗尽温柔 提交于 2019-11-27 08:18:11
问题 I'm a Laravel developer. I develop one ecommerce plugin with Laravel and I just want to combine WordPress with Laravel. So I need to share or make common login session between Laravel and WordPress. How could I implement this? And are there special plugins available for this? Or could I use laravel-Auth? 回答1: The right way of doing it is to Have a Laravel (or Wordpress) as an Auth server And create like an SSO plugin. I was doing the same with NodeBB Forum login from Laravel. Steps that I

Laravel 5.2 Auth not Working

雨燕双飞 提交于 2019-11-27 05:00:36
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()); return view('welcome'); }); Auth::user() is returning null and also Auth::check() and Auth::guest()

Laravel 5.2 validation errors

倾然丶 夕夏残阳落幕 提交于 2019-11-27 04:24:01
I have some trouble with validation in Laravel 5.2 When i try validate request in controller like this $this->validate($request, [ 'title' => 'required', 'content.*.rate' => 'required', ]); Validator catch error, but don't store them to session, so when i'm try to call in template this code @if (isset($errors) && count($errors) > 0) <div class="alert alert-danger"> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif Laravel throw the error Undefined variable: errors (View: /home/vagrant/Code/os.dev/resources/views/semantic/index.blade.php) When i'm

What is the concept of Service Container in Laravel?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 04:12:37
问题 I am starting to look into Laravel but I don't understand the concept of Service Container. How does it work and what do developers need to know to fully utilize this concept in Laravel? 回答1: The Service Container in Laravel is a Dependency Injection Container and a Registry for the application The advantages of using a Service Container over creating manually your objects are: Capacity to manage class dependencies on object creation You define how a object should be created in one point of

Undefined variable: errors in Laravel

寵の児 提交于 2019-11-27 04:09:20
When I want to register a user in my laravel project, the page always says Undefined variable: errors (View: /var/www/resources/views/auth/register.blade.php)" According to the Laravel documentation, $errors should always automatically be set: So, it is important to note that an $errors variable will always be available in all of your views on every request, allowing you to conveniently assume the $errors variable is always defined and can be safely used. I have this on on every view when I use: @if (count($errors) > 0) <div class="alert alert-danger"> <ul> @foreach ($errors->all() as $error)

Laravel 5.2 not reading env file

夙愿已清 提交于 2019-11-27 03:11:37
After upgrading to Laravel 5.2, none of my .env file values are being read. I followed the upgrade instructions ; none of my config files were changed except auth.php. They were all working fine in previous version, 5.1.19 .env contains values such as DB_DATABASE=mydb DB_USERNAME=myuser config/database.php contains 'mysql' => [ 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), ] I get this error: PDOException: SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) Clearly not pulling in my env config. This is affecting every

Where are logs located?

两盒软妹~` 提交于 2019-11-27 02:30:01
问题 I'm debugging a JSON endpoint and need to view internal server errors. However, my app/storage/logs dir is empty and it seems there are no other directories dedicated to logs in the project. I've tried googling the subject to no avail. How can I enable logging, if it's not already enabled and view the logs? 回答1: Ensure debug mode is on - either add APP_DEBUG=true to .env file or set an environment variable Log files are in storage/logs folder. laravel.log is the default filename. If there is

required_if Laravel 5 validation

时间秒杀一切 提交于 2019-11-27 01:46:28
问题 I have form that a user can fill-out for selling their home. And for one of the in puts, a user must select weather it will be "For Sale" or "For Rent". If it is For Sale, two price input fields will appear, and if it is For Rent, then some other price input field will appear based off of jQuery. My problem is I want the price fields to be required, BUT for example if I'am selecting "For Rent", and then I submit my form, it will give me an error saying the price fields for the "For Sale"