laracoft

laracoft

Member Since 1 Year Ago

Experience Points
21,300
Total
Experience

3,700 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
2
Lessons
Completed
Best Reply Awards
25
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    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.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 5
21,300 XP
Sep
27
23 hours ago
Activity icon

Replied to Git Hub - I Work Alone, Is There Any Point In Using Git Hub ?

@vincej

  1. Some JAAM stack developers use GitHub for syncing up with a hosting on Netlify.
  2. Since you tagged Laravel, I personally don't find much use. Git alone is enough for version control.
  3. Having a GitHub profile ready is also useful if you ever want to publish packages/code as a way of establishing your credentials.
Activity icon

Replied to How To Setup Laravel File Permission Once And For All

  1. A quick check shows that the group is also www-data, can you confirm with ll?
  2. If yes, just edit /etc/group to have this line www-data:x:<number>:www-data,my-user
Activity icon

Replied to How To Setup Laravel File Permission Once And For All

@jewishmoses what is your setup? Pure Linux server? Or some kind of VirtualBox VM?

  1. Find out the group of your /var/www/domain.com. Do a ll, it is the name beside www-data.
  2. Edit /etc/group and add apache to the end of that group. (I take it you are using apache)
  3. Also add my-user to the end of that same group.

In my case of using VirtualBox's file sharing, I have to do this vboxsf:x:123:root,apache

Activity icon

Replied to Index.php In Public Folder Is Not Loading Js And Css Files

@zool

A Laravel folder structure looks like this. You should undo all the files you have moved etc.

C:\xampp\Laravel
├── app
├── public  <- DocumentRoot must point here
├── vendor
...
└── storage
  1. In your case, edit C:\xampp\apache\conf\httpd.conf
  2. Find DocumentRoot "C:/xampp/htdocs" and change it to be DocumentRoot "C:/xampp/Laravel/public"
  3. Restart Apache
  4. Load http://localhost/ to see your Laravel project, http://localhost/robots.txt should work
  5. If things don't work initially, re-install Laravel into the same folder C:\xampp\Laravel
Activity icon

Replied to Sum For Loop Values

@felicia00

In the interest of moving you forward, this will work. However, like @jlrdw said, it is not considered as a good practice. The better way is to perform all your business logic code (i.e. calculating $total) in 1 place such as your model.

@php ($total = 0)
@foreach($sum as $ind=>$dtl)
<?php
    $total += $dtl->amount;
?>
@endforeach
<tr>
    <th>TOTAL</th>
    <td><input type="text" type="number" id="total" name="total" 
        value="{{$total}}" /></td>
</tr>
Activity icon

Replied to Deployed Laravel To Web-hosting, Now ALL My Files Are Accessible In The Root Directory.

@akc4 .htaccess is not reliable because the administrator can misconfigure the server to disable .htaccess and create exposure, but changing the root folder by mistake is less likely.

If your .env is one folder level higher than public (which is Laravel's default), it is considered safe.

Activity icon

Replied to DigitalOcean Newbie Questions

@msslgomez sure if they provide the option.

Activity icon

Replied to Deployed Laravel To Web-hosting, Now ALL My Files Are Accessible In The Root Directory.

@jlrdw I agree with being completely out of public_html, but did not want to add to further confusion.

Anyway, I also change public_html to throw off those script kiddies who hardcode these locations :)

Activity icon

Awarded Best Reply on Deployed Laravel To Web-hosting, Now ALL My Files Are Accessible In The Root Directory.

@akc4 I think you are pointing your http://www.example.com to the laravel folder. You need to point it to the public folder. Once you point to public, there is no need to move any files etc.

laravel     <- currently pointing here
├── app
├── public  <- point here
├── vendor
...
└── storage
Activity icon

Replied to Custom Route File Laravel 8 Not Working As Intended

@abdulrehmandev it doesn't make sense that a missing / before the CSS styles path causes a redirect() to /home as described in your OP. redirect()s are caused by bad routes and/or controller methods.

Hope you can pick a best answer. Thank you.

Activity icon

Replied to Deployed Laravel To Web-hosting, Now ALL My Files Are Accessible In The Root Directory.

@akc4 I think you are pointing your http://www.example.com to the laravel folder. You need to point it to the public folder. Once you point to public, there is no need to move any files etc.

laravel     <- currently pointing here
├── app
├── public  <- point here
├── vendor
...
└── storage
Activity icon

Replied to DigitalOcean Newbie Questions

@msslgomez all plans seem to combine domain, DNS and hosting. Essential and Ecommerce seem to be providing even coding 🤣🤣🤣

I normally prefer to separate domain from hosting. Most registrars provide domain + DNS and I find someone else to provide hosting.

What do you plan to do with 1 page? Realistically, I think it is pointless when what you plan to use is an instance of Laravel.

Activity icon

Replied to 1 Instance Of Laravel With Multiple Subdomains

@kingmaker_bgp Yea, then what about emails with routes that only work on admin.?

Activity icon

Replied to 1 Instance Of Laravel With Multiple Subdomains

@kingmaker_bgp config('app.url') and thereby APP_URL is often used in emails. How does that work if I my route works only on www.?

Activity icon

Replied to DigitalOcean Newbie Questions

@msslgomez sure, I had many clients who DIY to save cost but end up struggling with getting the domains and DNS in order.

Activity icon

Replied to Custom Route File Laravel 8 Not Working As Intended

@abdulrehmandev L8 does not accept "[email protected]" anymore. You must write [\App\Http\Controllers\HomeController::class, 'programs'] or whatever the namespace of HomeController is.

Activity icon

Replied to Custom Route File Laravel 8 Not Working As Intended

@abdulrehmandev Your routes/admin.php is registered differently. routes/web.php specifies the web middleware.

Route::middleware('web')
    ->prefix('admin')
    ->group(base_path('routes/admin.php'));
Activity icon

Replied to 1 Instance Of Laravel With Multiple Subdomains

@artcore

What do you mean by the subdomain folder? There is only one public correct? I'm working on the basis of multiple subdomains in 1 app.

If you use multiple root folders, that would mean having multiple entries in your web server, yes? This would be a con for scalability.

Anyway I was already using routing, but this discussion gave me some ideas on further improvement (which worked).

My only unsolved issue now is the value of APP_URL

Activity icon

Replied to DigitalOcean Newbie Questions

@msslgomez yes, I'm very familiar with domain and DNS setup, especially troubleshooting them.

Activity icon

Replied to Grouped Queries

@jlrdw thanks, cronix just knocked some sense into me. :)

Activity icon

Replied to DigitalOcean Newbie Questions

@msslgomez the link looks ok, but these articles tend to go stale after a while and I'm not sure if the screenshots etc are up to date.

If you mean pulling from BitBucket into your DigialOcean server, that would be a bash command git clone <bitbucket project URL>.

Activity icon

Replied to Grouped Queries

<?php
$selectOptions = Selectoption::
    selectRaw('count (distinct country) as country_count, count (distinct broad_category) as category_count, count (distinct narrow_category) as type_count, count (distinct series) as series_count')
    ->where(function ($query){
        $query
            ->where('broad_category', '=', 'Currency')
            ->orWhere('broad_category', '=', "Coins");
    })
    ->where(function ($query){
        $query
            ->where('narrow_category', '=', "Nickles")
            ->orWhere('narrow_category', '=', "Dollars");
    })
    ->where('country', '=', "USA")
    ->get();
Activity icon

Replied to DigitalOcean Newbie Questions

@msslgomez

  1. Domains are separate from hosting. You need to buy one from a registrar and setup the DNS properly. You might want to consider engaging professional help for this if you are unfamiliar.
  2. Hosting is practically like setting things up on your local machine, instantaneous. Domains are a different story, especially you are not familiar, it can take up to days if you get things wrong. Typically, it should be up within an hour or so.
Activity icon

Replied to Is There A Way To Remove Border When The Submitted Input Is Invalid?

/needmoreinfo

Is the red border by the browser? firefox? do you know what is the CSS for the red border?

input:required {
    box-shadow:none;
}
input:invalid {
    box-shadow:0 0 3px red;
}

Or some Javascript package?

Activity icon

Replied to 1 Instance Of Laravel With Multiple Subdomains

Can explain what do you set for your APP_URL?

Activity icon

Awarded Best Reply on My Facade Doesn't Work In Console Command

@itwrx possible to paste the full codes? offhand, I can tell that boot() is missing from the service provider. It might be something else other than what you showed that cause the issue.

Activity icon

Replied to My Facade Doesn't Work In Console Command

haha glad it's fixed, yes i have a beverage link at https://paypal.me/payseong thanks~

Activity icon

Replied to How To Pass Variable To Form Request From Controller?

@sagar001 welcome, I made an even better change $larger_side = max($this->width, $this->height);

Activity icon

Replied to Paypal Payment VALIDATION_ERROR Item Amount Must Add Up To Specified Amount Subtotal

You likely have a rounding error which can be verified by checking the full HTTP request that was sent to PayPal's server in the $payment->create($this->payPal);. Can you show it here?

Activity icon

Replied to My Facade Doesn't Work In Console Command

@itwrx possible to paste the full codes? offhand, I can tell that boot() is missing from the service provider. It might be something else other than what you showed that cause the issue.

Activity icon

Awarded Best Reply on How To Pass Variable To Form Request From Controller?

@sagar001

While your code does achieve your intended logic, it is quite hard to read correctly for most people. So it would not qualify as readable code to me. What I would do is one of the following, with option 1 being my most preferred:

// option 1
function ($attribute, $value, $fail){
    $larger_side = max($this->width, $this->height);
    if ($larger_side <= 1080) {
        $fail("Wallpaper's width or height must be greater than 1080px.");
    }
}

// option 2
function ($attribute, $value, $fail){
    if($this->width > $this->height) $larger_side = $this->width;
    if($this->height > $this->width) $larger_side = $this->height;
    if ($larger_side <= 1080) {
        $fail("Wallpaper's width or height must be greater than 1080px.");
    }
}

// option 3
function ($attribute, $value, $fail){
    if($this->width > $this->height && $this->width <= 1080) $error = true;
    if($this->height > $this->width && $this->height <= 1080) $error = true;
    if ($error) {
        $fail("Wallpaper's width or height must be greater than 1080px.");
    }
}
Activity icon

Replied to How To Pass Variable To Form Request From Controller?

@sagar001

While your code does achieve your intended logic, it is quite hard to read correctly for most people. So it would not qualify as readable code to me. What I would do is one of the following, with option 1 being my most preferred:

// option 1
function ($attribute, $value, $fail){
    $larger_side = max($this->width, $this->height);
    if ($larger_side <= 1080) {
        $fail("Wallpaper's width or height must be greater than 1080px.");
    }
}

// option 2
function ($attribute, $value, $fail){
    if($this->width > $this->height) $larger_side = $this->width;
    if($this->height > $this->width) $larger_side = $this->height;
    if ($larger_side <= 1080) {
        $fail("Wallpaper's width or height must be greater than 1080px.");
    }
}

// option 3
function ($attribute, $value, $fail){
    if($this->width > $this->height && $this->width <= 1080) $error = true;
    if($this->height > $this->width && $this->height <= 1080) $error = true;
    if ($error) {
        $fail("Wallpaper's width or height must be greater than 1080px.");
    }
}
Activity icon

Replied to Count Value Db

$building_id = 6; // which building?
$level_id = 6; // count the apartments on floor 6

$itemsCount = Item::where('level_id', $level_id)
    ->where('project_model_id', $building_id)
    ->count('id');

return view('developer.project.detail', compact('ItemsCount'));
Activity icon

Replied to Count Value Db

$building_id = 6; // which building?
$level_id = 6; // count the apartments on floor 6

$itemsCount = Item::count('id')
    ->where('level_id', $level_id)
    ->where('project_model_id', $building_id)
    ->get();

 return view('developer.project.detail', compact('ItemsCount'));
Activity icon

Replied to Count Value Db

Do you want the apartments in each building or floors?

You have 1 building, no need a loop. How do you plan multiple counts (apartments according to floor) without a loop?

Please give an example of the output you want to show.

Activity icon

Replied to Count Value Db

Yea you could use level_id, but it is less meaningful than using id, as each id means 1 apartment, but level_id refers to the floor of the apartment.

Remember, you are trying to count the number of apartments.

I'm also puzzled by your choice of project_model_id instead of level_id, but wrote the code according to what you asked for.

Activity icon

Replied to Count Value Db

Apartments::groupBy('project_model_id')
   ->count('id')
   ->get();
Activity icon

Replied to How To Watch Input Type File And Pass New Data?

Why do you ask the same question in a new discussion everyday?

Activity icon

Replied to Cannot Update Image (file Type) In Database On Updating Record.

See 1 to 8 on how to show us the chrome logs for api/news/{form_id}.

Activity icon

Awarded Best Reply on Change String To Unicode (Example: O -> U006f)

@hueilau

    $utf = "🤷‍♂️";
    $convmap = array(0x0100, 0xFFFF, 0, 0xFFFF);
    $encutf = mb_encode_numericentity($utf, $convmap, 'UTF-8');
    $iso = utf8_decode($encutf);
    echo $iso;

Your output would be

?&#8205;&#9794;&#65039;
Activity icon

Replied to Change String To Unicode (Example: O -> U006f)

@hueilau

    $utf = "🤷‍♂️";
    $convmap = array(0x0100, 0xFFFF, 0, 0xFFFF);
    $encutf = mb_encode_numericentity($utf, $convmap, 'UTF-8');
    $iso = utf8_decode($encutf);
    echo $iso;

Your output would be

?&#8205;&#9794;&#65039;
Activity icon

Replied to My Facade Doesn't Work In Console Command

It is a herculean task here to imagine and make assumptions about the code at your end. It's easier if you can paste your full

  1. class ITwrxEncryptionServiceProvider
  2. class Encrypter
  3. class ITwrxCrypt
  4. Console command class
Sep
26
1 day ago
Activity icon

Replied to How To Create A Slug When Importing A Csv File

@codebyray ok, you have to show more code. How are you importing the CSV and how is it linked to $this->defaults?

Activity icon

Replied to Cannot Update Image (file Type) In Database On Updating Record.

Step 1 to 8, which one you stuck or don't understand?

Activity icon

Replied to Cannot Update Image (file Type) In Database On Updating Record.

@anonymouse703 asking the same question is going to get you the same answer unless you produce some useful logs. And let's deal with 1 issue at a time, in this case, let's deal only with the validate issue.

To produce useful logs with Chrome:

  1. Press F12 to bring up Developer tools
  2. Click on Network tab
  3. Check Preserve log
  4. Check Disable Cache
  5. Press the Clear button
  6. Click on your form's submit button
  7. Click on the first URL that appears in the Developer tools
  8. Under Headers, click Form Data and view source, select the all the data copy and paste them here
Activity icon

Replied to Remove Image Laravel 7

class ArticleObserver
{
    public function deleted(Article $article)
    {
	if ($article->images) $article->images->each->delete();
    }
}
class ArticleImageObserver
{
    public function deleted(ArticleImage $image)
    {
        if(Storage::disk('public')->exists($image->src)){
            Storage::disk('public')->delete($image->src);
        }
    }
}
Sep
25
2 days ago
Activity icon

Replied to How To Create A Slug When Importing A Csv File

What about something like this?

$this->defaults = [
    'slug' => SlugService::createSlug(Salon::class, 'slug',  'name') .'-'.
    SlugService::createSlug(Salon::class, 'slug',  'city') .'-'.
    SlugService::createSlug(Salon::class, 'slug',  'state') .'-'.
    SlugService::createSlug(Salon::class, 'slug',  'postal')
];
Activity icon

Replied to Remove Image Laravel 7

This should work, if it does, remove the dump().

if not please paste the output paths logs.

public function destroy($id)
{
    $article = Article::findOrFail($id);
    if($article->images){
        foreach ($article->images as $image)
        {
	    dump(public_path($image['src']));
            Storage::delete(public_path($image['src']));
        }
        $article->images()->delete();
    }
    $article->delete();
    return back();
}