SELECT *, (
(Salary<10000)?(Salary+500):(
(Salary>=10000 AND Salary < 20000)? (Salary + 600):(
(Salary>=20000 AND Salary < 30000)? (Salary + 700):
(Salary + 800))
))) AS NewSalary FROM employee;
使用artisian命令{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"laravelcollective/html": "5.1.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
更新了作曲家。然后添加了
app.php
composer update
然后创建我的视图页面,如: -
布局/ app.blade.php
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Routing\ControllerServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
/*
* Laravel Collective HTML
*/
Collective\Html\HtmlServiceProvider::class,
//App\Providers\AnnotationsServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Input' => Illuminate\Support\Facades\Input::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
//Two aliases for HTML Service Provider
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
],
tasks.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Laravel Quickstart - Basic</title>
</head>
<body>
<div class="container">
<nav class="navbar navbar-default">
<!-- Navebar contents -->
</nav>
</div>
<div class="container">
@yield('content')
</div>
</body>
</html>
routes.php文件 [![Route :: get(&#39; /&#39;,function(){ //返回视图(&#39; welcome&#39;); $ tasks = array(&#39; a&#39;,&#39; b&#39;,&#39; c&#39;); 返回视图(&#39;任务&#39;,[&#39; tasks&#39; =&gt; $ tasks]); });] [2] [2]
答案 0 :(得分:4)
use App\Task;
文件的顶部可能遗漏了routes.php
。
我有完全相同的问题,Class 'Task' not found
并修复了它。
确保您的task::orderBy....
也是正确的大小写。
这是我的第一条路线,例如:
use App\Task;
use Illuminate\Http\Request;
/**
* Display All Tasks
*/
Route::get('/', function () {
$tasks = Task::orderBy('created_at', 'asc')->get();
return view('tasks', [
'tasks' => $tasks
]);
});
答案 1 :(得分:1)
请确保:
use App\Task
namespace App;
(当然,如果您的模型位于 App 中)答案 2 :(得分:0)
您在 @endif
文件中缺少 tasks.blade.php
@extends('layouts.app')
@section('content')
<!-- Current Tasks -->
@if(count($tasks) > 0){{--@endif for this section--}}
<div class="panel panel-default">
<div class="panel-heading">
Current Tasks
</div>
<div class="panel-body">
<table class="table table-striped task-table">
</table>
</div>
</div>
@endif{{--Add @endif--}}
<!-- TODO: Current Tasks -->
@endsection
答案 3 :(得分:0)
问题是你试图直接访问视图,这不是Laravel的工作方式。您需要设置路由并访问该路由,返回您想要的视图。
例如,转到app/Http/routes.php
。这是您的路线文件。在其中,您可以添加以下内容:
// The "test" is the uri. Keep this in mind.
// Think of it as the appended URL.
// So, it would be something like www.example.com/test
Route::get('test', function () {
// I am returning the view here.
// Note that I am returning "tasks", not "tasks.blade.php".
return view('tasks');
});
然后,根据您的图片,您需要在此处访问此路线:http://localhost/laravel/public/test
如果您将URI更改为“任务”:
// Changing "tests" to "tasks"
Route::get('tasks', function () {
// Note that I am returning "tasks", not "tasks.blade.php"
return view('tasks');
});
然后您在http://localhost/laravel/public/tasks
访问它阅读有关路由的文档,以获取有关该主题的完整细分:http://laravel.com/docs/5.1/routing
答案 4 :(得分:0)
并且不要忘记将这个东西放在routes.php
中的代码上Route::group(['middleware' => 'web'], function () {
//your current code here
})