1. Go to this page and download the library: Download onursimsek/laravel-extended library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
onursimsek / laravel-extended example snippets
Product::whereGreaterThan('price', 500)->get();
// select * from products where price > 500
Product::whereGreaterThanOrEqual('price', 500)->get();
// select * from products where price >= 500
Product::whereLessThan('price', 500)->get();
// select * from products where price < 500
Product::whereLessThanOrEqual('price', 500)->get();
// select * from products where price <= 500
Product::whereColumnGreaterThan('price', 'amount')->get();
// select * from products where price > amount
Product::whereColumnGreaterThanOrEqual('price', 'amount')->get();
// select * from products where price >= amount
Product::whereColumnLessThan('price', 'amount')->get();
// select * from products where price < amount
Product::whereColumnLessThanOrEqual('price', 'amount')->get();
// select * from products where price <= amount
Product::whenWhere(false, 'is_active')->get();
// select * from products
Product::whenWhere(true, 'is_active')->get();
// select * from products where is_active = 1
use Illuminate\Support\Str;
Str::squishBetween("I\twill kiss\t\nyou!", 'kiss', 'you');
// I will kiss you!
Str::replaceBetween('I will kiss you!', 'will', 'you', 'miss');
// I will miss you!
Str::replaceBetweenMatch('I will kiss you!', 'will', 'you', '/k(.*)s/', 'hug');
// I will hug you!
use Illuminate\Support\Str;
Str::of("I\twill kiss\t\nyou!")->squishBetween('kiss', 'you');
// I will kiss you!
Str::of('I will kiss you!')->replaceBetween('will', 'you', 'miss');
// I will miss you!
Str::of('I will kiss you!')->replaceBetweenMatch('will', 'you', '/k(.*)s/', 'hug');
// I will hug you!
$this->beginTransaction(); // Starts transaction on default connection
$this->beginTransaction('mysql', 'sqlite'); // Starts transactions on the 'mysql' and 'sqlite' connections
$this->commit(); // No action taken (no specific connection provided)
$this->commit('mysql', 'sqlite'); // Commits the transactions on the 'mysql' and 'sqlite' connections
$this->commitAll(); // Commits all active transactions
$this->rollBack(); // Rolls back on the default connection
$this->rollBack('mysql', 'sqlite'); // Rolls back on the 'mysql' and 'sqlite' connections
$this->rollBackAll(); // Rolls back all active transactions
namespace App\Http\Controllers\Controller;
use OnurSimsek\LaravelExtended\Support\InteractsWithDatabase;
class Controller
{
use InteractsWithDatabase;
public function store()
{
$this->beginTransaction('mysql', 'pgsql');
try {
// Your data processing logic
$this->commitAll(); // Commit the transactions if everything goes well
} catch (\Exception $e) {
$this->rollBackAll(); // Roll back if an error occurs
throw $e;
}
}
}
enum Status
{
use HasName;
case Active;
case Inactive;
}
Status::names(); // ['Active', 'Inactive']
enum Status: string
{
use HasValue;
case Active = 'active';
case Inactive = 'inactive';
}
Status::names(); // ['Active', 'Inactive']
Status::values(); // ['active', 'inactive']
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.