Populate form input select (Laravel)

this is for select option (dropdown)

<select name="province" id="province" class="form-control">
@foreach(config('constants.master_province') as $key => $value)
<option value="{{ $key }}" {{ (old('province', (!empty($vendor->province)) ? $vendor->province : '') == $key) ? 'selected="selected"' : '' }}>{{ $value }}</option>

and below for input

<input type="text" name="url" id="url" class="form-control" value="{{ old('url', (!empty($vendor->url)) ? $vendor->url : '') }}">

Manual pagination with Laravel 5.*

manual paginate with laravel

use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;

$array = [12,23,34,45];
$page = Input::get('page', 1); // Get the current page or default to 1, this is what you miss!
$perPage = 20;
$offset = ($page * $perPage) - $perPage;

return new LengthAwarePaginator(array_slice($array, $offset, $perPage, true), count($array), $perPage, $page, ['path' => $request->url(), 'query' => $request->query()]);


source: https://laracasts.com/discuss/channels/laravel/laravel-pagination-not-working-with-array-instead-of-collection

Send Email (With Generate PDF Attachment) – Laravel

first make notification (php artisan make:notification YourNotification)

public function toMail($notifiable)
$invoice = $this->invoice;
$pdf = PDF::loadview('subscribe.invoices.pdf-invoice-detail', compact('invoice'));

return (new MailMessage)
->subject('App.dev - Invoice #'. $this->invoice->id)
->line('Your invoice has been release.')
->action('Check Invoice', route('view.invoices') . '?id='. $this->invoice->id)
->line('Make sure you pay the invoice, Check You Email Attachment!')
->attachData($pdf->output(), Auth::user()->id_user . '_' . $invoice->id . '.pdf', [
'mime' => 'application/pdf',

Give User Access Specific Database (MySQL)

Ok first we need to create user, login user as root to your MySQL

> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

after create user, create database then give privileges to the user

> CREATE DATABASE new_database;
> GRANT ALL PRIVILEGES ON new_database.* TO 'newuser'@'localhost';

then flush privileges



source: https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql