Generate shareable links from your Eloquent models.
You can find the full documentation Here.
MIT
Create shareable links from your eloquent models.
License: MIT License
Generate shareable links from your Eloquent models.
You can find the full documentation Here.
MIT
Hello.
I've been testing your package to replace dwightwatson/autologin on my project and tried to supply an invalid uuid value to the url.
The project is running with a postgres database, that have native field support to uuids. In this case, laravel throws a Illuminate\Database\QueryException.
To solve this, I added a try/catch block to the Route::bind call on the ServiceProvider as below:
The idea is to replace the QueryException with the ModelNotFoundException, that will be handled by Laravel and will generate a proper 404 response.
<?php
Route::bind('shareable_link', function ($value) {
try {
return ShareableLink::where('uuid', $value)->firstOrFail();
} catch(QueryException $e) {
throw new ModelNotFoundException($e->getMessage());
}
});
Do you have a better approach to this? May I open a pull request?
Hello,
I'm trying to get the expired link route to work properly, and keep getting a 404 error screen. Cannot seem to get it to render a view. Here is what is inside my routes/web.php:
Route::domain('{cname}.' . config('routing.domain'))->middleware('subdomain')->group(function () {
Route::get('/interview/{shareable_link}', function (ShareableLink $link) {
$controller = new InterviewController($link);
return $controller->show();
})->middleware('shared')->name('interview.index');
Route::get('/interview/{shareable_link}/next', function (ShareableLink $link) {
$controller = new InterviewController($link);
return $controller->next();
})->middleware('shared')->name('interview.next');
Route::post('/interview/{shareable_link}/record', function (ShareableLink $link, Request $request) {
$controller = new InterviewController($link);
return $controller->record($request);
})->middleware('shared')->name('interview.record');
// Route::get('/interview/expired', 'InterviewController@expired')->middleware('shared')->name('interview.expired');
Route::get('/interview/expired', function () {
dd('here!');
})->name('interview.expired');
});
The config file has the shareable-models.php has 'expired' => '/interview/expired' redirect set. All other shareable routes within group work just fine. When specifying a UUID of an expired shareable link I get redirected to /interview/expired route, but always with a 404. I had also tried to Route::view, which is ultimately all I want in the first place -- just a page alerting the user that the link had expired. And as a test, it never outputs 'here!' in my temporary route above. Any ideas would be appreciated.
Thank you in advance!
There is a typo in this migration file on the 2.0.0.
tag that has been fixed in an earlier version of this package but now was re-introduced.
it is fixed on dev-master
, though i prefer to use a specific version in my composer.json
file. Furthermore, using migrate:refresh
is not valid on the 2.0.0
tag! ;)
Cheers
Not quite sure why this is happening as I have put it in my providers, and after that I ran php artisan config:clear and cache:clear.
Getting this:
Class 'App\Http\Controllers\ShareableLink' not found
Here's the code I'm trying to run
ShareableLink::buildFor($entry) ->setActive() ->build();
I am using MongoDB with jenssegers/laravel-mongodb eloquent implementation, and the SharableLink model currently using laravel official eloquent which doesn't support MongoDB
There are some problems with documentation.
Route::get('shared/{shareable_link}', ['middleware' => 'shared', function (ShareableLink $link) {
return $link->shareable;
});
A closing bracket ]
is missing.
Route::get('shared/{shareable_link}', function (Sassnowski\LaravelShareableModel\Shareable\ShareableLink $link) {
return 'test OK';
})->middleware('shared');
But to no result.
Maybe you could run the package on a clean new instance of Laravel 5.5?
https://ksassnowski.gitbooks.io/shareable-models/content/getting-started.html
use Sassnowski\LaravelShareableModel\Shareable\ShareableLink;
The package should be great, anyway! Thank you.
Peter
This is not explained at all. How am I suppose to get the actual link from a model? I have the model Article, and I want to find Article 1's link. How do I do this?
Any plans to support still widely used PHP 5.6 please?
Dear Kai,
thank you so much for this awesome piece of code - it is really helpful and i managed to implement it in my current api project. However, I have a question regarding "best practice" with this package. Maybe you can help or give advice?
Consider the following (simplified) example of a car customizer (we take Car
as a resource that is customized and to be shared)
User
creates a new resource (e.g., a Car
) and starts adapting it. Thereby, several properties of Car
are changed during run time (e.g., the color
, engine
, ...
) and stored in the database.shortcode
(i.e., a shareable-link
) to the model (Car
) that he created in order to send it to friends, or continue configuring it another day.Specific questions here are:
shareable_link
for the Car
model (e.g., I dont want to have multiple links "pointing" to the same model). Probably the link should be created when creating the Car
model.sharelink_id
field in the cars
table (and Car
model respectively). And (as described in 1) automatically link them when creating the Car
? Or is there another way of "navigating back" (from Car
to the ShareLink
?)Thank you for your time & help,
Best,
Johannes
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.