laravel-4

phpunit cannot find Class, PHP Fatal error

不问归期 提交于 2019-12-13 20:40:30
问题 I get phpunit and install it as this link using the simplest way for test purposes. I just download the phpunit.phar file, chmod & rename & move to /usr/local/bin Then, I run phpunit --version, its ok. PHPUnit 3.7.27 by Sebastian Bergmann I write a simple test public function testSomething(){ $this -> assertTrue(true) } Then I go into the source file folder, phpunit --colors Test It works. So, I decide write a complex demo. My project folder structure is like this. Project Name --> app -->

Using Mail::queue with iron.io

五迷三道 提交于 2019-12-13 20:06:53
问题 I'm trying to use the Mail::queue in Laravel 4 without success. When I run the command: php artisan queue: subscribe queue_name http://foo.com/queue/push It is created on my dashboard a subscriber, and also when I access my route queue/send a new queue is sent to Iron.io. The problem is that I never received the email should be sent when the Mail::queue to be executed. Look my routes: <?php Route::post('queue/push', function() { return Queue::marshal(); }); Route::get('queue/send', function()

What's the difference between with() and compact() in Laravel

て烟熏妆下的殇ゞ 提交于 2019-12-13 20:05:18
问题 What's the difference between the functions with() and compact() in Laravel in these two examples: Example 1: return View::make('books.index')->with('booksList', $booksList); Example 2: return View::make('books.index',compact('booksList')); 回答1: Well compact() is a PHP function that converts a list of variables into an associative array where the key is the variable name and the value the actual value of that variable. The actual question should be: What is the difference between return View:

multiple foreign key that is also primary key in schema builder( laravel )

隐身守侯 提交于 2019-12-13 19:23:01
问题 I have this schema builder (I omitted the class extension and the schema down part) public function up() { Schema::create('cat', function(Blueprint $table) { $table->bigIncrements('id'); $table->timestamps(); $table->string('path_img'); $table->softDeletes(); }); } this: public function up() { Schema::create('campo', function(Blueprint $table) { $table->bigIncrements('id'); $table->timestamps(); $table->string('nome'); }); } and this: public function up() { Schema::create('campo_cat',

Laravel ORM User can favorite Multiple Models

那年仲夏 提交于 2019-12-13 19:20:36
问题 I am trying to find out the best way to define the following relation using Laravel's Eloquent Laravel. I have a User table and 3 Objects ( Player, Team, League) that the user can add as favorites. I know I can create three pivot tables with the User Model and each one of the objects but then I will need to run a Union query to list all favorites from user regardless of type. User id Favorite id user_id favorited_id ( player_id or team_id or league id) favorite_type ( player , team or league)

How can I put multiple classes in a <li> element?

允我心安 提交于 2019-12-13 19:20:14
问题 I am working with a navigation menu, and wondering how to put multiple classes in a li tag: This is the li tag <li class='pil' class='dropdown'> And this is also what I want in the li tag: class='{{ ($aktiv == 'dagvakt') ? 'active' : '' }}' I tried this and it didn't work: <li class='pil' class='dropdown' class='{{ ($aktiv == 'dagvakt') ? 'active' : '' }}'> 回答1: You can add multiple classes to an element by putting them all in the same class attribute and separating them with a space. For

Interface laravel doesn't bind why?

岁酱吖の 提交于 2019-12-13 19:01:00
问题 Hello guys I was creating a package and i was trying to implement a dependency injection on my class without success. I followed all the instruction for do it work. I'm getting crazy on it. When i try to call Player::team_players(2); it throw me an error: Argument 1 passed to Team\Player\Player::__construct() must be an instance of Team\Player\StatusPlayerInterface, none given, called in C:\wamp\www\ultima\workbench\team\player\src\Team\Player\PlayerServiceProvider.php on line 35 and defined

Laravel 4 db raw query with IN in the WHERE clause doesn't work with parameter with MySql

别等时光非礼了梦想. 提交于 2019-12-13 18:12:51
问题 When I do the following query as a DB:select DB:raw query against MySql in Laravel 4 it returns no results. (Note, I've truncated the actual query for this example.) SELECT user_id, email, first_name, last_name, photo_small FROM users AS u JOIN profiles AS p ON p.user_id = u.id WHERE email IN (?) .... where $p= "email.address1@com","xyz.xxx@.edu" and $p is the parameter Yet when I do the following SELECT user_id, email, first_name, last_name, photo_small FROM users AS u JOIN profiles AS p ON

CSRF Token Mismatch Laravel 4

北城余情 提交于 2019-12-13 17:11:54
问题 This is driving me crazy. I'm getting token mismatches on each POST whether from a Laravel form or from AJAX. I added some code to the filter to show me the session vs. _token: Route::filter('csrf', function() { if ($_SERVER['REQUEST_METHOD'] !== 'GET') { $token = Input::has('_token') ? Input::get('_token') : ''; $sessionToken = Session::token(); if ($sessionToken != $token) { $message = 'Token mismatch'; // This one is for debug purposes only return Response::json(['flash' => "$message;

Laravel 4: Pass validation messages obtained from repository to controller

蹲街弑〆低调 提交于 2019-12-13 16:42:27
问题 Learning about Ioc and Repositories and stuck at last hurdle! Assuming I am validating input, how do I pass back messages from the Validator within the repository to the controller? UserRepository interface UserRepository { public function all(); public function create($input); public function findById($id); } Sentry2UserRepository class Sentry2UserRepository implements UserRepository { ... public function create($input) { $validation = Validator::make($input, User::$rules); if ($validation-