PHP code example of rcalicdan / ci4-larabridge

1. Go to this page and download the library: Download rcalicdan/ci4-larabridge 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/ */

    

rcalicdan / ci4-larabridge example snippets


public function store()
{
    User::create(StoreUserRequest::validateRequest());
    return redirect()->route_to('users.index')->with('success', 'User created successfully');
}

public function store()
{
    $validation = \Config\Services::validation();
    $validation->setRules([
        'name' => '   
    if (!$validation->withRequest($this->request)->run()) {
        return redirect()->back()->withInput()->with('errors', $validation->getErrors());
    }
    
    $userModel = new \App\Models\UserModel();
    $userModel->insert([
        'name' => $this->request->getPost('name'),
        'email' => $this->request->getPost('email'),
        'password' => password_hash($this->request->getPost('password'), PASSWORD_BCRYPT)
    ]);
    
    return redirect()->to('/users')->with('message', 'User created successfully');
}

public function index()
{
    $users = User::paginate(15);
    return view('users.index', compact('users'));
}

public function index()
{
    $userModel = new \App\Models\UserModel();
    $data['users'] = $userModel->paginate(15);
    $data['pager'] = $userModel->pager;
    
    return view('users/index', $data);
}
bash
php spark laravel:setup