Hotel System Management
Hello Dear,
This tutorial will give you an example of how to clone Laravel project from Gitlab. let’s discuss steps to clone Laravel project from Github. I explained simply about the clone Laravel project from Github. This article goes in detail on the clone Laravel project from Github on the server.
In this tutorial, I will show you step by step how to clone Laravel projects from Github, GitLab, or bitbucket and set up an ubuntu server from scratch. you can easily clone Laravel 6, Laravel 7, Laravel 8, Laravel 9 and Laravel 10 projects from this post.
So, let's follow the below step-by-step and get done with the clone Laravel app.
Step 1: namespace App\Models
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'user_id',
'name',
'email',
'join_date',
'phone_number',
'status',
'role_name',
'avatar',
'position',
'department',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
protected static function boot()
{
parent::boot();
self::creating(function ($model) {
$getUser = self::orderBy('user_id', 'desc')->first();
if ($getUser) {
$latestID = intval(substr($getUser->user_id, 3));
$nextID = $latestID + 1;
} else {
$nextID = 1;
}
$model->user_id = 'KH_' . sprintf("%03s", $nextID);
while (self::where('user_id', $model->user_id)->exists()) {
$nextID++;
$model->user_id = 'KH_' . sprintf("%03s", $nextID);
}
});
}
}
Step 2: Composer Update
Type the command in your terminal.
composer update
composer update
Step 3: Update Your Database Credentials
After that update your database credentials in your .env file which is located in your project root.
1. connection databases
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_db
DB_USERNAME=root
DB_PASSWORD=#your database password
Step 4: database/migrations/users_table.php
After adding the migration file now run the migrate command.
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('user_id')->nullable();
$table->string('name')->nullable();
$table->string('email')->nullable();
$table->string('join_date')->nullable();
$table->string('phone_number')->nullable();
$table->string('status')->nullable();
$table->string('role_name')->nullable();
$table->string('avatar')->nullable();
$table->string('position')->nullable();
$table->string('department')->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('user_id')->nullable();
$table->string('name')->nullable();
$table->string('email')->nullable();
$table->string('join_date')->nullable();
$table->string('phone_number')->nullable();
$table->string('status')->nullable();
$table->string('role_name')->nullable();
$table->string('avatar')->nullable();
$table->string('position')->nullable();
$table->string('department')->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
Step 5: Make Migration
After adding the migration file now run the migrate command.
php artisan migrate
Step 6:Run
After adding the run file now run the migrate command.
php artisan serve
Tags:
Laravel