Package Data | |
---|---|
Maintainer Username: | alex-oliveira |
Package Create Date: | 2017-05-28 |
Package Last Update: | 2018-02-28 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-14 15:10:03 |
Package Statistics | |
---|---|
Total Downloads: | 27 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
$ composer require alex-oliveira/ao-logs
'providers' => [
/*
* Vendor Service Providers...
*/
AoLogs\ServiceProvider::class,
],
return [
.
.
.
'models' => [
'users' => App\Models\User::class,
],
'tables' => [
'users' => 'users'
]
.
.
.
];
$ php artisan vendor:publish --tag=ao-logs
$ composer dump
public function up()
{
AoLogs()->schema()->create('users');
}
the same that
public function up()
{
Schema::create('ao_logs_x_users', function (Blueprint $table) {
$table->integer('user_id')->unsigned();
$table->foreign('user_id', 'fk_users_x_ao_logs')->references('id')->on('users');
$table->bigInteger('log_id')->unsigned();
$table->foreign('log_id', 'fk_ao_logs_x_users')->references('id')->on('ao_logs_logs');
$table->primary(['user_id', 'log_id'], 'pk_ao_logs_x_users');
});
}
public function down()
{
AoLogs()->schema()->drop('users');
}
the same that
public function down()
{
Schema::dropIfExists('ao_logs_x_users');
}
namespace App\Models;
use AoLogs\Traits\AoLogsTrait;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use AoLogsTrait;
}
the same that
namespace App\Models;
use AoLogs\Models\Log;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* @return Log[]|\Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function logs()
{
return $this->belongsToMany(Log::class, 'ao_logs_x_users');
}
}
namespace App\Http\Controllers\Users;
use AoLogs\Controllers\AoLogsController;
use App\Models\User;
class LogsController extends AoLogsController
{
protected $dynamicClass = User::class;
}
Route::group(['prefix' => 'users', 'as' => 'users.'], function () {
AoLogs()->router()->controller('Users\LogsController')->foreign('user_id')->make();
.
.
.
});
$ php artisan route:list
$category = \App\Models\Category::find(1);
.
.
.
AoLogs()->post($category, [
'title' => 'Cadastro realizado.',
'description' => 'O usuário "Alex Oliveira" realizou o cadastro da categoria "Computadores".'
]);