Skip to content

Commit 76ea5eb

Browse files
committed
configure
1 parent 8c2ab9a commit 76ea5eb

14 files changed

+128
-150
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Changelog
22

3-
All notable changes to `vendor/package` will be documented in this file.
3+
All notable changes to `laravelir/attachmentable` will be documented in this file.
44

README-en.md

-24
This file was deleted.

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
- [![Starts](https://img.shields.io/github/stars/miladimos/laravel-?style=flat&logo=github)](https://github.com/miladimos/laravel-/forks)
2-
- [![Forks](https://img.shields.io/github/forks/miladimos/laravel-?style=flat&logo=github)](https://github.com/miladimos/laravel-/stargazers)
1+
- [![Starts](https://img.shields.io/github/stars/laravelir/attachmentable?style=flat&logo=github)](https://github.com/laravelir/attachmentable/forks)
2+
- [![Forks](https://img.shields.io/github/forks/laravelir/attachmentable?style=flat&logo=github)](https://github.com/laravelir/attachmentable/stargazers)
33

4+
# Laravel attachmentable package
45

5-
- [English](README-en.md)
6+
A package for attachment files to models
67

7-
# پکیج لاراولی
8-
یه پکیج خفن
8+
## Installation
99

10+
1. Run the command below to add this package:
1011

11-
### نصب
12-
13-
1. برای نصب در مسیر روت پروژه خود دستور زیر را در ریشه پروژه اجرا کنید
1412
```
15-
composer require miladimos/laravel-
13+
composer require laravelir/attachmentable
1614
```
1715

18-
2. Open your config/app.php and add the following to the providers array:
16+
2. Open your config/attachmentable.php and add the following to the providers array:
17+
1918
```php
20-
Miladimos\Package\Providers\PackageServiceProvider::class,
19+
Laravelir\Attachmentable\Providers\AttachmentableServiceProvider::class,
2120
```
2221

23-
3. Run the command below to publish the package config file config/package.php:
22+
3. Run the command below to publish the package config file config/attachmentable.php:
23+
2424
```
2525
php artisan vendor:publish
2626
```

composer.json

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
2-
"name": "miladimos/package-skeleton",
2+
"name": "laravelir/attachmentable",
33
"description": "test description",
4-
"homepage": "https://github.com/miladimos/package-skeleton",
4+
"homepage": "https://github.com/laravelir/attachmentable",
55
"type": "library",
66
"keywords": [
77
"laravel",
88
"laravel-package",
99
"laravel support",
1010
"lumen packages",
1111
"laravel packages",
12-
"lumen support"
12+
"lumen support",
13+
"attachmentable",
14+
"laravel-attachmentable"
1315
],
1416
"authors": [
1517
{
@@ -21,26 +23,26 @@
2123
],
2224
"autoload": {
2325
"psr-4": {
24-
"Miladimos\\Package\\": "src/"
26+
"Laravelir\\Attachmentable\\": "src/"
2527
}
2628
},
2729
"autoload-dev": {
2830
"psr-4": {
29-
"Miladimos\\Package\\Tests\\": "tests"
31+
"Laravelir\\Attachmentable\\Tests\\": "tests"
3032
}
3133
},
3234
"extra": {
3335
"laravel": {
3436
"providers": [
35-
"PackageServiceProvider"
37+
"AttachmentableServiceProvider"
3638
],
3739
"aliases": {
38-
"Package": "Miladimos\\Package\\Facades\\PackageFacade"
40+
"Attachmentable": "Laravelir\\Attachmentable\\Facades\\AttachmentableFacade"
3941
}
4042
}
4143
},
4244
"require": {
43-
"php": ">=7.2"
45+
"php": ">=7.4"
4446
},
4547
"require-dev": {
4648
"phpunit/phpunit": "^9.4"

config/attachmentable.php

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
// config file for laravelir/attachmentable
4+
return [
5+
//
6+
];

config/config.php

-6
This file was deleted.

database/create_tables_table.php.stub renamed to database/create_attachmentables_table.php.stub

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreateTablesTable extends Migration
7+
class CreateAttachmentablesTable extends Migration
88
{
99
/**
1010
* Run the migrations.
@@ -13,11 +13,11 @@ class CreateTablesTable extends Migration
1313
*/
1414
public function up()
1515
{
16-
Schema::create('tables', function (Blueprint $table) {
16+
Schema::create('attachmentables', function (Blueprint $table) {
1717
$table->id();
18-
19-
$table->string('title');
20-
18+
$table->uuid('uuid');
19+
$table->morphs('attachmentable');
20+
$table->string('path');
2121
$table->timestamps();
2222
});
2323
}
@@ -29,6 +29,6 @@ class CreateTablesTable extends Migration
2929
*/
3030
public function down()
3131
{
32-
Schema::dropIfExists('tables');
32+
Schema::dropIfExists('attachmentables');
3333
}
3434
}

src/Console/Commands/InstallPackageCommand.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<?php
22

3-
namespace Miladimos\Package\Console\Commands;
3+
namespace Laravelir\Attachmentable\Console\Commands;
44

55
use Illuminate\Console\Command;
66

7-
class InstallPackageCommand extends Command
7+
class InstallAttachmentableCommand extends Command
88
{
9-
protected $signature = 'package:install';
9+
protected $signature = 'attachmentable:install';
1010

11-
protected $description = 'Install the package Package';
11+
protected $description = 'Install the attachmentable package';
1212

1313
public function handle()
1414
{
15-
$this->line("\t... Welcome To Package Installer ...");
15+
$this->line("\t... Welcome To Attachmentable Installer ...");
1616

1717

18-
$this->info("Package Successfully Installed.\n");
18+
$this->info("Attachmentable Successfully Installed.\n");
1919
$this->info("\t\tGood Luck.");
2020
}
2121

2222
// //config
23-
// if (File::exists(config_path('package.php'))) {
24-
// $confirm = $this->confirm("package.php already exist. Do you want to overwrite?");
23+
// if (File::exists(config_path('attachmentable.php'))) {
24+
// $confirm = $this->confirm("attachmentable.php already exist. Do you want to overwrite?");
2525
// if ($confirm) {
2626
// $this->publishConfig();
2727
// $this->info("config overwrite finished");
@@ -34,8 +34,8 @@ public function handle()
3434
// }
3535

3636
// //assets
37-
// if (File::exists(public_path('package'))) {
38-
// $confirm = $this->confirm("package directory already exist. Do you want to overwrite?");
37+
// if (File::exists(public_path('attachmentable'))) {
38+
// $confirm = $this->confirm("attachmentable directory already exist. Do you want to overwrite?");
3939
// if ($confirm) {
4040
// $this->publishAssets();
4141
// $this->info("assets overwrite finished");
@@ -67,7 +67,7 @@ public function handle()
6767
// private function publishConfig()
6868
// {
6969
// $this->call('vendor:publish', [
70-
// '--provider' => "Miladimos\package\Providers\packageServiceProvider",
70+
// '--provider' => "Laravelir\Attachmentable\Providers\AttachmentableServiceProvider",
7171
// '--tag' => 'config',
7272
// '--force' => true
7373
// ]);
@@ -76,7 +76,7 @@ public function handle()
7676
// private function publishMigration()
7777
// {
7878
// $this->call('vendor:publish', [
79-
// '--provider' => "Miladimos\package\Providers\packageServiceProvider",
79+
// '--provider' => "Laravelir\Attachmentable\Providers\AttachmentableServiceProvider",
8080
// '--tag' => 'migrations',
8181
// '--force' => true
8282
// ]);
@@ -85,7 +85,7 @@ public function handle()
8585
// private function publishAssets()
8686
// {
8787
// $this->call('vendor:publish', [
88-
// '--provider' => "Miladimos\package\Providers\packageServiceProvider",
88+
// '--provider' => "Laravelir\Attachmentable\Providers\AttachmentableServiceProvider",
8989
// '--tag' => 'assets',
9090
// '--force' => true
9191
// ]);

src/Facades/AttachmentableFacade.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Laravelir\Attachmentable\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class AttachmentableFacade extends Facade
8+
{
9+
protected static function getFacadeAccessor()
10+
{
11+
return 'attachmentable'; // TODO: Change the accessor name
12+
}
13+
}

src/Facades/PackageFacade.php

-13
This file was deleted.

src/Models/PackageModel.php renamed to src/Models/Attachment.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
22

3-
namespace Miladimos\Package\Models;
3+
namespace Laravelir\Attachmentable\Models;
44

55
use Illuminate\Database\Eloquent\Model;
66

7-
class PackageModel extends Model
7+
class Attachment extends Model
88
{
99
/**
1010
* The table associated with the model.
1111
*
1212
* @var string
1313
*/
14-
protected $table = 'tables';
14+
protected $table = 'attachmentables';
1515

1616
// protected $fillable = ['name'];
1717

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace Laravelir\Attachmentable\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use Laravelir\Attachmentable\Console\Commands\InstallAttachmentableCommand;
7+
use Laravelir\Attachmentable\Facades\AttachmentableFacade;
8+
9+
class AttachmentableServiceProvider extends ServiceProvider
10+
{
11+
12+
public function register()
13+
{
14+
$this->mergeConfigFrom(__DIR__ . "/../../config/attachmentable.php", 'attachmentable');
15+
16+
$this->registerFacades();
17+
}
18+
19+
/**
20+
* Bootstrap services.
21+
*
22+
* @return void
23+
*/
24+
public function boot()
25+
{
26+
27+
if ($this->app->runningInConsole()) {
28+
$this->registerCommands();
29+
$this->registerPublishes();
30+
$this->publishConfig();
31+
}
32+
}
33+
34+
private function registerFacades()
35+
{
36+
$this->app->bind('attachmentable', function ($app) {
37+
return new AttachmentableFacade();
38+
});
39+
}
40+
41+
private function registerPublishes()
42+
{
43+
$this->publishes([
44+
__DIR__ . '/../../config/attachmentable.php' => config_path('attachmentable.php')
45+
], 'attachmentable-config');
46+
}
47+
48+
private function registerCommands()
49+
{
50+
$this->commands([
51+
InstallAttachmentableCommand::class,
52+
]);
53+
}
54+
55+
public function publishConfig()
56+
{
57+
$this->publishes([
58+
__DIR__ . '/../../config/attachmentable.php' => config_path('attachmentable.php')
59+
], 'attachmentable-config');
60+
}
61+
}

0 commit comments

Comments
 (0)