In Laravel 5.2, it's suggested to type-hint the Request object in controller method declarations:
I'm trying to do the same in one of my libraries:
<?php
namespace App\Libraries;
use Illuminate\Http\Request;
class MyLibrary {
public static function doStuff(Request $request) {
//...
}
}
However, when I try to use the library method like shown in the code below, I get a missing argument error:
<?php
namespace App\Http\Controllers;
use App\Libraries\MyLibrary;
class DefaultController extends Controller {
public function __construct() {
MyLibrary::doStuff(); // => trows missing argument error
}
}
Now, I've type-hinted the Request object into my doStuff()
method. Why do I need to pass an argument directly? Do I understand the type-hinting concept incorrectly?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1TWVnCz
via IFTTT
Aucun commentaire:
Enregistrer un commentaire