PHP code example of open-resource-manager / client-laravel
1. Go to this page and download the library: Download open-resource-manager/client-laravel 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/ */
open-resource-manager / client-laravel example snippets
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use OpenResourceManager\Client\Account as AccountClient;
class ExampleController extends Controller
{
public function index()
{
$orm = getORMConnection();
$accountClient = new AccountClient($orm);
return $accountClient->getList()->raw_body;
}
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use OpenResourceManager\Laravel\Facade\ORM;
use OpenResourceManager\Client\Account as AccountClient;
class ExampleController extends Controller
{
public function index()
{
$orm = ORM::get();
$accountClient = new AccountClient($orm);
return $accountClient->getList()->raw_body;
}
}
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->integer('orm_id')->unique(); // Add this to your user's model and fill it with the related ORM Account ID.
$table->string('username');
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
namespace App\Model;
use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use OpenResourceManager\Laravel\Traits\OrmAccount; // Add the OrmAccount trait
class User extends Authenticatable
{
use HasApiTokens, Notifiable;
use OrmAccount; // Add the OrmAccount trait
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'orm_id',
'username',
'password'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Model\User;
class MyController extends Controller
{
/**
* Trait methods:
*
* $user->account();
* $user->emails();
* $user->mobilePhones();
* $user->addresses();
* $user->duties();
*/
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Shows a user's ORM Account
*/
public function showUserAccount($id)
{
$user = User::findOrFail($id);
return $user->account(); // Returns the ORM account
}
/**
* Shows a user's ORM Emails
*/
public function showUserEmails($id)
{
$user = User::findOrFail($id);
return $user->emails(); // Returns the ORM emails
}
}
shell
php artisan vendor:publish --tag orm
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.