September 22, 2022 in Laravel, Php
How to check maximum upload file size in Laravel / PHP
PHP get actual maximum upload size
echo ini_get("upload_max_filesize");
(int)ini_get("upload_max_filesize")*1024 will convert it to kbs
September 22, 2022 in Laravel, Php
PHP get actual maximum upload size
echo ini_get("upload_max_filesize");
(int)ini_get("upload_max_filesize")*1024 will convert it to kbs
September 22, 2022 in Laravel, Php
$request->validate([
'amount' => 'required|numeric|max:9999999999',
'date' => 'required',
'description' => 'required|max:200',
]);
September 2, 2022 in Laravel
php artisan migrate --path=/database/migrations/employee
php artisan migrate --path=/database/migrations/student
August 7, 2022 in Laravel, Php
PHP 7.4 goes end of life (EOL) on the 28 November 2022 meaning known security flaws will no longer be fixed and sites are exposed to significant security vulnerabilities. It is important to update them to a newer version.
PHP 7.4, the next PHP 7 minor release, has been released for General Availability as of November 28th, 2019.
August 7, 2022 in Laravel
use App\Models\User;
use Auth;
if (Auth::check()) {
$user = Auth::user();
$user_id = $user->id;
}
August 7, 2022 in Laravel
use \stdClass;
$data = array();
$object = new stdClass();
$object->business_id= '';
$object->phone_number_id= '';
$object->recipient_phone_number= '';
$object->user_access_token= '';
$object->waba_id= '';
$object->version= '';
$data[0] = $object;
July 6, 2022 in Laravel, Tips and Tricks
The second param is to manually set the name of the unique index. Use an array as the first param to create a unique key across multiple columns.
$table->unique(array('mytext', 'user_id'));
$table->unique(['mytext', 'user_id']);
Schema::create('cal_like', function (Blueprint $table) {
$table->id();
$table->string('module',250)->nullable();
$table->bigInteger('module_id')->nullable();
$table->bigInteger('user_id')->nullable();
$table->unique(array('module_id', 'user_id'));
$table->timestamps();
});
July 4, 2022 in Laravel, Tips and Tricks
Existing Code
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
Existing Code Replace with
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
if(isset($_SERVER['REQUEST_URI'])){$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);}
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
June 22, 2022 in Laravel
$chapter= array();
$chapter = DB::table('Table_Name')->select( DB::raw('format(number,0) as chapter'), DB::raw('count(*) as total'))->groupBy(\DB::raw('format(number,0)'))->get();
June 22, 2022 in Laravel, Php, Ubuntu
RUN composer command in non root user
$ composer dump-autoload
RUN composer command in root user
# composer dump-autoload --no-plugins --no-scripts