PHP code example of aungmyokyaw / lara-arch

1. Go to this page and download the library: Download aungmyokyaw/lara-arch 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/ */

    

aungmyokyaw / lara-arch example snippets


php artisan make:dto [Filename]

php artisan make:service [Filename]

php artisan make:trit [Filename]

php artisan make:enum [Filename]

enum Status : int {
    case Pending = 0;
    case Approved = 1;
}

php artisan make:repository [Filename] --model=[ModelName]

php artisan make:repository UserRepository --model=User

namespace App\Repositories;

use Amk\LaraArch\BaseRepository;
use App\Models\User;

class UserRepository extends BaseRepository {
    public function getModel(){
        return User::class;
    }
}

$userRepository = new UserRepository();

// Create a new user
$userRepository->create(['name' => 'John Doe', 'email' => '[email protected]']);

// Find a user by ID
$userRepository->find(1);

// Update a user's information
$userRepository->update(1, ['name' => 'Updated Name']);

// Delete a user
$userRepository->delete(1);

// Retrieve all users
$users = $userRepository->all();

// Retrieve all users with paginate
$users = $userRepository->paginate(10);

// Retrieve users using where query
$users = $userRepository->all(['email' => '[email protected]']);