samedi 2 avril 2016

How to make SQLite work in Laravel

Whenever I run php artisan migrate, the following error is shown in the console:

[PDOException]
SQLSTATE[HY000] [14] unable to open database file

The database.sqlite file is located at database/. I'm running Windows 10, Laravel 5.2. Here are my configurations:

.env:

DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=homestead
DB_PASSWORD=secret

I have looked everywhere, but could not find what causes this error and how to resolve it.



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

RBAC Laravel 5.1 Banning users

I'm making a application in laravel 5.1 and I'm using Bican roles to manage the user's permissions and role names. Now I want to be able to ban my users.

So if I ban a user, the application needs to check globally the application if the user is banned. Im storing the bans in a new table outside of the users table because in that way, I can always find all the bans there were given to a specific user.

My database structure looks like this:

+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+------------------+------------+----------------+---------------------------------+----------------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | ORDINAL_POSITION | COLUMN_DEFAULT | IS_NULLABLE | DATA_TYPE | CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH | NUMERIC_PRECISION | NUMERIC_SCALE | CHARACTER_SET_NAME | COLLATION_NAME     | COLUMN_TYPE      | COLUMN_KEY | EXTRA          | PRIVILEGES                      | COLUMN_COMMENT |
+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+------------------+------------+----------------+---------------------------------+----------------+
| def           | xenionode    | banned     | id          |                1 | NULL           | NO          | int       | NULL                     | NULL                   |                10 |             0 | NULL               | NULL               | int(11) unsigned | PRI        | auto_increment | select,insert,update,references |                |
| def           | xenionode    | banned     | user_id     |                2 | NULL           | NO          | int       | NULL                     | NULL                   |                10 |             0 | NULL               | NULL               | int(11) unsigned | MUL        |                | select,insert,update,references |                |
| def           | xenionode    | banned     | banned_by   |                3 | NULL           | NO          | int       | NULL                     | NULL                   |                10 |             0 | NULL               | NULL               | int(11) unsigned | MUL        |                | select,insert,update,references |                |
| def           | xenionode    | banned     | reason      |                4 | NULL           | NO          | varchar   |                      255 |                   1020 | NULL              | NULL          | utf8mb4            | utf8mb4_unicode_ci | varchar(255)     |            |                | select,insert,update,references |                |
| def           | xenionode    | banned     | expires     |                5 | NULL           | NO          | datetime  | NULL                     | NULL                   | NULL              | NULL          | NULL               | NULL               | datetime         |            |                | select,insert,update,references |                |
| def           | xenionode    | banned     | lifted      |                6 | NULL           | YES         | datetime  | NULL                     | NULL                   | NULL              | NULL          | NULL               | NULL               | datetime         |            |                | select,insert,update,references |                |
| def           | xenionode    | banned     | lifted_by   |                7 | NULL           | YES         | int       | NULL                     | NULL                   |                10 |             0 | NULL               | NULL               | int(11) unsigned | MUL        |                | select,insert,update,references |                |
+---------------+--------------+------------+-------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+------------------+------------+----------------+---------------------------------+----------------+
7 rows in set

Now I want if a user is banned, the user still can login, but redirects always to a view called banned.

I really don't knwo how I can do this global check in Laravel 5 in a propper way, if someone could help me out, that would be awesome!

Kindest regards

Robin



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

Laravel composer update give error

I just update the compose and i found below error.

php artisan clear-compiled PHP Fatal error: Call to undefined method Illuminate\View\Compilers\BladeCompiler::directive() in /var/www/html/innomaid/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 213

[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method Illuminate\View\Compilers\BladeCompiler::directive()

Script php artisan clear-compiled handling the post-update-cmd event returned with an error

[RuntimeException]
Error Output: PHP Fatal error: Call to undefined method Illuminate\View\Compilers\BladeCompiler::directive() in /var/www/html/innomaid/ve
ndor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 213

Here is my composer code

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "laravel/framework": "5.0.*",
        "illuminate/html": "5.*",
        "barryvdh/laravel-dompdf": "0.6.*",
        "tymon/jwt-auth": "0.5.*",
        "gloudemans/shoppingcart": "~1.3",
        "intervention/image": "^2.3"

    },
    "require-dev": {
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1",
        "zizaco/entrust": "dev-laravel-5"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php -r \"copy('.env.example', '.env');\"",
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

Please help me to solve this error



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

Call to a member function paginate() on array

I am working with Laravel5.0 . I want to add paginate() to the following function of my controller part.

public function index()
{
    try{
        $val=DB::connection()->getDatabaseName();
        if(DB::connection()->getDatabaseName()) {
            //$bRecord = DB::table('bills')->orderBy('Date', 'desc')->paginate(4);

            $bRecord = DB::table('bills')
                ->join('clients', 'bills.ClientID', '=', 'clients.ClientID')
                ->select('bills.ReceiptID', 'bills.ClientID', 'bills.Paid', 'bills.Date','bills.ReceivedBy',
                    'clients.ClientName')
                ->get();

            return view('bills.billRecord')->with('bRecord', $bRecord);
        }else{
            $er="/connection status: database error";
            return view('home')->with('error',$er);         //'error' is passed to home
        }
    }catch (\Exception $e){
        $er="/connection status: database error";
        return view('home')->with('error',$er);
    }

}

if I add paginate here, it shows error. "Call to a member function paginate() on array"

$bRecord = DB::table('bills')
                ->join('clients', 'bills.ClientID', '=', 'clients.ClientID')
                ->select('bills.ReceiptID', 'bills.ClientID', 'bills.Paid', 'bills.Date','bills.ReceivedBy',
                    'clients.ClientName')
                ->get()->paginate(4);

How can I use paginate() here?



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

How to get excel sheet title in laravel 5.2

I want to get excel sheet title.
I have method controller like this:

use Maatwebsite\Excel\Facades\Excel;



public function importCSVEXCEl()
   {

    Excel::load('test.xls', function($reader) {
        foreach($reader as $sheet)
        {

         $temp= $sheet->getTitle();
        }
    });
}

after execute this method show me error

Call to undefined method PHPExcel::getTitle()



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

Laravel 5.2: url not found but router is available in windows 7 wamp server

Default route is running

for example:

Route::get('/', function () {
return view('welcome');
});

When i run this http://localhost/laracast/public Shows outputs as LARAVEL 5

But when I add new route to

Route::get('/hello', function() {    
return 'Welcome to Laracast';
});

It shows output as => url not found

I am using

1.Windows7

2.Wamp Server

3.Composer and

4.GIT BASH

what the mistake i done it



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

Laravel Thujohn/Twitter Bad Authentication Data

I'm trying to use twitter api with laravel.It's working on localhost.But when I deploy my project to heroku.Its giving error on views.

{"errors":[{"code":215,"message":"Bad Authentication data."}]}
[215] Bad Authentication data.

What should I do for solving this problem.

Thanks



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