laravel-4

how to add PHPExcel library in laravel?

断了今生、忘了曾经 提交于 2019-12-04 07:17:25
i want to create new module in laravel which include PHPExcel library. where to put library. how to access it. i have put the PHPExcel library at below location laravel\project\application\libraries\PHPEXCEL it give me error PHP Fatal error: Class 'PHPExcel' not found. You can use the PHPExcel Composer package . Just add "phpoffice/phpexcel": "dev-master" to your composer.json and enter composer update . This way the library will be "installed" and you can use it as normal (for example $objPHPExcel = new PHPExcel(); ) No need for manual includes etc. Update may 2016 Instead of editing your

Laravel 4 - set database.fetch config at runtime

久未见 提交于 2019-12-04 07:14:26
In Laravel 3 I could set the database 'fetch' config at runtime (to get the results as an array rather than an object): Config::set('database.fetch', PDO::FETCH_ASSOC); In Laravel 4, the result is still being returned as an object. What am I doing wrong? [Edit - extra details] I decided to test if the config was being set, and also to try identical code segments in Laravel 3 and Laravel 4 side-by-side. //first fetch as object Config::set('database.fetch', PDO::FETCH_CLASS); //Laravel 3 and 4 returns 88 ... expected: echo PDO::FETCH_CLASS.Config::get('database.fetch'); $users = $users = DB:

Laravel Seeding Does not Fill in Fields

江枫思渺然 提交于 2019-12-04 06:49:29
I have a database seed file: class ContactTableSeeder extends Seeder { public function run() { $contacts = array( array( 'first_name' => 'Test', 'last_name' => 'Contact', 'email' => 'test.contact@emai.com', 'telephone_number' => '0111345685', 'address' => 'Address', 'city' => 'City', 'postcode' => 'postcode', 'position' => 'Director', 'account_id' => 1 ) ); foreach ($contacts as $contact) { Contact::create($contact); } } } When I run php artisan migrate:refresh --seed it seeds the database and creates the relevant record in the contacts table, except that it does not fill the fields with any

Eloquent: Calling Where on a relation

做~自己de王妃 提交于 2019-12-04 06:30:56
问题 I have the following Eloquent ORM query. $products2 = Product::with('metal', 'metal.fixes', 'metal.fixes.currency') ->where('metal_id', '=', 1) ->get()->toArray(); Output from this query is as follows: http://pastebin.com/JnDi7swv I wish to further narrow down my query to only display products where fixes.currency_id = 1 . $products2 = Product::with('metal', 'metal.fixes', 'metal.fixes.currency') ->where('metal_id', '=', 1) ->where('metal.fixes.currency_id', '=', 1) ->get()->toArray(); Could

Token mismatch when changing session driver in Laravel 4

≯℡__Kan透↙ 提交于 2019-12-04 06:15:57
问题 I have problem with Laravel CSRF. I test my code in native session driver and everything is OK. but while I change session driver to redis , token mismatch error happens. I also tried to clear cache. but not working. this is my form {{ Form::open(array( 'route' => 'login' )) }} {{ Form::text('email') }} {{ Form::password('password') }} {{ Form::submit('Login') }} {{ Form::close() }} this is my route Route::post('login', array('as' => 'login', 'before' => 'csrf', 'uses' => 'UserController

Laravel 4.1 Request::is for active menu not working

Deadly 提交于 2019-12-04 05:43:23
I'm trying to make a menu active depending on route in laravel 4.1, my attempt: <li {{{ (Request::is('/core') ? 'class="active"' : '') }}}><a href="{{{ URL::to('/core') }}}">Control Panel</a> </li> My route: Route::get('/core', 'CoreController@Showindex'); This is not throwing any errors just simply ignored. any help is appreciated. In Laravel 4.2: By name: <li class="{{ Route::is('user') ? 'active' : ''}}">Profile</li> router.php Route::get('/user/{id}', ['as' => 'user', 'uses' => 'UserController@profile']); By url: <li class="{{ Request::is('user/*') ? 'active' : '' }}">Profile</li> Moe

laravel belongsTo gives null

∥☆過路亽.° 提交于 2019-12-04 05:37:40
问题 belongsTo relation in laravel is returning null public function games(){ return $this->belongsTo('App\Models\Game'); } but when i provide key as argument it seems to work fine public function games(){ return $this->belongsTo('App\Models\Game','game_id'); } but as per the docs game_id is itself is a default argument. What is the small thing i am missing here. Thanks 回答1: The belongsTo side of the relationship builds the foreign key name based on the name of the relationship method. This

In a Laravel Eloquent model, do we call table field names using camelCase, even though they contain an underscore in the db?

↘锁芯ラ 提交于 2019-12-04 05:32:45
In the database let's say I have in my user's table these fields: name , favorite_color , created_at , etc... Using Eloquent to save: 1: $user = new User; $user->name = "John"; $user->favorite_color = 'blue'; // Notice the underscore $user->save(); 2: $user = new User; $user->name = "John"; $user->favoriteColor = 'blue'; // camelCase $user->save(); Which one of the above is correct? The first one is the correct form. But there's a package to help you do the second one: https://github.com/kirkbushell/eloquence . 来源: https://stackoverflow.com/questions/23274988/in-a-laravel-eloquent-model-do-we

Laravel Crypt - Comparing Values

别来无恙 提交于 2019-12-04 05:20:20
Given that Laravel's Crypt always adds salt, and so therefore no two instances of the same encryption are the same. Normally, this is fine because I can compare the decrypted version of the two. However, what if I want to search for a value that is encrypted in the database? Say that I have a table of users and I would like to encrypt the email address. Now I want to find somebody by the email test@email.com . How do I go about to write the query for this? I cannot just Crypt::encrypt($email) and search since this iteration of the encrypt will be different than the one in the DB. Edit

Laravel 4 - Input::old for radio buttons

喜欢而已 提交于 2019-12-04 05:15:56
I was wondering if some Laravel guys can help out. I have a form in which i have 2 radio buttons, when the form submits it goes through the validator, if the validator fails it comes back to the form, populates the fields with the input and displays error messages. I cant seem to do this for radio buttons, if one is clicked when the form is submitted and there was an error, it comes back to the form with everything filled out EXCEPT the radio button that was checked is now empty. My radio buttons are as follows: <input type="radio" name="genre" value="M" class="radio" id="male" /> <input type=