일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- Python
- 코로나
- Blade
- blockchain
- Bootstrap
- Eclipse
- 사업자계좌
- 개인사업자
- auth
- 당사자표시정정신청서
- elasticSearch
- vue
- Sentinel
- Laravel
- Java
- Tutorial
- cartalyst
- 전자소송
- javascript
- as후기
- 홈택스
- 체당금
- reactnative
- win32
- php
- 이더리움
- 코로나19
- 인민공원
- 보정명령
- 소액임금체불
- Today
- Total
목록Laravel (26)
그냥 사는 이야기
Create, Store Post 생성 App/Http/Controllers/Auth/PostController public function create(Request $request) { // if user can post i.e. user is admin or author if ($request->user()->can_post()) { return view('admin/posts/create'); } else { return redirect('/')->withErrors('You have not sufficient permissions for writing post'); } } public function store(Request $request) { $post = new Post(); $post->..
Admin PostController Admin dashboard 에서 사용할 PostController를 별도로 만든다. 기존의 PostController와 이름이 같기 때문에 Auth 디렉토리 밑으로 생성한다. php artisan make:controller Auth/PostController --resource App/Http/Controllers/Auth/PostController use App\Post; use App\User; class PostController extends Controller { public function index(Request $request) { $search = $request->get('search'); $posts = Post::where('title', '..
Bootstrap 적용 Dashboard template 의 소스를 구해서 적용해본다. View 추가 resources/views/layouts/dashboard.blade.php Toggle navigation @if (Auth::guest()) Members Login Register @else {{ Auth::user()->name }} Logout {{ csrf_field() }} @endif Overview (current) All Posts Drafts Comments Label User Profile @yield('content') resources/views/admin/index.blade.php @extends('layouts.dashboard') @section('content') Da..
Bootstrap 적용 Clean Blog theme 를 down 받는다. 그래서 모든 폴더(css, img, js, less, mail, vendor)를 public 밑으로 복사해 둔다. View 추가 resources/views/layouts/app.blade.php Toggle navigation Menu Study Home About Sample Post Contact @if (Auth::guest()) Members Login Register @else {{ Auth::user()->name }} Logout {{ csrf_field() }} @endif @yield('content') resources/views/auth/login.blade.php, register.blade.php @ext..
Post와 Comment 구현 Model App/Post class Post extends Model { protected $guarded = []; public function comments() { return $this->hasMany('App\Comment','on_post'); } public function author() { return $this->belongsTo('App\User','author_id'); } } App/Comment class Comment extends Model { protected $guarded = []; public function author() { return $this->belongsTo('App\User','from_user'); } public fun..
Setup database Auth 추가 php artisan make:auth database/migrations/CreateUsersTable $table->enum('role',['admin','author','subscriber'])->default('author'); php artisan migrate database seed 추가 database/seeds/DatabaseSeeder use App\User; class DatabaseSeeder extends Seeder { public function run() { $this->call(UsersTableSeeder::class); } } class UsersTableSeeder extends Seeder { public function ru..
Visitor 권한 우선 VisitorMiddleware를 만든다. php artisan make:middleware VisitorsMiddleware routes/web.php Route::group(['middleware' => 'visitors'], function() { Route::get('/register', 'RegistrationController@register'); Route::post('/register', 'RegistrationController@postRegister'); Route::get('/login', 'LoginController@login'); Route::post('/login', 'LoginController@postLogin'); }); visitor가 접근 할 ..
Admin Controller 추가 php artisan make:controller AdminController routes/web.php Route::get('earnings', 'AdminController@earnings'); AdminController public function earnings() { return 'Total earnings 999'; } Admin Middleware 추가 php artisan make:middleware AdminMiddleware App/Http/Middleware/AdminMiddleware.php use Sentinel; ... public function handle($request, Closure $next) { // 1. User should b..