참고주소:
https://stackoverflow.com/questions/46268211/how-to-format-laravel-blade-codes-in-visual-studio-code
'VSCODE' 카테고리의 다른 글
파일명으로 이동 찾기 command + P (0) | 2021.12.19 |
---|---|
맥에서 Visual Studio Code의 PATH를 설정하는 방법 (0) | 2021.12.19 |
vetur 설치 (0) | 2020.01.13 |
참고주소:
https://stackoverflow.com/questions/46268211/how-to-format-laravel-blade-codes-in-visual-studio-code
파일명으로 이동 찾기 command + P (0) | 2021.12.19 |
---|---|
맥에서 Visual Studio Code의 PATH를 설정하는 방법 (0) | 2021.12.19 |
vetur 설치 (0) | 2020.01.13 |
1 | composer require maatwebsite/excel | cs |
구성 공개
1 | php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" | cs |
1. export명령어로 파일을 생성 (파일은 app/Exports/BoardSearchExport 생성됨)
1 | php artisan make:export BoardSearchExport --model=BoardSearchExport | cs |
2. 받을 인자와 쿼리문을 작성해준다.
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 | <?php namespace App\Exports; use App\Product; use Maatwebsite\Excel\Concerns\FromQuery; use Maatwebsite\Excel\Concerns\Exportable; class BoardsearchExport implements FromQuery { /** * @return \Illuminate\Support\Collection */ use Exportable; public function __construct(int $year, string $board_name_search) { //dd($year,$boardname); $this->year = $year; $this->boardname = $board_name_search; } public function query() { return Product::query()->whereYear('created_at', $this->year)->where('board_name', $this->boardname); } } | cs |
3. SpcsController.php
1 2 3 4 5 6 7 8 9 | namespace App\Http\Controllers; use App\Exports\BoardsearchExport; use App\Exports\BoardsearchExportView; use Illuminate\Http\Request; use App\Product; use App\Project; use App\Works; use Maatwebsite\Excel\Facades\Excel; | cs |
1 2 3 4 | public function export($board_name_search) { return Excel::download(new BoardsearchExport(2020,$board_name_search), 'qwer.xlsx'); } | cs |
4. web.php
1 2 | #excel export Route::get('/bobo/{board_name_search?}','SpcsController@export')->middleware('lv2')->name('bobo'); // | cs |
5. 해당 블레이드파일에 버튼을 삽입한다.
1 2 3 | <div class="column"> <div > <a href="/bobo/{{ $board_name_search }}" class="ui teal button">엑셀파일 다운로드</a></div> </div> | cs |
테이블 파일 인크루드
1 | @include('main.table', $products) | cs |
table.blaed.php
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | <table class="ui twelve column celled table"> <thead> <tr> <th>ID</th> <th>시리얼번호</th> <th>보드명</th> <th>생산일</th> <th>출하일</th> <th>출하내역</th> <th>불량</th> <th>불량내용</th> <th>타입</th> <th>인수자</th> <th>인계자</th> <th>메모</th> </tr> </thead> <tbody> @foreach($products as $product) <tr> <td>{{ $product->id }}</td> <td> <form action="/serialNameSearch" method="GET"> <input type="hidden" name="serial_name" value="{{ $product->serial_name }}" > <button style=" background:none;border:none; margin:0px;cursor: pointer;">{{ $product->serial_name }}</button> </form> </td> <td> <form action="/pbas/" method="GET"> <input type="hidden" name="board_name" value="{{ $product->board_name }}" > <button style=" background:none;border:none; margin:0px;cursor: pointer;">{{ $product->board_name }}</button> </form> </td> <td>{{ $product->product_date }}</td> <td>{{ $product->shipment }}</td> <td>{{ $product->shipment_daily }}</td> <td>{{ $product->faulty }}</td> <td>{{ $product->remarks }}</td> <td>{{ $product->type }}</td> <td>{{ $product->receiver }}</td> <td>{{ $product->ship_user }}</td> <td>{{ $product->note }}</td> </tr> @endforeach </tbody> </table> | cs |
6. 브라우저에서 해당버튼을 누르면 엑셀파일이 다운로드 받아진다.
역순으로 나왔지만 잘 추출된다.
라라벨 마크다운 문서작성 라이브러리 (0) | 2020.12.26 |
---|---|
디버그바 설치 (0) | 2020.03.04 |
laravel log-viewer 설치 (0) | 2019.08.31 |
laravel sweet-alert 설치 경고창 설정 (0) | 2019.08.30 |
라라벨 회원계정 사진올리기 (0) | 2019.07.13 |
php artisan tinker
$q= App\Question::first()
작성날짜확인
$q->created_at
작성날짜부터 현재까지의 시간
$q->created_at->diffForHumans();
일,월,년 으로 표현
$q->created_at->format("d/m/Y");
format에러날 경우 (0) | 2020.03.11 |
---|---|
전역변수 날짜, 시간설정하기 (0) | 2019.08.31 |
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 3780 Referencing column 'user_id' and referenced column 'id' in foreign key constraint 'questions_user_id_foreign' are incompatible. (SQL: alter table `questions` add constraint `questions_user_id_foreign` foreign key (`user_id`) references `users` (`id`) on delete cascade on update cascade)
at /Users/wonhochoi/laravel-qa/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {
> 669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|
Exception trace:
1 PDOException::("SQLSTATE[HY000]: General error: 3780 Referencing column 'user_id' and referenced column 'id' in foreign key constraint 'questions_user_id_foreign' are incompatible.")
/Users/wonhochoi/laravel-qa/vendor/laravel/framework/src/Illuminate/Database/Connection.php:463
2 PDOStatement::execute()
/Users/wonhochoi/laravel-qa/vendor/laravel/framework/src/Illuminate/Database/Connection.php:463
Please use the argument -v to see more details.
1 | $table->unsignedInteger('user_id'); | cs |
수정
1 | $table->unsignedBigInteger('user_id'); | cs |
다시 마이그레이션 실행한다.
unsignedInteger(음수를 사용지않음) (0) | 2020.03.29 |
---|---|
마이그레이션 에러 (0) | 2020.01.18 |
컬럼삭제하기 (0) | 2020.01.01 |
app\Proderviders\AppServerProvider.php
1 | use Illuminate\Support\facades\Schema; | cs |
1 | Schema::defaultStringLength(191); | cs |
1 | php artisan migrate:fresh | cs |
unsignedInteger(음수를 사용지않음) (0) | 2020.03.29 |
---|---|
마이그레이션에러 SQLSTATE[HY000]: General error: 3780 (0) | 2020.01.18 |
컬럼삭제하기 (0) | 2020.01.01 |
ContactsTest.php
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | <?php namespace Tests\Feature; use App\Contact; use Tests\TestCase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Foundation\Testing\RefreshDatabase; class ContactsTest extends TestCase { use RefreshDatabase; /** @test */ public function a_contact_can_be_added() { //예외처리 핸들링 $this->withoutExceptionHandling(); //이름을 전달하는 테스트 코드 $this->post('/api/contacts', $this->data()); //데이터베이스의 첫번째 것 가져오기 $contact = Contact::first(); $this->assertEquals('Test Name', $contact->name); $this->assertEquals('test@email.com', $contact->email); $this->assertEquals('05/14/1988', $contact->birthday); $this->assertEquals('ABC String', $contact->company); } /** @test */ public function fields_are_required() { collect(['name', 'email', 'birthday', 'company']) ->each(function($field){ //이름을 전달하는 테스트 코드 $response = $this->post('/api/contacts', array_merge($this->data(),[$field => ''])); $response->assertSessionHasErrors($field); $this->assertCount(0, Contact::all()); }); } private function data() { return[ 'name' => 'Test Name', 'email' => 'test@email.com', 'birthday' => '05/14/1988', 'company' => 'ABC String', ]; } } | cs |
ContactsController.php
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 | <?php namespace App\Http\Controllers; use App\Contact; use Illuminate\Http\Request; class ContactsController extends Controller { public function store() { $data = request()->validate([ 'name' => 'required', 'email' => 'required', 'birthday' => 'required', 'company' => 'required', ]); Contact::create($data); } } | cs |
10. tailwindcss설치 (2) | 2020.01.15 |
---|
노드모듈설치
npm install
테일윈드 설치
npm install tailwindcss
resources/sass/app.scss 아래소스
@tailwind base;
@tailwind components;
@tailwind utilities;
Tailwind 구성 파일 생성
npx tailwind init
웹팩
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.options({
processCssUrls: false,
postCss: [ tailwindcss('./tailwind.config.js') ],
})
justify-content-center
05. 테스트 정리 및 리펙토링 (1) | 2020.01.16 |
---|
정의되지 않은 페이지는 404페이지를 사용자 정의하는 방법이다.
1. resources/js/components/Notfound.vue 파일을 만들어준다.
2. resources/js/routes.js
1 | import Notfound from './components/Notfound'; | cs |
1 2 3 4 5 6 | { path: '*', component: Notfound }, | cs |
전체
정의되지 않은 패스는 /components/Notfound 로 가게 설정하는 것이다.
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 32 33 34 35 36 37 38 39 40 41 42 | import Logo from './components/Logo'; import LogoSymbol from './components/LogoSymbol'; import Colors from './components/Colors'; import Notfound from './components/Notfound'; export default{ mode : 'history', linkActiveClass: 'font-bold text-blue-500', routes:[ { path: '*', component: Notfound }, { path: '/', component: Logo }, { path: '/logo-symbol', component: LogoSymbol }, { path: '/colors', component: Colors }, ] }; | cs |
3.routes/web.php 파일
1 2 3 4 | Route::get('/{any?}', function () { return view('app'); })->where('any','.*'); | cs |
02) 레이아웃 tailwindcss (0) | 2020.01.13 |
---|---|
01)라라벨에 뷰 라우터 설치하기 (0) | 2020.01.13 |
laravel+vue+tailwindcss (0) | 2019.08.24 |
laravel vue axjos (0) | 2019.08.05 |
라라벨 뷰 적용하기 (0) | 2019.08.03 |