Member Since 4 Years Ago
180 experience to go until the next level!
In case you were wondering, you earn Laracasts experience when you:
Earned once you have completed your first Laracasts lesson.
Earned once you have earned your first 1000 experience points.
Earned when you have been with Laracasts for 1 year.
Earned when you have been with Laracasts for 2 years.
Earned when you have been with Laracasts for 3 years.
Earned when you have been with Laracasts for 4 years.
Earned when you have been with Laracasts for 5 years.
Earned when at least one Laracasts series has been fully completed.
Earned after your first post on the Laracasts forum.
Earned once 100 Laracasts lessons have been completed.
Earned once you receive your first "Best Reply" award on the Laracasts forum.
Earned if you are a paying Laracasts subscriber.
Earned if you have a lifetime subscription to Laracasts.
Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.
Earned once you have achieved 500 forum replies.
Earned once your experience points passes 100,000.
Earned once your experience points hits 10,000.
Earned once 1000 Laracasts lessons have been completed.
Earned once your "Best Reply" award count is 100 or more.
Earned once your experience points passes 1 million.
Earned once your experience points ranks in the top 50 of all Laracasts users.
Earned once your experience points ranks in the top 10 of all Laracasts users.
Started a new Conversation Laravel-review-rateable Package [Solved]
Hi, I use the review package: https://github.com/codebyray/laravel-review-rateable
I don't understand why each extracted value is displayed as in the image below.
To give an example, this happens with:
{{ $item->averageRating(2, true) }}
Started a new Conversation Play With Subscription Restrictions
Hi, I'm going crazy testing the logic of restrictions via subscriptions with Stripe.
Coming to the point, I would like to manage content through subscriptions that have this logic:
2 [If the user has an expired or terminated subscription with immediate expiry]
3 [Finally, if he is a visitor]
I made a small draft to give an idea, but it seems that if I instantly terminate the subscription for a user (therefore with the immediate expiration which is therefore to be considered expired), it does not show the warning that it has expired.
@if(Auth::check() && Auth::user()->subscribed('default') || Auth::user()->subscription('default')->onGracePeriod())
[If the user is logged in and has a subscription]
[If the user has canceled his subscription but is still in the trial period]
@elseif(Auth::check() && Auth::user()->subscribed('default') && Auth::user()->subscription('default')->ended())
[If the user has an expired or terminated subscription with immediate expiry]
@else
[guest]
@endif
Started a new Conversation Correct Syntax
Hi, following the Stripe schematic, I can't understand the syntax to create the data for the customer invoice.
https://stripe.com/docs/api/metadata?lang=php
$request->user()->newSubscription('default', $plan)->create([
$request->token,
"billing_details" => "..........................................."
]);
Started a new Conversation Manage Billing With Stripe
Hi, accepting payments from all over the world via Stripe, how do I manage billing?
I created a small application that creates the subscriptions, as per instructions on Laravel I am only asked for the card number, holder, expiry date etc.
The payment is successful, thus creating the subscription but rightly so, by going to see the customer's invoice, there is no type of data, if not his email.
So I wonder how to manage the customer's billing data. Thank you
Replied to Show Category List And Related Posts
I was wrong, with the above post report only one post belonging to that category is taken.
Who can help me? Thank you
Replied to Show Category List And Related Posts
I think I have solved this
public function items(){
return $this->hasMany(Items::class, 'category_id', 'id');
}
Started a new Conversation Show Category List And Related Posts
Hi, I would like to get a list of categories where the related posts are shown by clicking.
Right now my code is this:
Categories Model
public function items(){
return $this->belongsToMany(Items::class);
}
@foreach($categories as $cat)
@foreach($cat->items as $item)
{{ $item->title }}
@endforeach
@endforeach
Started a new Conversation Retrieve Stripe Subscription Expiration
Hi, I was studying Cashier / Stripe a bit directly from the Laravel documentation, I apologize in advance, but it becomes more difficult when it is not your native language.
How can I find out when a user's subscription expires? Should it be set by retrieving it from the plan?
try {
$request->user()->newSubscription('default', $plan)->create($request->token);
} catch (\Exception $e) {
return back()->withErrors(['message' => 'Error creating subscription. ' . $e->getMessage()]);
}
Replied to Stripe\PaymentMethod Instance Has Invalid ID:
I checked in the events, in the developer section of Stripe, and SetupIntent is created.
Started a new Conversation Stripe\PaymentMethod Instance Has Invalid ID:
Hi, I'm following this tutorial to create subscriptions via cashier / stripe, unfortunately, however, after entering the test credit card credentials, and sending, this error appears:
Could not determine which URL to request: Stripe\PaymentMethod instance has invalid ID:
I searched around for a while, but I haven't solved it.
public function retrievePlans() {
$key = \config('services.stripe.secret');
$stripe = new \Stripe\StripeClient($key);
$plansraw = $stripe->plans->all();
$plans = $plansraw->data;
foreach($plans as $plan) {
$prod = $stripe->products->retrieve(
$plan->product,[]
);
$plan->product = $prod;
}
return $plans;
}
public function showSubscription() {
$plans = $this->retrievePlans();
$user = Auth::user();
return view('subscribe')->with([
'site_name' => Settings::find('site_name')->value,
'site_description' => __(''),
'page_name' => __('Exclusive Content for Subscribers'),
'categories' => $this->categories,
'user' => $user,
'intent' => $user->createSetupIntent(),
'plans' => $plans
]);
}
public function processSubscription(Request $request)
{
$user = Auth::user();
$paymentMethod = $request->input('payment_method');
$user->createOrGetStripeCustomer();
$user->addPaymentMethod($paymentMethod);
$plan = $request->input('plan');
try {
$user->newSubscription('default', $plan)->create($paymentMethod, [
'email' => $user->email
]);
} catch (\Exception $e) {
return back()->withErrors(['message' => 'Error creating subscription. ' . $e->getMessage()]);
}
return redirect('dashboard');
}
Replied to All Jquery Resources Are Ok But Dropdown Doesn't Work
Ok, solved, apparently other resources were conflicting even though no errors were generated.
Started a new Conversation All Jquery Resources Are Ok But Dropdown Doesn't Work
Hi, I will have gone crazy but it seems that my jquery resources don't exist in my application, in fact the various dropdowns in the menu and much more don't work.
The connections are all correct, also in the console log no errors are shown.
I also cleaned the views, cache. Did I miss something? Thank you
Replied to Sort User List With Who Has The Most Points
The list now looks like this:
admin -> 100 admin -> 100 admin -> 100 userx -> 10 admin -> 100
Replied to Sort User List With Who Has The Most Points
I tried this solution but it duplicates some users.
Started a new Conversation Sort User List With Who Has The Most Points
Hi, I have two tables, Users and Points. I would like to show a list of ranked users sorted by whoever has the most points.
With my code unfortunately they are shown in a staggered order.
$this->topUser = User::whereHas('points', function ($query) {
$query->orderByDesc('score');
})->take(5)->get();
User Model:
public function points(){
return $this->hasMany(Items::class);
}
Points: id, user_id, score, type
Replied to Improve If Condition In Blade
Same problem, with the automatic closing of the div, I realize that it is automatically closed with
</$getcategory
So I guess here's the problem:
<= $getCategory->score
Replied to Improve If Condition In Blade
In my IDE it is enough that I enclose this code inside for example:
The closure marks it in red.
Started a new Conversation Improve If Condition In Blade
Hi, I ask for advice on how to improve this condition in blade, at the moment it works but creates error in HTML syntax.
@if(Auth::check() && Auth::user()->total_point_count() <= $getCategory->score)
{{ __('You cannot view') }}
@else
<!-- if the list is empty -->
@if($items->isEmpty())
{{ __('Empty') }}
@endif
<!-- end if the list is empty -->
@endif
How can I improve it? Thank you
Replied to Email Auth Body Text
This is for the password reset, obviously I have to do the same for the emails sent after registration?
Started a new Conversation Email Auth Body Text
Replied to Problems With Database Import
If I understand correctly, is the problem basically with an older version of MySQL?
Started a new Conversation Problems With Database Import
Hi, I have encountered an oddity in importing the database on two different hosting plans of my provider.
In one with more features I have no problem importing the database, everything is created normally.
While in the lower floor, but with the same version of the database, it has problems importing.
In particular:
-- -- Indici per le tabelle `failed_jobs` -- ALTER TABLE `failed_jobs` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`) USING BTREE Messaggio di MySQL: Documentazione #1071 - The specified key is too long. The max length of the key is 767
Replied to Censoring Some Letters Of A Word
Thank you for your reply, but in the specific package how can I use it?
public function censorString($string, $fullWords = false)
{
// generate our censor checks if they are not defined yet
if (!$this->censorChecks) {
$this->generateCensorChecks($fullWords);
}
$anThis = &$this;
$counter = 0;
$match = array();
$newstring = array();
$newstring['orig'] = html_entity_decode($string);
$original = $this->replaceWhiteListed($newstring['orig']);
// $anThis for <= PHP5.3
$newstring['clean'] = preg_replace_callback(
$this->censorChecks,
function ($matches) use (&$anThis, &$counter, &$match) {
$match[$counter++] = $matches[0];
// is $anThis->replacer a single char?
return (strlen($anThis->replacer) === 1)
? str_repeat($anThis->replacer, strlen($matches[0]))
: $anThis->randCensor($anThis->replacer, strlen($matches[0]));
},
$original
);
$newstring['clean'] = $this->replaceWhiteListed($newstring['clean'], true);
$newstring['matched'] = $match;
return $newstring;
}
Started a new Conversation Censoring Some Letters Of A Word
Hi, I'm using this package, for word censorship, which unfortunately censors the whole word. How can I censor TOT letters of the word?
https://github.com/snipe/banbuilder/blob/master/src/CensorWords.php
So, if the word to be censored is "Hello", it is censored like this "***lo".
Started a new Conversation Sort Posts With "Featured" Posts First
Hi, I would like to ask for advice on how to handle this situation in the cleanest way and that it could be a good writing method to show precedence in my list of posts with those in relief.
I have to create a "featured" field in the "Post" table, with the value 0/1 and then I have to sort the query that retrieves the results as:
orderByDesc('featured')
Replied to Exclude Content From List If User Is Not Subscribed [Laravel Cashier]
So assuming I have this list of categories, how do I check which ones are accessible if the user is subscribed?
Both at the field level in the DB table and programmatically. Also, what kind of validation should I also use to prevent a user from not being able to select this "X" category if they don't have a subscription?
Started a new Conversation Exclude Content From List If User Is Not Subscribed [Laravel Cashier]
Hello, I would like to understand better how to use Laravel Cashier according to my intentions. I explain what I would like to do.
I have a list of categories in a form, but I would like the "X" category to be shown in the list only if the user has signed up.
So let's assume we have the list of categories, what should I do?
@foreach($categories as $cat)
...
@endforeach
Replied to Profanity Words
However, these packages block the insertion of words, but I would just like to obscure them.
Started a new Conversation Profanity Words
Hi, I would like to have an evaluation from you on this package for handling "bad words".
https://github.com/ConsoleTVs/Profanity
It is valid? Alternatively, what would you recommend me to use? Thank you
Replied to "Node_modules" Folder Utility
I used a tutorial to do this, also editing the .htaccess file
Replied to "Node_modules" Folder Utility
I don't know how to answer this question, but I use UI kits, so I directly load the assets.
Replied to "Node_modules" Folder Utility
PS: I tried to rename the folder, to test, and my application apparently from a quick glance seems to be working fine. Could I then eliminate it?
Replied to "Node_modules" Folder Utility
How do I know if they are useful in my application?
Because those present in the "vendor" folder I know I have installed them and therefore I can understand their use and origin, while the "node_modules" folder does not.
Started a new Conversation "Node_modules" Folder Utility
Hi, I don't remember how, but in my application's folder list, I find a folder called "node_modules". How do I find out if I really need it? It really has a lot of content in it ...
I ask for clarification, maybe it's trivial, but I don't understand its usefulness.
Replied to Show Comment List In Modal
I am not very familiar with javascript, am I asking too much if I ask you to give me some practical examples?
Started a new Conversation Show Comment List In Modal
I open a discussion very similar to my last ones, but asking for a specific thing (that if I solve this one, I can probably also solve the doubts of another open discussion of mine).
I have a list of posts within a foreach. I would like you to click on the item:
<a href="" class="text-muted text-truncate">
{{ __(':count Comments', ['count' => $item->comments()->count()]) }}
</a>
A modal opens with the list of comments related to that post. I get the comments with the relationship:
$item->comments() as $comment
How can I do?
I add details to make myself better understood in my request:
Replied to Open A Modal Via Route Controller
I've tried them all, but it's not enough for me to just pass those textual parameters like:
$('#title').html(data.title);
Because I need to get also comment counts, likes, the list of comments ... which I get through relations like $item->comments->count() ...
Replied to Open A Modal Via Route Controller
Route
Route::get('view/{id}', [HomeController::class, 'show_modal'])
->name('show_modal');
Controller
public function show_modal($id)
{
$item = Items::whereHas('category', function ($query) {
$query->where('status', 1);
})->where('id', $id)
->where('status', 1)
->firstOrFail();
return view('layouts.modal_item', compact('item'));
}
View
<div class="modal modal-blur fade" id="show--modal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">
{{ $item->title }}
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<h3>{{ $item->story }}</h3>
</div>
</div>
</div>
</div>
Replied to Open A Modal Via Route Controller
Could you give me an example of the ajax code?
I created this controller
public function show_modal($id)
{
$item = Items::whereHas('category', function ($query) {
$query->where('status', 1);
})->where('id', $id)
->where('status', 1)
->firstOrFail();
$html = view('layouts.modal_item', compact('item'))->render();
return $html;
}
Replied to Open A Modal Via Route Controller
Yes, in my list I see all the details about each post, everything ok. I just wish that clicking on each post would open the post I am calling with all its details.
Started a new Conversation Open A Modal Via Route Controller
I had already opened a discussion on a similar issue, but I would like to find an alternative and therefore post here.
I have a list of posts within foreach, with lots of details, such as title, description, count of likes, list of comments etc. all thanks to the reports.
I would like clicking on each post to open a modal with exactly all the details of that post.
Can I do all this via the controller? To give a quick example of what I mean:
Replied to Better Manage Data Passed In Ajax By Modal Post
I ask a new question, can I do the same thing by calling via the controller and then open a view blade (post.blade.php)?
Something like this, of course, is an example, because rightly in this way it does not pass css and any other details of the template. It is right to make my intent understood.
public function show_modal($id)
{
$item = Items::whereHas('category', function ($query) {
$query->where('status', 1);
})->where('id', $id)
->where('status', 1)
->firstOrFail();
return response('layouts.modal_item')->with([
'item' => $item,
]);
}
Replied to Better Manage Data Passed In Ajax By Modal Post
No, that's not what I'm looking for, sorry. I try to explain myself better.
I have a list of posts with various details, likes, comments etc. All right!
When I click on each post, I open a modal to see the same post, with the same details.
This is done via the ajax call I placed earlier. But unfortunately, I can only go through some simpler details, like the title, the description.
For more complicated details, such as likes or comments, I can't ... since I get them via relation thanks to the $ item variable.
So, if through the ajax call, I could pass the variable $ item as given in the view blade, I might be able to do what I need.
$('body').on('click', '#show--modal', function () {
var item_id = $(this).data('item');
console.log(item_id);
$.ajax({
url : APP_URL + '/view/' + $(this).data('item').id,
success : function (data) {
$('#show--modal--post').modal('show');
$('#item_id').html(data.id);
$('#title').html(data.title); // I'm passing some details but making them appear in the blade via id = "" not as a variable.
// I wish I could pass the $ item variable into the blade
},
error : function (error) {
alert("Errore.");
}
});
});
Replied to Better Manage Data Passed In Ajax By Modal Post
Example: so that then in the blade view I can safely play with (example) {{ $item->title }}
I have improved this way.
But as you can see, I pass the data into the view blade via the div IDs. How can I pass the $ item variable via ajax instead?
$.ajax({
url : APP_URL + '/view/' + item_id,
success : function (data) {
$('#show--modal--example').modal('show');
$('#item_id').html(data.id);
$('#title').html(data.title);
$('#desc').html(data.desc);
},
error : function (error) {
alert("Errore.");
}
});
If I could pass the whole variable I would be able to handle everything.
Replied to Better Manage Data Passed In Ajax By Modal Post
Yes, even if a lot of this data is through relationships. If I could send everything via ajax via variable then I would be able to manage everything in the view blade as a variable.