www888

Member Since 4 Months Ago

Experience Points
3,180
Total
Experience

1,820 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
0
Lessons
Completed
Best Reply Awards
0
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.

  • Community Pillar

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

Level 1
3,180 XP
Jun
12
2 days ago
Activity icon

Started a new Conversation Laravel Csrf

Hello using search method get, do i need use @csrf ?

     <form  method="GET" action="{{route('search')}}" >
                      @csrf
<input class="form-control form-control-navbar" type="search" name="q">
                        <button type="submit" class="btn btn-default"><i class="fas fa-search"></i></button>
                  </form>



public function search(Request $request)
{     

    $q = trim($request->get('q')); 
   Posts::where('title', 'LIKE', "%{$q}%")->paginate(150);
Jun
10
4 days ago
Activity icon

Replied to Encoding Format (jfif) Is Not Supported - Laravel

Change

getClientOriginalExtension() to extension() and it worked

Activity icon

Started a new Conversation Encoding Format (jfif) Is Not Supported - Laravel

Hello

I used Intervention image plugin, everything worked. uploading files but one day is stop working and when trying upload it gives error.

This is in log Intervention\Image\Exception\NotSupportedException: Encoding format (jfif) is not supported.

This my function

public function photoUploads(Request $request)
{


    $year_folder = date("Y");
    $month_folder = date("m");
    $path_year = "uploads/cars/".$year_folder;   
    $path_month = $path_year."/".$month_folder."/";       
    if(!File::exists($path_year)) {
        File::makeDirectory($path_year, 0775, true);
    }
    if(!File::exists($path_month)) {
        File::makeDirectory($path_month, 0775, true);
    }
    $path = $path_month;

 if($request->hasFile('auctionImage')){         
    $auctionImages = $request->file('auctionImage');     
       foreach ($auctionImages as $auctionImage) {
            $auctionName = hexdec(uniqid()).'.'.$auctionImage->getClientOriginalExtension(); 
            Image::make($auctionImage)->resize(1200, 1200, function ($constraint) {$constraint->aspectRatio();$constraint->upsize();})->save($path.$auctionName);
            $auctionUrl = $path . $auctionName;
            return $auctionUrl;
        }
 }

Jun
09
5 days ago
Activity icon

Replied to Laravel Search Exact Match

How can I make exact match only last 6 charset

Jun
08
6 days ago
Activity icon

Started a new Conversation Laravel Search Exact Match

Hi, How search exact match?

 $car = Car::where('vin', 'LIKE', "%{$vin}%")->firstOrFail();
Jun
06
1 week ago
Activity icon

Started a new Conversation Running The Scheduler

Hello I have project which using scheduler. When upload on server run command

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

If I make update in my project in local , I will delete all files on my server and upload it again, I must run command again ?

Jun
05
1 week ago
Activity icon

Replied to Schedule In Laravel

anyone can help?

Activity icon

Replied to Schedule In Laravel

I try this but not updating price

Activity icon

Replied to Schedule In Laravel

What you mean "actually running"?

Activity icon

Started a new Conversation Schedule In Laravel

Hi I want create schedule in Laravel In app/Console/Kernel.php this is my code

    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')->hourly();

        $schedule->call(function () {
            $products = Product::all();
                foreach($products as $product)
                {
                    DB::table('products')
                    ->where('status', 1)
                    ->update(['tax_price' => 100]);
                }
        })->everyMinute(); 
    }

In products I want update each product tax price which status is 1. but schedule not works, where I have mistake ?

Jun
04
1 week ago
Activity icon

Started a new Conversation Delete Model And Controller

Hi I create model and controller after this I delete this files and migration also. Then I run

php artisan cache:clear
php artisan config:clear
php artisan cache:clear

but when search see this controller name in files https://ibb.co/VDS1WDB

There is any command or what is correct way delete modal controller migration ?

Activity icon

Replied to Javascript Current Time With Zero

Like this?

var today = new Date(0);
 var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
  var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = new Date().toISOString().replace('T', ' ').slice(0, 19);
Activity icon

Started a new Conversation Javascript Current Time With Zero

Hi, Getting currant time with javascript

var today = new Date(0);
 var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
  var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
 var dateTime = date+' '+time;

Result 2021-6-4 13:2:1

What show like with zeros 2021-06-04 13:02:01

May
26
2 weeks ago
Activity icon

Replied to Days Between Two Dates In Laravel

now showing date like 2021-05-07 23:00:00

Activity icon

Replied to Days Between Two Dates In Laravel

now() also need parse

Activity icon

Replied to Days Between Two Dates In Laravel

I check doc but can not find how get from $car->buy_date date form Y m d

try this but not works $car->buy_date->format('Y-m-d')

Activity icon

Replied to Days Between Two Dates In Laravel

Now I don't get same same number of day number. Using {{ now()->diffInDays($car->buy_date) }} for ex. if buy date I have 2021-05-07 00:00:00 day = 19 if 2021-05-07 23:00:00 day = 18

p.s. using {{ today()->diffInDays($car->buy_date->toDateString()) }} error Call to a member function toDateString() on string

Activity icon

Replied to Days Between Two Dates In Laravel

{{ now()->diffInDays($car->buy_date) }} using only this time no and buy date using format Y-m-d H:i:s , I want pars and and then calculate between Y-m-d not use H:i:s

Activity icon

Replied to Days Between Two Dates In Laravel

In blade I have {{$car->buy_date}}

And I want show day between buy date and date now

Activity icon

Started a new Conversation Days Between Two Dates In Laravel

Hello

I want calculate days between two dates in laravel End date is currant date Start date I have in DB like this format 2021-03-01 04:03:00

  1. How can I do what $date1 see only Y-m-d (2021-03-01)
function dateDiffInDays($date1, $date2) 
{
    $diff = strtotime($date2) - strtotime($date1);
    return abs(round($diff / 86400));
}
  
// Start date
$date1 = "2021-03-01 04:03:00";
// End date
$date2 = date('Y-m-d');

$dateDiff = dateDiffInDays($date1, $date2);
  1. and how I can send this calculate day index function
   public function index()
    {
        
        $products = Product::all();     
      
 
        return view('products.index', [
            'products'=>$products, 
            ]);
    }
May
25
2 weeks ago
Activity icon

Replied to Laravel Check Property Is Not Null

I change my cod line

$userIdSub = User::where('sub_user_id',$userId)->first(['id'])->id;

to

    $posts = Post::whereIn('user_id', array_filter([
        Auth::id(), User::where('sub_user_id',$userId)->first(['id'])->id; ?? null
    ]))->paginate(50);

and it works, thanks

Activity icon

Replied to Laravel Check Property Is Not Null

Hi,

I dont have subUser model

In user DB I have value owner_id, so I need find user which have same id which using auth user

Activity icon

Replied to Laravel Check Property Is Not Null

syntax error, unexpected token ";", expecting "]"

p.s. what this ?? 0 doing ?

Activity icon

Started a new Conversation Laravel Check Property Is Not Null

Hello I have user and some of user has sub user

In user DB I have sub_user_id value

Now I want get auth user post + it sub user post


    public function index()
    {
        //
        $userId = Auth::id();
        $userIdSub = User::where('sub_user_id',$userId)->first(['id'])->id;
        

        $posts = Post::where('user_id',$userId)
        ->orWhere('user_id', $userIdSub)
        ->paginate(50);
    }

This owrks and getting auth user post + it sub user post BUT if for user don't have set sub user id getting error ,

Attempt to read property "id" on null (on this line $userIdSub = User::where('sub_user_id',$userId)->first(['id'])->id;)

May
04
1 month ago
Activity icon

Started a new Conversation Laravel Login Office 365

Hello There is any module integrate Microsoft 365 user to laravel auth, I mean user can log in using O365 user and pass

Apr
15
1 month ago
Activity icon

Replied to Show Function With Two Parameters

show($id, $hash) this parament need any security check ?

Activity icon

Started a new Conversation Show Function With Two Parameters

Hello

I have post model and controller. with migration

            $table->string('title');
            $table->string('hash');
            $table->text('short'); 
            $table->text('full')->nullable(); 

When I create post it automatically generate hash for each post

show function for post when using id (fro ex. site.com/post/1 )

Route::get('/post/{id}', [App\Http\Controllers\PostController::class, 'show']);
    public function show(Post $id)
    {
        return view('show.post', ['post'=>$post]);
    }

I want make show Id and + hash like

Route::get('/post/{id}/{hash}', [App\Http\Controllers\PostController::class, 'show']);

How have two parameters there. Link must have both parameters to show post (/post/1/dfgh4g6u546)

    public function show(Post $id)
    {
        return view('show.post', ['post'=>$post]);
    }
Apr
14
2 months ago
Activity icon

Started a new Conversation Laravel On Shared Hosting

Hi

When uploading Laravel project on shared hosting (sitground) it makes accessible my site like ~/public_html/public/index.php www.test.com/public/index.php how I can make it www.test.com

Activity icon

Started a new Conversation Registration In Laravel/breeze

Using laravel/breeze where can I find routes /login /forgot-password /register (web.php ther is not this routes)

Activity icon

Replied to Intervention Image And FilePond

It looks after update xampp disable GD Library In your php.ini you need enable ;extension=php_gd (reamove ; )

Apr
13
2 months ago
Activity icon

Replied to Intervention Image And FilePond

Image::make($file)->resize(1200, 1200, function ($constraint) {$constraint->aspectRatio();$constraint->upsize();})->move("uploads/" . $name_gen);

using this but same error

Activity icon

Replied to Intervention Image And FilePond

"GD Library extension not available with this PHP installation"

Activity icon

Replied to Intervention Image And FilePond

Your answer is wrong

Apr
12
2 months ago
Activity icon

Started a new Conversation Intervention Image And FilePond

Hi

Uisng FilePond

<input id="photos" name="image[]" type="file"multipledata-allow-reorder="true"data-max-file-size="3MB"data-max-files="3">
  
<script>
  FilePond.registerPlugin(FilePondPluginImagePreview);
const inputElement = document.querySelector('input[id="photos"]');
const pond = FilePond.create( inputElement );
FilePond.setOptions({
server:{
    url: '/photo', 
    process: '/uploads',
    revert: '/delete',
    headers: {
          'X-CSRF-TOKEN': '{{ csrf_token() }}'
          }
        }

}); 
</script>

....

   public function uploads(Request $request)
    {
     if($request->hasFile('image')){         
        $files = $request->file('image');       
           foreach ($files as $file) {
                    $filename = $file->getClientOriginalName();
                    $name_gen = hexdec(uniqid()).'.'.$file->getClientOriginalExtension();
                    $folder = uniqid();               
                   $file->move("uploads/" .,$name_gen);           
                   $url = "uploads/" . $name_gen;
                    return $url;
      }
     } 
     return '';
}

This function works upload image, now I want add Intervention Image

tried this but give response 500 error

   public function uploads(Request $request)
    {
     if($request->hasFile('image')){         
        $files = $request->file('image');       
           foreach ($files as $file) {
                    $filename = $file->getClientOriginalName();
                    $name_gen = hexdec(uniqid()).'.'.$file->getClientOriginalExtension();
                    $folder = uniqid();               
                   //$file->move("uploads/" .,$name_gen);         

       Image::make($file)->resize(1200, 1200, function ($constraint) {$constraint->aspectRatio();$constraint->upsize();})->move(uploads/" . $name_gen);

  
                   $url = "uploads/" . $name_gen;
                    return $url;
      }
     } 
     return '';
}
Activity icon

Replied to Laravel Filepond Multi Images Upload

anyone have experience with filepond

Apr
10
2 months ago
Activity icon

Started a new Conversation Laravel DOMPDF UTF 8

Using DOMPDF, when generate pdf not English text showing ??????? How can I add UTF8 encoding ?

    public function getPDF($id)
    {    
         
        $invoice = Invoice::find($id); 
 
        $pdf = PDF::loadHTML('invoices.pdf', ['invoice' => $invoice] );
    
        return $pdf->download('file.pdf');
    }

in blade using


<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
Activity icon

Replied to Laravel DOMPDF

Using


  <link rel="stylesheet" href="{{asset('dist/css/adminlte.min.css')}}">

Activity icon

Replied to Laravel DOMPDF

Problem is that when in blade

I have

stylesheet and div it not works, but if I use simple html table it generate pdf. how can i fix this ?

Activity icon

Replied to Laravel DOMPDF

Not working

Activity icon

Started a new Conversation Laravel DOMPDF

Hi, Using DOMPDF

Route

Route::get('/pdf/{invoice}', [App\Http\Controllers\InvoiceController::class, 'getPDF'])->name('invoice.pdf');

Function

    public function getPDF(Invoice $invoice)
    {     
          
        $pdf = PDF::loadView('invoices.print', $invoice );
    
        return $pdf->download('file.pdf');
    }

Blade

            <table class="table"> 
              <tr>
                <td><strong>Payment Day: {{$invoice->date}}</strong></td>
              </tr>
              <tr>
                <td><strong>INVOICE#: {{$invoice->invoice_number}}</strong></td>
              </tr> 
              <tr>
                <td><strong>Buyer: {{$invoice->name}}</strong></td>
              </tr>
            </table>

Getting error Undefined variable $invoice

Apr
07
2 months ago
Activity icon

Started a new Conversation Moment.js Get Sleeted Month Days

Hello Using daterangepicker and moment (https://www.daterangepicker.com) Tying get days number in selected date (fore ex. if is set. 04-07-2021 get 30) but it not gives number

<input type="text" id="date" name="dates" />

 <script>
	jQuery(document).ready(function($) {
$('input[name="dates"]').daterangepicker({
   singleDatePicker: true,
  startDate: moment()
});

     var selecteddate = $("dates").val();
      var month=(moment(selecteddate, "MM-D-YYYY").daysInMonth());
        alert(month);
 });
 </script>
Activity icon

Replied to Javascript Loop Dont Increment Last Item Value

Hi

Make update

<p id="demo1"></p>
<p id="demo2"></p>
<script>
var month = 12;
var amount = 100;
var step = 50;
var text1 = "";
var text2 = "";
var i;
var number1;
var number2;
var total = 0;
for (i = 0; i <= month; i++) {

  number1 = amount + (step * i);
  text1 += number1 + "<br>";
  number2 = (number1-step)*2;
  text2 += number2 + "<br>";
   
  total =  number2+total;

}
 
alert(total);
document.getElementById("demo1").innerHTML = text1;
document.getElementById("demo2").innerHTML = text2;
</script>
result :

100
150
200
250
300
350
400
450
500
550
600
650
700

100
200
300
400
500
600
700
800
900
1000
1100
1200
1300

total sums

100+200+300+400+500+600+700+800+900+1000+1100+1200+1300 and gives 9010 But I need exclude loop first number (on this ex, 100) when it calculate total and get 9000

Activity icon

Started a new Conversation Foeach Loop Select Filed

Hi I have loop

foreach ($locations as $location) { 
            echo '<option value="'.$location.'">'.$location.'</option>';
  }

I want add additional check for option if it is select, how can I add this if into option

if (in_array($location, $checkedArray)) { echo 'selected'; }
Apr
03
2 months ago
Activity icon

Started a new Conversation Laravel Multiple Image Upload

Hello Need recommendation what can be solution: I have post , with values title text and Multiple Image Upload (50 max). If I use simple php code for upload server have problem when I attach 50 photo and trying upload. ()

What can I do this case, use user side image compression or use ajax when attach image auto upload

Can any one give recommendation. (tutorials or plugins)

Apr
02
2 months ago
Activity icon

Started a new Conversation Laravel If Statement For Select

Hi,

I have users table like

Users: id role_id owner_id name

( $owners = User::all(); owner_id is value where I put owner user id. for ex. for user id 1 owner is user id 2 )

I want make check, If user with id 1 have owner_id 2 == $owner->owner_id (for ex 2 then make select)

@foreach($owners as $owner)
 <option value="{{$owner->id}}"<?php if ($user->id->owner_id == $owner->owner_id) {
echo "selected"; } ?> >{{$owner->name}} {{$user->id}}</option>
@endforeach
Apr
01
2 months ago
Activity icon

Replied to Javascript Loop Dont Increment Last Item Value

Hi,

I need for by month but in last loop I dont want increment

Need result like (for 13 month ) 12 an 13 will be same 155

100 105 110 115 120 125 130 135 140 145 150 155 155

Activity icon

Replied to JavaScript For Loop

This returns this number 100001100012000130001400015000160001700018000190002000021000 , x12 time

Activity icon

Started a new Conversation Javascript Loop Dont Increment Last Item Value

Hi

<p id="demo1"></p>
<p id="demo2"></p>
<script>
var month = 12;
var amount = 100;
var step = 5;
var text1 = "";
var text2 = "";
var i;
var length = amount+month*step;
for (i = amount; i <= length; i += step) {
var sum = 0;
  text1 += i + "<br>";
  text2 += Math.round((i*0.11/365)*31) +"<br>";
}
document.getElementById("demo1").innerHTML = text1;
document.getElementById("demo2").innerHTML = text2;
</script>

In result have 13 line, Need , do not increment last item 155, 160

100
105
110
115
120
125
130
135
140
145
150
155
160 // I want that this last also be 155

0.9342465753424658
0.9809589041095892
1.0276712328767124
1.0743835616438355
1.121095890410959
1.167808219178082
1.2145205479452055
1.2612328767123286
1.307945205479452
1.3546575342465752
1.4013698630136986
1.448082191780822
1.4947945205479454
Activity icon

Replied to JavaScript For Loop

I dont need parseInt() , i want sum all values inside loop

sum of this 10000 11000 12000 13000 14000 15000 16000 17000 18000 19000 20000 21000