Skip to content

Commit

Permalink
Publish laravel stub
Browse files Browse the repository at this point in the history
  • Loading branch information
mckenziearts committed Oct 3, 2023
1 parent 724ce17 commit a24564b
Show file tree
Hide file tree
Showing 27 changed files with 667 additions and 0 deletions.
31 changes: 31 additions & 0 deletions stubs/cast.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

final class {{ class }} implements CastsAttributes
{
/**
* Cast the given value.
*
* @param array<string, mixed> $attributes
*/
public function get(Model $model, string $key, mixed $value, array $attributes): mixed
{
return $value;
}

/**
* Prepare the given value for storage.
*
* @param array<string, mixed> $attributes
*/
public function set(Model $model, string $key, mixed $value, array $attributes): mixed
{
return $value;
}
}
19 changes: 19 additions & 0 deletions stubs/console.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Illuminate\Console\Command;

final class {{ class }} extends Command
{
protected $signature = '{{ command }}';

protected $description = 'Command description';

public function handle()
{
//
}
}
15 changes: 15 additions & 0 deletions stubs/controller.invokable.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Illuminate\Http\Request;

final class {{ class }}
{
public function __invoke(Request $request)
{
//
}
}
13 changes: 13 additions & 0 deletions stubs/controller.plain.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use {{ rootNamespace }}Http\Controllers\Controller;
use Illuminate\Http\Request;

final class {{ class }} extends Controller
{
//
}
35 changes: 35 additions & 0 deletions stubs/event.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

final class {{ class }}
{
use Dispatchable, InteractsWithSockets, SerializesModels;

public function __construct()
{
//
}

/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('channel-name'),
];
}
}
19 changes: 19 additions & 0 deletions stubs/factory.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace {{ factoryNamespace }};

use Illuminate\Database\Eloquent\Factories\Factory;

final class {{ factory }}Factory extends Factory
{
protected $model = {{ namespacedModel }}::class;

public function definition(): array
{
return [
//
];
}
}
27 changes: 27 additions & 0 deletions stubs/job.queued.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

final class {{ class }} implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

public function __construct()
{
//
}

public function handle(): void
{
//
}
}
41 changes: 41 additions & 0 deletions stubs/mail.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

final class {{ class }} extends Mailable
{
use Queueable, SerializesModels;

public function __construct()
{
//
}

public function envelope(): Envelope
{
return new Envelope(
subject: '{{ subject }}',
);
}

public function content(): Content
{
return new Content(
view: 'view.name',
);
}

public function attachments(): array
{
return [];
}
}
41 changes: 41 additions & 0 deletions stubs/markdown-mail.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

final class {{ class }} extends Mailable
{
use Queueable, SerializesModels;

public function __construct()
{
//
}

public function envelope(): Envelope
{
return new Envelope(
subject: '{{ subject }}',
);
}

public function content(): Content
{
return new Content(
markdown: '{{ view }}',
);
}

public function attachments(): array
{
return [];
}
}
50 changes: 50 additions & 0 deletions stubs/markdown-notification.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

final class {{ class }} extends Notification
{
use Queueable;

public function __construct()
{
//
}

/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}

/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)->markdown('{{ view }}');
}

/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}
17 changes: 17 additions & 0 deletions stubs/middleware.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace {{ namespace }};

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

final class {{ class }}
{
public function handle(Request $request, Closure $next): Response
{
return $next($request);
}
}
26 changes: 26 additions & 0 deletions stubs/migration.create.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration
{
public function up(): void
{
Schema::create('{{ table }}', static function (Blueprint $table): void {
$table->id();

//

$table->timestamps();
});
}

public function down(): void
{
Schema::dropIfExists('{{ table }}');
}
};
20 changes: 20 additions & 0 deletions stubs/migration.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration
{
public function up(): void
{
//
}

public function down(): void
{
//
}
};
24 changes: 24 additions & 0 deletions stubs/migration.update.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration
{
public function up(): void
{
Schema::table('{{ table }}', static function (Blueprint $table): void {
//
});
}

public function down(): void
{
Schema::table('{{ table }}', function (Blueprint $table) {
//
});
}
};
Loading

0 comments on commit a24564b

Please sign in to comment.