1. Go to this page and download the library: Download awssat/laravel-kabsa 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/ */
awssat / laravel-kabsa example snippets
class State extends Model
{
use \Awssat\Kabsa\Traits\Kabsa;
protected $rows = [
[
'abbr' => 'NY',
'name' => 'New York',
],
[
'abbr' => 'CA',
'name' => 'California',
],
];
}
class State extends Model
{
use \Awssat\Kabsa\Traits\Kabsa;
public function getRows()
{
return [
[
'abbr' => 'NY',
'name' => 'New York',
],
[
'abbr' => 'CA',
'name' => 'California',
],
];
}
}
$stateName = State::where('Abbr', 'NY')->first()->name;
// or
$stateName = State::firstWhere('Abbr', 'NY')->name;
class Role extends Model
{
use \Awssat\Kabsa\Traits\Kabsa;
protected $rows = [
['label' => 'admin'],
['label' => 'manager'],
['label' => 'user'],
];
}
class User extends Model
{
use \Awssat\Kabsa\Traits\KabsaRelationships;
public function role()
{
return $this->belongsToKabsaRow(Role::class, 'role_label', 'label');
}
}
// Grab a User.
$user = User::first();
// Grab a Role.
$role = Role::where('label', 'admin')->first();
// Associate them.
$user->role()->associate($role);
// Access like normal.
$user->role;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.