vendredi 1 janvier 2016

Call to undefined method Illuminate\Support\Facades\Validator::resolver()

What is it about ?

I am using Laravel 5.2 and update the composer by running the following command

composer require felixkiss/uniquewith-validator:2.*

and then added the following to your providers array in config/app.php:

'providers' => array(
    // ...

    'Felixkiss\UniqueWithValidator\UniqueWithValidatorServiceProvider',
),

I did this because I am trying to implement Multiple column Unique Validation. I mean Composite Key Validation.

I am following the instructions as mentioned here

What's the issue ?

When Laravel runs the below line.

public function store(Request $request)
{
    $v = \Validator::make($request->all(), [
        'SubCategory' => 'required|max:25|min:5|unique_with:tblsubcategory,CategoryID',
        'CategoryID' => 'required',
    ]);

    if ($v->fails()) {
        return \Redirect::back()
                    ->withErrors($v)
                    ->withInput();
    }
    return Redirect('/SubCategories-List/'.$request->input('CategoryID'));
}

I get this error.

Call to undefined method Illuminate\Support\Facades\Validator::resolver()

Important

This was working fine in Laravel 5.1



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1ReSQ5S
via IFTTT

How to move my controllers into a seperate package folder in Laravel 5.2?

I build a small app using laravel 5.2. I put all of my files into a folder called Surveys located at App/Modules/Surveys. "No worries, I am planning to move the Modules out of the App folder, I just need to get the controller to work"

Currently my controller is located on App/Http/Controllers/SurveysController

I want to move my controller folder so it is located on App/Modules/Surveys/Controllers/Frontend/SurveysController

How would I tell laravel to resolve the controller out of this path App/Modules/Surveys/Controllers/Frontend/ instead of App/Http/Controllers?

I tried to do this into a service provider but it is still not working

<?php

namespace App\Modules\Surveys\Providers;

use Illuminate\Support\ServiceProvider;

class PackageServiceProvider extends ServiceProvider
{

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {

        if (! $this->app->routesAreCached()) {
            require __DIR__.'/../routes.php';
        }

    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {

        $this->app->make('Modules\Surveys\Controllers\Frontend\SurveyController');
    }

}

What should I do to make the routes point to the correct controller?

Just for clarity my Application instructor starts at the App

App/Https/Controllers App/Modules/Surveys



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1kyVN4s
via IFTTT

Cant run a migration when deploying. Laravel 5.2

Consider the following task for envoy:

@task('deploy', ['on' => 'web'])
    cd personal_site
    php artisan down
    git pull origin master
    composer install
    php artisan migrate
    php artisan up
@endtask

php artisan migrate // Blows up

The error is:

[user@xxxx]: **************************************
*     Application In Production!     *
**************************************
[user@xxxx]: Command Cancelled!
[user@xxxx]: Application is now live.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1kyVOW7
via IFTTT

Laravel 5 Routes - Group domains if in array?

I have same project here(Laravel 5 Routes - Group Domains from Rows in Database), but I don't know how I should organize my code in routes.php and Custom ServiceProvider ? Can you help me ?

Finally, I want to check the domain with my array (As here), and put in custom view (with 403 code) if the domain is not present. And if exist, return in a variable the ID's domain value for to use it in all Request Eloquent.

Thx.

ps : Sorry for my english (French).



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1UktO4P
via IFTTT

Laravel lockforupdate (Pessimistic Locking)

i'm trying to figure out how to use/test the lockforupdate correctly, but i found is not function like what i expected

this is just testing

public function index() {
        return dd(\DB::transaction(function() {
            if (\Auth::guard('user')->check()) {
                $model = \App\Models\User::find(1)->lockForUpdate();
                sleep(60);
                $model->point = 100000;
                $model->save();
            } else {
                $model = \App\Models\User::find(1);
                $model->point = 999;
                $model->save();
            }

            return $model;
        }));
}

i try to test in 2 browser, browser 1 user logged in and browser 2 not logged in, browser 1 hit refresh, then there will lockforupdate and sleep 60 seconds before update

in the 60 seconds, i go browser 2 and hit refresh, however the record is not locked, i check phpmyadmin and the record is updated(within the 60 seconds lock trigger by browser 1)

but after 60 seconds, the record has been modified again by browser 1(Point 100000)

so am i misunderstanding the lockforupdate is use for?or i test it incorrectly?

what i expected is the row shouldn't be modified by browser 2 in the first 60 seconds(blank page with loading favicon or error throw?)

http://ift.tt/1kxDahl

and i did some research but still cannot understand what different between sharedLock(LOCK IN SHARE MODE) and lockForUpdate(FOR UPDATE)

btw i confirmed the database is innodb



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1PAJYYl
via IFTTT

Is laravel created_at and updated_at inverse?

Laravel Framework version 5.2.5

When I updated a record, update_at was not changed but created_at changed to the current timestamp.

Is this correct?

MariaDB [moon]> show columns from users;
+----------------+------------------+------+-----+---------------------+-----------------------------+
| Field          | Type             | Null | Key | Default             | Extra                       |
+----------------+------------------+------+-----+---------------------+-----------------------------+
| id             | int(10) unsigned | NO   | PRI | NULL                | auto_increment              |
| name           | varchar(255)     | NO   |     | NULL                |                             |
| email          | varchar(255)     | NO   | UNI | NULL                |                             |
| password       | varchar(60)      | NO   |     | NULL                |                             |
| remember_token | varchar(100)     | YES  |     | NULL                |                             |
| created_at     | timestamp        | NO   |     | CURRENT_TIMESTAMP   | on update CURRENT_TIMESTAMP |
| updated_at     | timestamp        | NO   |     | 0000-00-00 00:00:00 |                             |
+----------------+------------------+------+-----+---------------------+-----------------------------+
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password', 60);
            $table->rememberToken();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('users');
    }
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1VtLJHb
via IFTTT

Laravel: Cannot use helper inside php shorthand array

PHP version 5.6. Code:

protected $siteServices = [
        1 => [
            'title' =>  'Consulting',
            'key'       =>  'service',
            'description'   =>  '',
            'file'  =>  asset('assets/img/sample/image1.jpg'), // throws error on this line
        ],
];

Error: PHP Parse error: syntax error, unexpected '(', expecting ']'

What the hell?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1OwlScd
via IFTTT