PHP code example of repat / laravel-helper
1. Go to this page and download the library: Download repat/laravel-helper 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/ */
repat / laravel-helper example snippets
print_r(mysql_headers("test_table"));
// returns: Array( [0] => head1, [1] => head2 )
print_r(mysql_headers("test_table", $assoc = true));
// returns: Array( [head1] => head1, [head2] => head2)
use App\Models\User;
$user = User::first();
print_r(table_headers($user));
// returns: Array( 1 => id, 2 => name, ...)
print_db_session();
// returns:
// Array
// (
// [_token] => 7Au0aYkJVxQVA3xQBfdJwKNaWxUv0UVJKublCqMn
// [locale] => en
// ...
// )
use App\Model\User;
$user = User::first();
$user->id;
// returns: 1
$user->slug;
// returns: foobar
get_free_slug('foobar', 'slug', User::class, 1, 'id');
// returns: foobar1
insert_bindings(DB::table('users')->where('id', 1));
// returns: SELECT * FROM `users` WHERE `id` = '1'
morph_map();
// returns:Array
// (
// [user] => App\Models\User
// )
use App\Models\User;
morph_map_key(User::class);
// returns: 'user'
use App\Models\Post;
$posts = cache_get_or_add('posts', function() {
return Post::orderBy('created_at', 'desc')->get();
});
dispatch_tinker(new \App\Jobs\CleanupJob());
// returns: 1 (id of job)
route_path();
// returns: /var/www/htdocs/laravel/routes
route_path('web.php');
// returns: /var/www/htdocs/laravel/routes/web.php
named_routes('/var/www/htdocs/laravel/routes/web.php');
// returns: [
// 'laravel.get'
// 'laravel.post'
// ]
named_routes('/var/www/htdocs/laravel/routes/web.php', 'get');
// returns: [
// 'laravel.get'
// ]
// in routes/web.php
// Route::name('dev.foo')->get('foo', 'Dev\TestController@foo');
// Route::get('bar', 'Dev\TestController@bar');
// in Dev/TestController@foo
current_route_name();
// returns: dev.foo
// in Dev/TestController@foo
current_route_name();
// returns: null
all_routes();
// returns:
// "name" => 'route.test', // could be null
// "methods" => [
// "GET",
// "HEAD",
// ],
// "uri" => "test",
// "action" => "\App\Http\Controllers\TestController@test",
route_exists('route.test');
// returns: true
route_exists('route.foobar')
// returns: false
use App\Models\Product;
translated_attributes(Product::class);
// returns: ['title', 'description'];
extract_inline_img("<img src='data:image/jpeg;base64,...>", '/var/www/htdocs/laravel/storage/foobar', 'public/images', true);
// returns: <img src="public/images/fj3209fjew93.jpg">