This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $posts = Post::filter($filters)->get(); | |
| $groupBy = $filters['groupBy'] ?? 'week'; | |
| $posts->groupBy(function ($post) use ($groupBy) { | |
| return match ($groupBy) { | |
| 'day' => $post->published_at->format('D d M Y'), | |
| // 📅 Group by day, format 'Day Date Month Year' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| public function up(): void | |
| { | |
| // Method 1: Adding 'team_id' Foreign Key to Different Tables One by One | |
| Schema::table('users', function (Blueprint $table) { | |
| $table->foreignIdFor(Team::class)->nullable(); | |
| }); | |
| Schema::table('posts', function (Blueprint $table) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // In the Post model | |
| class Post extends Model | |
| { | |
| public function user() | |
| { | |
| return $this->belongsTo(User::class); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Http\Livewire; | |
| use Livewire\Component; | |
| use Livewire\Attributes\Renderless; | |
| use App\Traits\HasFilteredReports; | |
| class Reports extends Component | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // 🎉 Birthday Check Function 🚀 | |
| use Carbon\Carbon; | |
| function checkBirthday($birthday) | |
| { | |
| return Carbon::now()->isSameDay($birthday) | |
| ? "🎉🥳 Happy Birthday! 🎂 Best wishes for an amazing year ahead! 🚀" | |
| : "🎈 No birthday today. Make it an awesome day anyway! 🌟"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Livewire; | |
| use App\Models\Post; | |
| use Livewire\Component; | |
| class PostList extends Component | |
| { | |
| public $offset = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // PHP 8.3 introduces exciting new functions for | |
| // incrementing and decrementing alphanumeric strings! | |
| // Let's dive into some examples to see how they work. | |
| // str_increment — Increment an alphanumeric string | |
| echo str_increment("a") . PHP_EOL; // b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Listeners; | |
| use Illuminate\Events\Dispatcher; | |
| use Illuminate\Foundation\Http\Events\RequestHandled; | |
| use Illuminate\Console\Events\CommandFinished; | |
| use Illuminate\Http\Client\Events\ResponseReceived; | |
| use Illuminate\Support\Facades\Log; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function exportCSV() | |
| { | |
| header('Content-type: text/csv'); | |
| header('Content-Disposition: attachment; filename=products.csv'); | |
| header('Pragma: no-cache'); | |
| header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); | |
| header('Expires: 0'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use App\Models\Team; | |
| use App\Models\User; | |
| use Database\Seeders\RoleAndPermissionSeeder; | |
| use Database\Seeders\TeamSeeder; | |
| use Database\Seeders\UserSeeder; | |
| use function Pest\Laravel\actingAs; | |
| use function Pest\Laravel\get; |
OlderNewer