Learning LaravelChecking for Existence 21 Raw echos 21 Including Partial Views 21 Layout Inheritance 22 Sharing data to all views 24 Using View::share 24 Using View::composer 24 Closure-based composer 24 Class-based Contains to check if a collection satisfies certain condition 32 Using Pluck to extract certain values from a collection 32 Using Map to manipulate each element in a collection 33 Using sum, avg, min min or max on a collection for statistical calculations 33 Sorting a collection 33 Sort() 33 SortBy() 34 SortByDesc() 35 Using reduce() 35 Using macro() to extend collections 36 Using Array Syntax0 码力 | 216 页 | 1.58 MB | 1 年前3
Laravel 5.6 中文文档test 在终端 ping 一下任意 *.test 域名,如果 Valet 安装正确就会看到来自 127.0.0.1 的响 应: PING foobar.dev (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.069 ms 64 bytes from 127.0.0.1: icmp_seq=1 视图响应 如果你需要控制响应状态和响应头,并且还需要返回一个视图作为响应内容,可以使用 view 方法: return response() ->view('hello', $data, 200) ->header('Content-Type', $type); 当然,如果你不需要传递自定义的 HTTP 状态码和头信息,只需要简单使用全局辅助函数 view : @include('view.name', ['some' => 'data']) 当然,如果你尝试包含一个不存在的视图,Laravel 会抛出错误,如果你想要包含一个有可能不存在的视图,可以使用 @includeIf 指令: @includeIf('view.name', ['some' => 'data']) 如果包含的视图取决于一个给定的布尔条件,可以使用 @includeWhen0 码力 | 377 页 | 14.56 MB | 1 年前3
Laravel 6.0 中文文档RateLimited]; } 懒集合 许多开发者已经使用过 Laravel 功能强大的集合方法了,在 Laravel 6.0 中新引入了一个 LazyCollection 类来对 Collection 类进行 补充,LazyCollection 底层基于 PHP 的生成器实现,适用于处理 大型数据集。 例如,假设你的应用需要处理 GB 级别的日志文件,并使用 Laravel 的集 响应,文件下载、流响应等等。 视图响应 如果你需要控制响应状态和响应头,并且还需要返回一个视图作为响 应内容,可以使用 view 方法: return response() ->view('hello', $data, 200) ->header('Content-Type', $type); 当然,如果你不需要传递自定义的 HTTP 状态码和头信息,只需要 简单使用全局辅助函数 view 即可: R 样引用它: 本文档由学院君提供 学院君致力于提供优质 Laravel 中文学习资源:https://xueyuanjun.com 286 return view('admin.profile', $data); 判断视图是否存在 如果需要判断视图是否存在,可调用 View 门面上的 exists 方法, 如果视图在磁盘存在则返回 true: use Illuminate\Support\Facades\View;0 码力 | 1442 页 | 14.66 MB | 1 年前3
Laravel 5.1 中文文档$columns); // ... return $model; } lists 方法 lists 方法现在返回一个 Collection 实例而不是包含 Eloquent 查询结果的数组,如果你想 将 Collection 转化为数组,使用 all 方法: User::lists('id')->all(); 注意:Query Builder 的 lists 返回的仍然是数组。 6 Collection 类 sortBy 方法 sortBy 方法现在返回一个新的 collection 实例而不是改变已有的 collection: $collection = $collection->sortBy('name'); groupBy 方法 groupBy 方法现在为每个父级 Collection 中的 item 返回 Collection 实例,如果你想要将这些 map 方法实现: $collection->groupBy('type')->map(function($item){ return $item->all(); }); lists 方法 lists 方法现在返回一个 Collection 实例而不是数组,如果你想要将 Collection 转化数组,使 用 all 方法: $collection->lists('id')->all();0 码力 | 307 页 | 3.46 MB | 1 年前3
Laravel 5.2 中文文档类实例,该契约提供了一些有用的方法来生成响应。 视图 如果你需要控制响应状态和响应头,并且还需要返回一个视图作为响应内容,可以使 用 view 方法: return response()->view('hello', $data)->header('Content-Type', $type); 当然,如果你不需要传递自定义的 HTTP 状态码和头信息,只需要简单使用全局辅助函 数 view 即可。 JSON json ”号来引用嵌套视图,比如, 如果视图存放路径是 resources/views/admin/profile.php,那我们可以这样引用它: return view('admin.profile', $data); 判断视图是否存在 如果需要判断视图是否存在,可调用在不带参数的 view 之后使用 exists 方法,如果视图 在磁盘存在则返回 true: if (view()->exists('emails 在上述例子中可以看到,我们可以简单通过数组方式将数据传递到视图: return view('greetings', ['name' => 'Victoria']); 以这种方式传递数据的话,$data 应该是一个键值对数组,在视图中,就可以使用相应的 键来访问数据值,比如 。除此之外,还可以通过 with 方法添加独立 的数据片段到视图: $view =0 码力 | 377 页 | 4.56 MB | 1 年前3
Laravel 5.3 中文文档3,并没有什么重大更新。 集合 key/value 顺序调整 集合方法 first, last 和 contains 都将“value”作为第一个参数传递给相应的回调闭包,例如: $collection->first(function ($value, $key) { return ! is_null($value); }); 在 Laravel 之前的版本中,$key 部分由网友 AC1982(微信号)提供翻译支持。 数据库 集合 查询构建器现在返回 Illuminate\Support\Collection 实例而不是原生数组,以便保持和 Eloquent 返回结果类型一致。 如果你不想要迁移查询构建器结果到 Collection 实例,可以在查询构建器的 get 方法后调用 call 方法,这将会返回原生的 PHP 数组结果,从而保证向后兼容: 集合序列化 Illuminate\Queue\SerializesModels trait 现 在 适 当 实 例 化 了 Illuminate\Database\Eloquent\Collection。对绝大多数应用来说这不算重大更新,但是,如果 你的应用绝对依赖于不是通过队列任务从数据库重新获取的集合,那么就要验证这一改动对应用 没有负面影响。 后台 woker 在使用 Artisan0 码力 | 691 页 | 9.37 MB | 1 年前3
Laravel 5.0 Documentation
vi. Push Queues vii. Failed Jobs xix. Session i. Configuration ii. Session Usage iii. Flash Data iv. Database Sessions v. Session Drivers xx. Templates i. Blade Templating ii. Other Blade Control PodcastWasPurchased($podcast)); Of course, your event handler will receive the event object instead of a list of data: class ReportPodcastPurchase { public function handle(PodcastWasPurchased $event) { env environment file. If the application key is not set, your user sessions and other encrypted data will not be secure! Laravel needs almost no other configuration out of the box. You are free to get0 码力 | 242 页 | 1.44 MB | 1 年前3
《Slides Dev Web》02. Introduction aux frameworks PHP
– (bootstrap, ré-écriture des URL, …) • Object Relational Mapping5 – Active Record, Table Data Gateway, Data Mapper, … • UI Patterns6 MVC for webdev Conventions • Nommage – Classes – Base de données $routeInfo[2] ); } catch (Exception $e){ echo server_error($e); } break; } Framework PHP Une collection de bibliothèques avec un peu de glue. Un framework web vous propose une structure de base pour0 码力 | 24 页 | 1.03 MB | 1 年前3
Laravel 3.2 Documentation.................................................................................... 30 Binding Data To Views ........................................................................................ ..................................................................... 34 Redirecting With Flash Data......................................................................................... 36 Downloads constraints to both relationships and nested eager-loading you'll have complete control over your data with all of the 2 conveniences of ActiveRecord. Eloquent natively supports all of the methods0 码力 | 139 页 | 1.13 MB | 1 年前3
The Laravel Handbook
anything other than HTML. 18 But you can do lots of interesting stuff in Blade templates: insert data, add conditionals, do loops, display something if the user is authenticated or not, or show different Blade (for more I highly recommend the official Blade guide). In the route definition, you can pass data to a Blade template: Route::get('/test', function () { return view('test', ['name' => 'Flavio']); 'Flavio']); }); and use it like this:{{ $name }}
The {{ }} syntax allows you to add any data to the template, escaped. Inside it you can also run any PHP function you like, and Blade will display0 码力 | 111 页 | 14.25 MB | 1 年前3
共 14 条
- 1
- 2













