Comments (7)
I'm aware the issue is old & closed but I've documented the way to combine timestamps() & userstamps() below. This is tested on 5.7 but any version of Laravel that has Blueprint able to use Macro should be ok.
AppServiceProvider:
Blueprint::macro('userTimeStamps', function() {
$this->timestamps();
$this->unsignedBigInteger('created_by')->nullable();
$this->unsignedBigInteger('updated_by')->nullable();
$this->unsignedBigInteger('deleted_by')->nullable();
});
The created_by, updated_by & deleted_by also use unsignedBigInteger as this is consistent with the id columns. You could also change them to foreign keys if you wished.
You then simply need to do
$table->userTimeStamps();
inside your migrations.
from laravel-userstamps.
Good spot on the
unsignedBigInteger
@harry-synergi - have updated the readme.No problem. I'm also confused why you're doing
default(null)
whennullable()
should take care of that? Is this due to the strict DB mode in laravel 5.3?
Nope - just a mistake!
from laravel-userstamps.
I've considered adding something along those lines - will try to take a look at it some point - happy to accept a PR though!
from laravel-userstamps.
:-) What is a PR?
from laravel-userstamps.
Handy section on Pull Requests (PRs) here https://guides.github.com/activities/contributing-to-open-source
from laravel-userstamps.
Good spot on the unsignedBigInteger
@harry-synergi - have updated the readme.
from laravel-userstamps.
Good spot on the
unsignedBigInteger
@harry-synergi - have updated the readme.
No problem. I'm also confused why you're doing default(null)
when nullable()
should take care of that? Is this due to the strict DB mode in laravel 5.3?
from laravel-userstamps.
Related Issues (20)
- Repo has no license HOT 1
- Hard coded created_by implemented instead of getCreatedByColumn HOT 4
- The 'update' events are getting fired on deletion
- deleted_by not set when deleting relationship elements HOT 3
- userstamps() in migrations HOT 2
- User class not found HOT 1
- Waiting for 1.0.0 HOT 2
- Two queries executed when deleting HOT 1
- Lumen Support! HOT 1
- suggestion, add user name HOT 2
- How much memory is needed to run the tests ? HOT 1
- The user in the parent table is not updated when the child record is modified HOT 2
- Support for Laravel 8? HOT 1
- detach doesn't work with userstamps HOT 1
- Laravel 9 HOT 1
- Support for Laravel 9 HOT 1
- This package does not support multiple guard ?
- Question about avoiding load three time relation with user model HOT 3
- User model with reset password HOT 1
- Support for Laravel 11 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-userstamps.