Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vobar committed Dec 23, 2022
0 parents commit 1d75202
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .gitignore
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
14 changes: 14 additions & 0 deletions README.md
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)


17 changes: 17 additions & 0 deletions app/Http/Controllers/NewsController.php
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,
]);
}
}
10 changes: 10 additions & 0 deletions app/Models/News.php
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
{

}
45 changes: 45 additions & 0 deletions composer.json
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 database/migrations/0000_00_00_000000_create_news_table.php
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');
}
}
6 changes: 6 additions & 0 deletions routes/web.php
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);
24 changes: 24 additions & 0 deletions src/Providers/LaravelBasicComponentsServiceProvider.php
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');
}
}
}

0 comments on commit 1d75202

Please sign in to comment.