-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1d75202
Showing
8 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/node_modules | ||
|
||
/public/storage | ||
/storage/*.key | ||
/vendor | ||
.env | ||
|
||
.phpunit.result.cache | ||
docker-compose.override.yml | ||
Homestead.json | ||
Homestead.yaml | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
/.idea | ||
/public/build/ | ||
/package-lock.json | ||
/composer.lock |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
### HOW TO INSTALL | ||
|
||
composer require vobar/laravel-basic-site:dev-master | ||
|
||
### HOW TO PUBLISH | ||
|
||
php artisan vendor:publish --tag=[tag_name] | ||
|
||
#### available tags: | ||
|
||
- news | ||
- slider (WIP) | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\News; | ||
|
||
class NewsController | ||
{ | ||
public function index() | ||
{ | ||
$news = News::select(['name'])->get(); | ||
|
||
return response()->json([ | ||
'news' => $news, | ||
]); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class News extends Model | ||
{ | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "vobar/laravel-basic-site", | ||
"description": "Laravel package for basic site", | ||
"license": "MIT", | ||
"type": "library", | ||
"authors": [ | ||
{ | ||
"name": "Vladimir vobar Barkaev" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.1", | ||
"illuminate/database": "^9.0", | ||
"illuminate/support": "^9.0", | ||
"illuminate/console": "^9.0" | ||
}, | ||
"require-dev": { | ||
"orchestra/testbench": "^7.2", | ||
"phpunit/phpunit": "^9.5" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Vobar\\LaravelBasicSite\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Vobar\\LaravelBasicSite\\Test\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"test": [ | ||
"vendor/bin/phpunit" | ||
] | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"LaravelBasicComponentsServiceProvider" | ||
] | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
database/migrations/0000_00_00_000000_create_news_table.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateNewsTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('news', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('title'); | ||
$table->integer('active')->default(1); | ||
$table->timestamp('active_from')->nullable(); | ||
$table->timestamp('active_to')->nullable(); | ||
$table->timestamps(); | ||
$table->softDeletes(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('news'); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use app\Http\Controllers\NewsController; | ||
|
||
Route::resource('news', NewsController::class); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Vobar\LaravelBasicSite\Providers; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class LaravelBasicComponentsServiceProvider extends ServiceProvider | ||
{ | ||
public function boot() | ||
{ | ||
if ($this->app->runningInConsole()) { | ||
//php artisan vendor:publish --tag=news | ||
$this->publishes([ | ||
__DIR__ . '/../../database/migrations/0000_00_00_000000_create_news_table.php' => database_path( | ||
'/migrations/0000_00_00_000000_create_news_table.php' | ||
), | ||
__DIR__ . '/../../app/Http/Controllers/NewsController.php' => app_path('Http/Controllers/NewsController.php'), | ||
__DIR__ . '/../../app/Models/News.php' => app_path('Models/News.php'), | ||
], 'news'); | ||
|
||
$this->loadRoutesFrom(__DIR__ . '/../../routes/web.php'); | ||
} | ||
} | ||
} |