Posts
Showing posts from February, 2021
Laravel breez and laratrust
- Get link
- X
- Other Apps
composer require laravel/breeze --dev php artisan breeze:install npm install && npm run dev composer require santigarcor/laratrust php artisan vendor:publish --tag="laratrust" php artisan laratrust:setup php artisan laratrust:seeder php artisan vendor:publish --tag="laratrust-seeder" composer dump-autoload $this->call(LaratrustSeeder::class); database seeder file php artisan migrate php artisan db:seed <div class="mt-4"> <x-label for="role_id" :value="__('Register As')" /> <select id="role_id" class="block mt-1 w-full" name="role_id" required> ...
Laravel adding hasRole method to Auth
- Get link
- X
- Other Apps

adding the following to your User model:- public function hasRole ( $role ) { return User::where( 'role' , $role )->get(); } This should firstly check to see if you User table has the field 'role' and then check your parameter $role against the role field. You can the check by doing the following: if ( Auth::user()->hasRole( $role ) ) You may need to adjust the example to your needs. Let me know if you need anything else. /------------EDIT-----------------/ If you have two seperate tables, one holding the user information and the other holding the users privileges/roles you could add another function to the User model: public function userID ( ) { return $this ->user_id; } This will check for if you have a user ID field if so, it will return the id for the authenticated user. Then add this to your hasRoles method: public function hasRoles ( $userID , $roles ) { return Your\User\Roles\Model::where( 'role...
Validate Max File Size in Laravel
- Get link
- X
- Other Apps

First, let’s see how to validate file size in Laravel. In your Form Request files or validate() method you can pass array with this parameter: [ 'image' => 'required|mimes:jpeg,bmp,png|size:20000', ] The last part means that size should be not more than 20 MB (20000 kB). But that may be not enough, cause file restrictions exist not only on Laravel application level.
Laravel 8 File Upload with Custom Renaming and Helper Creation | Latest ...
- Get link
- X
- Other Apps
PHP mysql Database Backup
- Get link
- X
- Other Apps

$date_string = date("Ymd"); $dbhost = "localhost"; $dbuser = 'dbuser'; $dbpass = 'dbuserpass'; $dbname = 'dbname'; $connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname); $backupAlert = ''; $tables = array(); $result = mysqli_query($connection, "SHOW TABLES"); if (!$result) { $backupAlert = 'Error found.<br/>ERROR : ' . mysqli_error($connection) . 'ERROR NO :' . mysqli_errno($connection); } else { while ($row = mysqli_fetch_row($result)) { $tables[] = $row[0]; } mysqli_free_result($result); $return = '...
Laravel 8.x Resource CRUD (Create,Read,Update,Delete) operation | 2021 ...
- Get link
- X
- Other Apps
Send an Email with attachment from Laravel 8 using PHPmailer Library | 2...
- Get link
- X
- Other Apps
Laravel 8.x CRUD (Create,Read,Update and Delete) Operation using Query B...
- Get link
- X
- Other Apps
Dynamic number of rows in Laravel Blade
- Get link
- X
- Other Apps

This is correct: @ foreach ( $collection as $index => $element ) {{ $index }} - {{ $element [ 'name' ]}} @ endforeach And you must use index+1 because index starts from 0. Using raw PHP in view is not the best solution. Example: <tbody> <?php $i = 1 ; @ foreach ( $aaa as $value ) ?> <tr> <td> <?php echo $i ; ?> </td> <td> <?php {{ $value ->name}}; ?> </td> </tr> <?php $i ++; ?> <?php @ endforeach ?> <thead> <th>number</th> <th>name</th> </thead> <tbody> @ foreach ( $aaa as $index => $value ) <tr> <td>{{ $index }}</td> // index +1 to begin from 1 <td>{{ $value }}</td> </tr> @ endforeach </tbody> ...
Multi Vendor company employee record Application with Codeigniter 3 in H...
- Get link
- X
- Other Apps
Custom Registration and Login using Eloquent with Session in Laravel La...
- Get link
- X
- Other Apps
Login Form with bootstrap Card
- Get link
- X
- Other Apps

<!DOCTYPE html> <html> <head> <title>Login</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> </head> <body> <div class="container"> <div class="row"> <div class="col-sm-4 offset-sm-4 mt-2"> <form action="" method="post"> <div class="card"> <div class="card-header"> L...
Register form with bootstrap card
- Get link
- X
- Other Apps

<!DOCTYPE html> <html> <head> <title>Register</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> </head> <body> <div class="container"> <div class="row"> <div class="col-sm-4 offset-sm-4 mt-2"> <form action="" method="post"> <div class="card"> <div class="card-header"> ...