javascript code for make slugs

replace all non-alphanumerical characters with dashes

<script>
  $("#inputSlug").keyup(function() {
  var Text = $(this).val();
  Text = Text.toLowerCase();
  Text = Text.replace(/[^a-zA-Z0-9]+/g,'-');
  $("#inputSlug").val(Text);        
});
</script>

add soft delete in laravel

In the migration file add:

$table->softDeletes();

In the model:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;


class CalNotes extends Model
{
    use HasFactory;
    protected $table = 'cal_notes';
    protected $fillable = ['user_id','title','description','price','ip'];
    protected $primaryKey = 'id';
    use SoftDeletes;

}

In the controller:

 $id = $request->id;
 $calNotesModel  = new CalNotes();
 $calNotes = $calNotesModel->find($id);
 $calNotes->delete();

 if you need to restore the deleted user

$calNotes = CalNotes::withTrashed()->find($id);
        $calNotes->restore();

trim left characters in php

The ltrim() function removes whitespace or other predefined characters from the left side of a string. Related functions: rtrim() – Removes whitespace or other predefined characters from the right side of a string. trim() – Removes whitespace or other predefined characters from both sides of a string.

Return Value: Returns the modified string

Changelog: The charlist parameter was added …

PHP Version: 4+

AH00126: Invalid URI in request GET

There’s two issues here that are likely contributing to your troubles. First, you can’t check for file existence so easily in a server context (as you are with httpd.conf), because the request hasn’t been mapped to the file system yet.

If your requests for static resources happen to correspond directly to your file system structure beyond your DOCUMENT_ROOT, you can solve this by appending the value of DOCUMENT_ROOT before the incoming REQUEST_URI, as follows:

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d

If the path to your static resources is transformed somewhere down the line, the mod_rewrite documentation suggests using the following, which will issue a subrequest to perform a lookahead based on the request URI:

RewriteCond %{LA-U:REQUEST_FILENAME} !-f
RewriteCond %{LA-U:REQUEST_FILENAME} !-d

This approach is more expensive though, so try to use the first one where at all possible.

Secondly, the URI that you pass back into the request is actually invalid, because it needs the leading slash. Correcting that and combining it with the new conditions above gives you this modified rule set:

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^.*$ /index.php?page=$0 [PT,QSA,L]

Note that the value of page here will always have a leading slash, so you might actually want to use this rule instead, depending on your handling logic in index.php:

RewriteRule ^/(.*)$ /index.php?page=$1 [PT,QSA,L]

ignore time in datetime mysql in select in laravel 8

They do the SQL DATE() work for you, and manage the differences of SQLite.

Your result can be achieved as so:

->whereDate('date', '<=', '2014-07-10')

Though the above method is convenient, as noted by Arth it is inefficient on large datasets, because the DATE() SQL function has to be applied on each record, thus discarding the possible index.

Here are some ways to make the comparison (but please read notes below):

->where('date', '<=', '2014-07-10 23:59:59')

->where('date', '<', '2014-07-11')

// '2014-07-11'
$dayAfter = (new DateTime('2014-07-10'))->modify('+1 day')->format('Y-m-d');

->where('date', '<', $dayAfter)
->whereDate('date','=','2014-07-10')

->whereDate('date', '<=', '2014-07-10')