laravel-4

laravel show only next and previous link in pagination

…衆ロ難τιáo~ 提交于 2019-12-10 16:33:39
问题 I ma trying to use Laravel Pagination and I only want to show the Previous and Next link with out the number 1 2 3 ... how could I do that? I followed Laravel page : "Simple Pagination" If you are only showing "Next" and "Previous" links in your pagination view, you have the option of using the simplePaginate method to perform a more efficient query. This is useful for larger datasets when you do not require the display of exact page numbers on your view: $someUsers = User::where('votes', '>'

Laravel 4 pagination count

痞子三分冷 提交于 2019-12-10 16:33:27
问题 I have set a pagination in my specific view/site, and it works. The problem is I have a php counter: <?php $count = 0;?> @foreach ($players as $player) <?php $count++;?> <tr> <td>{{ $count }}. </td> and whenever I switch pages, it starts from 1. How could I change that? 回答1: In order to achieve that, you need to initialize the value of counter: <?php $count = (($current_page_number - 1) * $items_per_page) + 1; ?> Notice I'm first subtracting 1 from current page, so the first page number is 0

How to unlink files after they have been attached and sent? (When using Mail::queue)

≯℡__Kan透↙ 提交于 2019-12-10 16:27:20
问题 I switched from sending my mails immediately to adding them to the queue, here is my code, the $attachments is an array of temporary paths, I've commented out what I've tried, which throws errors about files not existing. Mail::queue($view, $data, function(\Illuminate\Mail\Message $message) use($mail,$attachments){ foreach($mail->getRecipients() as $recipient){ $message->to($recipient); } $message->subject($mail->getSubject()); foreach($attachments as $attachment){ $message->attach(

Is it possibly to modify the request before being processed by the routes file in Laravel?

若如初见. 提交于 2019-12-10 16:25:49
问题 Is it possibly to modify the request before being processed by the routes file? Basically the app I am looking to build will have hundreds of slug URLs. But the slugs will lead to different controllers. To achieve this I will keep key:values pairs in redis. For example: // slug = domain.com/slug-one // Would route to Route::get('pages/{id}', 'PagesController@index'); // slug = domain.com/slug-two // Would route to Route::get('articles/{id}', 'ArticlesController@index'); For me the best way

Eloquent ORM Eager-loading Distinct Records in Many to Many Relationship

好久不见. 提交于 2019-12-10 16:22:44
问题 Background I have a List model which belongs to and has many Subscriber. And of course a Subscriber which belongs to and has many List. Problem I want to eager-load all subscribers from multiple lists. BUT, I am only interested in distinct subscribers, since a subscriber can have and indeed belong to multiple lists. My attempt I have used the distinct() method but this hasn't yielded any joy. And I can also loop through the result set to manually slice out duplicates. Just wondering if there

cURL error 35: Unknown SSL protocol error in connection to api.mailgun

强颜欢笑 提交于 2019-12-10 16:19:52
问题 All of a sudden I have started getting this mailgun error , GuzzleHttp \ Exception \ RequestException cURL error 35: Unknown SSL protocol error in connection to api.mailgun.net:443 Any Mail gun user please help me out Thanks 回答1: I have been having the same issue with Laravel 4.2 and Mailgun. I have contacted MG they are blaming this error on DDoS attacks they have been having. I included this thread in my latest support ticket. If you have any useful information to help them please include

Laravel 4 - Read config files

寵の児 提交于 2019-12-10 16:17:57
问题 How can i read the config files from laravel? For example for the database connection (app/config/database/.php) I want the mysql data from the config. For a package you do it like that: return Config::get('package::group.option'); But how to do it for the main files? 回答1: I do Config::get('database.default') for example. 回答2: To get the database connection parameters (server, username, password etc) if you're using MySQL, you can do this: echo "Driver: " . Config::get('database.connections

Laravel can't connect to DB

天涯浪子 提交于 2019-12-10 16:17:28
问题 I'm following through the Quick Start Guide, and got to the section actually connecting to the DB to fetch the users table, and am getting the following error: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) My database.php includes the following setup (default set to mysql): 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'bt', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci',

Can you extend Command classes in Laravel

£可爱£侵袭症+ 提交于 2019-12-10 16:11:59
问题 I'm currently working on an application working with Laravel 4. I'm working on building a commenting system and have the basic Commands for doing Create, Update, Delete. What I'm trying to do next is create commands for the specific objects to which the comments will be attached, for example a Blog Post. So if my command file is called CreateCommentCommand I would like to create another command called CreatePostCommentCommand . I would like this newer class to extend the CreateCommentCommand

Decrypt encrypted value outside of Laravel

拥有回忆 提交于 2019-12-10 15:59:42
问题 How can i decrypt a string which has been encrypted using the Laravel 4 Encrypt class, outside of Laravel, only with PHP? 回答1: The Laravel Encrypter class uses Rijndael with a block size of 256 bit for encryption which is provided by the Mcrypt PHP extension. The Encrypter class works using two simple methods, encrypt() and decrypt() . An example below: <?php $secret = Crypter::encrypt('some text here'); //encrypted $decrypted_secret = Crypter::decrypt($secret); //decrypted ?> Since you're