laravel项目3myPersimmon学习(使用了什么插件,视图,编辑器,migrate,seeder)1urlencode,sha1_file
Posted 克维拉
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了laravel项目3myPersimmon学习(使用了什么插件,视图,编辑器,migrate,seeder)1urlencode,sha1_file相关的知识,希望对你有一定的参考价值。
3mypersimmino
使用了什么插件
1use GuzzleHttp\Client;
$client = new Client();
$response = $client->request(‘GET‘, $originUrl);
获取状态码if ($response->getStatusCode() != 200) {
获取请求的值$jsonBody = $response->getBody(); $body = json_decode($jsonBody, true);
2
zgldh\QiniuStorage; Qinu资源(云)存储SDK Laravel 5
3
"naux/auto-correct": "^1.0",自动给中英文之间加入合理的空格并纠正专用名词大小写//https://packagist.org/packages/naux/auto-correct
// 加入空格并纠正词汇(auto_space + auto_correct)
$correct->convert("php是世界上最好的语言,之一"); // PHP 是世界上最好的语言,之一
4
"erusev/parsedown": "^1.6", //Parser for Markdown.
$Parsedown = new Parsedown();
echo $Parsedown->text(‘Hello _Parsedown_!‘); # prints: <p>Hello <em>Parsedown</em>!</p>
$posts->content = (new \Parsedown())->text($request->markdown);
$posts->markdown = $request->markdown;
5league/html-to-markdown//An HTML-to-markdown conversion helper for PHP
6
barryvdh/laravel-debugbar //laravel 的debug工具
7
Laravel 5的52种语言的列表
与通常的用法没有区别。
如果您需要添加其他语言内容,请在resources/lang/{LANGUAGE} 目录中创建一个文件。
添加自定义语言项目
这里以中文为例:
resources/lang/zh-CN/demo.php:
<?PHP
return [
‘ user_not_exists ‘ => ‘用户不存在‘,‘ email_has_registed ‘ => ‘邮箱:email已经注册过!‘,];
在模板中使用:
echo trans(‘ demo.user_not_exists ‘); //用户不存在
echo trans(‘ demo.email_has_registed ‘,[ ‘ email ‘ => ‘ [email protected] ‘ ]);
//邮箱[email protected]已经注册过!
8
predis / predis//用于PHP和HHVM的灵活且功能完备的Redis客户端
9
suin / php-rss-writer
另一个PHP 5.4或更高版本的简单RSS编写器库。
10tom-lingham / searchy //搜索用的
Laravel Searchy通过模糊搜索,基本字符串匹配,Levenshtein距离等等,使得用户驱动的搜索更容易。
4视图
<link rel="stylesheet" href="{{ mix(‘backend/css/app.css‘) }}">
<script src="{{ mix(‘backend/js/app.js‘) }}"></script>
<script>window.Laravel = {‘csrfToken‘ : ‘{{csrf_token()}}‘,‘apiUrl‘:‘{{ route(‘admin‘) }}‘};</script>不懂
<img src="{{ asset(‘backend/images/fly.gif‘) }}" class="pit-loading-img" >
///////
@extends(‘app.layouts.base‘)
@section(‘head‘)
@endsection
@section(‘nav‘)
@endsection
@section(‘content‘)
{!! $users->links() !!}
编辑器
? 好用的 Simplemde Markdown 编辑器
https://segmentfault.com/a/1190000009469890
migrate
$table->string(‘title‘)->nullable();
$table->integer(‘category_id‘)->default(‘0‘);
$table->integer(‘comments‘)->default(‘0‘)->nullable();//defautl,nullable
$table->string(‘name‘)->default(‘‘)->nullable();
$table->string(‘ipaddress‘)->default(‘0.0.0.0‘)->nullable();
$table->softDeletes(); //软删除
enum
$table->enum(‘option_status‘, [‘base‘,‘extends‘,‘hidden‘])->default(‘extends‘);
$table->enum(‘data_type‘, [‘textarea‘,‘text‘])->default(‘text‘);
外键
public function up()
{
Schema::create(‘tags‘, function (Blueprint $table) {
$table->increments(‘id‘);
$table->string(‘tags_name‘)->nullable();
$table->string(‘tags_flag‘)->nullable();
$table->timestamps();
});
Schema::create(‘posts_tags‘, function(Blueprint $table){
$table->integer(‘posts_id‘)->unsigned()->index();
$table->foreign(‘posts_id‘)->references(‘id‘)->on(‘posts‘)->onDelete(‘cascade‘);
$table->integer(‘tags_id‘)->unsigned()->index();
$table->foreign(‘tags_id‘)->references(‘id‘)->on(‘tags‘)->onDelete(‘cascade‘);
$table->timestamps();
});
}
DatabaseSeeder
1
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->call(UsersTableSeeder::class);
$this->call(OptionsTableSeeder::class);
$this->call(PostsTableSeeder::class);
$this->call(TagsTableSeeder::class);
$this->call(PostsTagsTableSeeder::class);
$this->call(CategorysTableSeeder::class);
$this->call(NavicationsTableSeeder::class);
}
}
2CategorysTableSeeder.php
<?php
use Illuminate\Database\Seeder;
class CategorysTableSeeder extends Seeder
{
/**
* Auto generated seed file
*
* @return void
*/
public function run()
{
\DB::table(‘categorys‘)->delete();
\DB::table(‘categorys‘)->insert(array (
0 =>
array (
‘id‘ => 1,
‘category_name‘ => ‘PHP‘,
‘category_parent‘ => 0,
‘category_flag‘ => ‘php‘,
‘category_description‘ => ‘‘,
‘ipaddress‘ => ‘127.0.0.1‘,
‘created_at‘ => ‘2017-03-31 03:26:06‘,
‘updated_at‘ => ‘2017-03-31 03:26:06‘,
),
1 =>
array (
‘id‘ => 2,
‘category_name‘ => ‘Laravel‘,
‘category_parent‘ => 0,
‘category_flag‘ => ‘laravel‘,
‘category_description‘ => ‘‘,
‘ipaddress‘ => ‘127.0.0.1‘,
‘created_at‘ => ‘2017-03-31 03:26:15‘,
‘updated_at‘ => ‘2017-03-31 03:26:15‘,
),
2 =>
array (
‘id‘ => 3,
‘category_name‘ => ‘Linux‘,
‘category_parent‘ => 0,
‘category_flag‘ => ‘linux‘,
‘category_description‘ => ‘‘,
‘ipaddress‘ => ‘127.0.0.1‘,
‘created_at‘ => ‘2017-03-31 03:26:23‘,
‘updated_at‘ => ‘2017-03-31 03:26:23‘,
),
3 =>
array (
‘id‘ => 4,
‘category_name‘ => ‘MySQL‘,
‘category_parent‘ => 0,
‘category_flag‘ => ‘database‘,
‘category_description‘ => ‘‘,
‘ipaddress‘ => ‘127.0.0.1‘,
‘created_at‘ => ‘2017-03-31 03:26:33‘,
‘updated_at‘ => ‘2017-03-31 03:26:33‘,
),
));
}
}
3UsersTableSeeder.php
<?php
use Illuminate\Database\Seeder;
class UsersTableSeeder extends Seeder
{
/**
* Auto generated seed file
*
* @return void
*/
public function run()
{
\DB::table(‘users‘)->delete();
\DB::table(‘users‘)->insert(array (
0 =>
array (
‘id‘ => 1,
‘name‘ => ‘MrCong‘,
‘email‘ => ‘[email protected]‘,
‘password‘ => ‘$2y$10$oC0ilorUCl8dt78wqp8tteBDOw2RnC/dNbm4Mc91rWkQOgW573vtO‘,
‘avatar‘ => ‘https://o75u5ooep.qnssl.com/avatar_2017-03-18‘,
‘remember_token‘ => ‘tDpcjqLYBeWU11ULTVcmsIFaaSiqdvVh8zDeNbFZ29lhqQNUR3Ki0QtEzCNd‘,
‘created_at‘ => ‘2017-02-04 08:04:57‘,
‘updated_at‘ => ‘2017-03-18 08:48:00‘,
),
));
}
}
函数
1urlencode
$url = sprintf($this->apiUrl, urlencode($words), $from, $to, $ak, $salt, $sign);
2
private function fileExists($file)
{
$realPath = is_string($file) ? $file : $file->getRealPath();
$hash1 = sha1_file($realPath);
$data = Attachments::where(‘hash1‘, $hash1)->first();
return $data;
}
以上是关于laravel项目3myPersimmon学习(使用了什么插件,视图,编辑器,migrate,seeder)1urlencode,sha1_file的主要内容,如果未能解决你的问题,请参考以下文章