fixing conflicts.
This commit is contained in:
commit
a85945561c
|
@ -35,8 +35,6 @@
|
|||
|
||||
return array(
|
||||
|
||||
// route the official docs
|
||||
'docs' => array(
|
||||
'handles' => 'docs'
|
||||
),
|
||||
'docs' => array('handles' => 'docs'),
|
||||
|
||||
);
|
|
@ -38,14 +38,24 @@
|
|||
| remain secret and should not be shared with anyone. Make it about 32
|
||||
| characters of random gibberish.
|
||||
|
|
||||
| The "auto_key" option tells Laravel to automatically set this key value
|
||||
| if one has not already been set. This is generally done on the first
|
||||
| request to the Laravel splash screen.
|
||||
|
|
||||
*/
|
||||
|
||||
'key' => 'YourSecretKeyGoesHere!',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Profiler Toolbar
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel includes a beautiful profiler toolbar that gives you a heads
|
||||
| up display of the queries and logs performed by your application.
|
||||
| This is wonderful for development, but, of course, you should
|
||||
| disable the toolbar for production applications..
|
||||
|
|
||||
*/
|
||||
|
||||
'profiler' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Character Encoding
|
||||
|
@ -140,6 +150,7 @@
|
|||
'Log' => 'Laravel\\Log',
|
||||
'Memcached' => 'Laravel\\Memcached',
|
||||
'Paginator' => 'Laravel\\Paginator',
|
||||
'Profiler' => 'Laravel\\Profiling\\Profiler',
|
||||
'URL' => 'Laravel\\URL',
|
||||
'Redirect' => 'Laravel\\Redirect',
|
||||
'Redis' => 'Laravel\\Redis',
|
||||
|
|
|
@ -112,6 +112,22 @@
|
|||
return Lang::file($bundle, $language, $file);
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Attach The Laravel Profiler
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If the profiler is enabled, we will attach it to the Laravel events
|
||||
| for both queries and logs. This allows the profiler to intercept
|
||||
| any of the queries or logs performed by the application.
|
||||
|
|
||||
*/
|
||||
|
||||
if (Config::get('application.profiler'))
|
||||
{
|
||||
Profiler::attach();
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable The Blade View Engine
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Laravel: A Framework For Web Artisans</title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
{{ HTML::style('laravel/css/style.css') }}
|
||||
</head>
|
||||
<body onload="prettyPrint()">
|
||||
<div class="wrapper">
|
||||
<header>
|
||||
<h1>Laravel</h1>
|
||||
<h2>A Framework For Web Artisans</h2>
|
||||
|
||||
<p class="intro-text" style="margin-top: 45px;">
|
||||
</p>
|
||||
</header>
|
||||
<div role="main" class="main">
|
||||
<div class="home">
|
||||
<h2>Learn the terrain.</h3>
|
||||
|
||||
<p>
|
||||
You've landed yourself on our default home page. The route that
|
||||
is generating this page lives at:
|
||||
</p>
|
||||
|
||||
<pre>{{ path('app') }}routes.php</pre>
|
||||
|
||||
<p>And the view sitting before you can be found at:</p>
|
||||
|
||||
<pre>{{ path('app') }}views/home/index.php</pre>
|
||||
|
||||
<h2>Grow in knowledge.</h2>
|
||||
|
||||
<p>
|
||||
Leaning to use Laravel is amazingly simple thanks to
|
||||
its {{ HTML::link('docs', 'wonderful documentation') }}.
|
||||
</p>
|
||||
|
||||
<h2>Create something beautiful.</h2>
|
||||
|
||||
<p>
|
||||
Now that you're up and running, it's time to start creating!
|
||||
Here are some links to help you get started:
|
||||
</p>
|
||||
|
||||
<ul class="out-links">
|
||||
<li><a href="http://laravel.com">Official Website</a></li>
|
||||
<li><a href="http://forums.laravel.com">Laravel Forums</a></li>
|
||||
<li><a href="http://github.com/laravel/laravel">GitHub Repository</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,129 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Laravel - A Framework For Web Artisans</title>
|
||||
|
||||
<style>
|
||||
@import url(http://fonts.googleapis.com/css?family=Ubuntu);
|
||||
|
||||
body {
|
||||
background: #eee;
|
||||
color: #6d6d6d;
|
||||
font: normal normal normal 14px/1.253 Ubuntu, sans-serif;
|
||||
margin: 0 0 25px 0;
|
||||
min-width: 800px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#main {
|
||||
background-clip: padding-box;
|
||||
background-color: #fff;
|
||||
border:1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 10px #cdcdcd;
|
||||
margin: 25px auto 0;
|
||||
padding: 30px;
|
||||
width: 700px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#main h1 {
|
||||
font-family: 'Ubuntu';
|
||||
font-size: 38px;
|
||||
letter-spacing: 2px;
|
||||
margin: 0 0 10px 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#main h2 {
|
||||
color: #999;
|
||||
font-size: 18px;
|
||||
letter-spacing: 3px;
|
||||
margin: 0 0 25px 0;
|
||||
padding: 0 0 0 0;
|
||||
}
|
||||
|
||||
#main h3 {
|
||||
color: #999;
|
||||
margin-top: 24px;
|
||||
padding: 0 0 0 0;
|
||||
}
|
||||
|
||||
#main h3 {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
#main p {
|
||||
line-height: 25px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
#main pre {
|
||||
background-color: #333;
|
||||
border-left: 1px solid #d8d8d8;
|
||||
border-top: 1px solid #d8d8d8;
|
||||
border-radius: 5px;
|
||||
color: #eee;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#main div.warning {
|
||||
background-color: #feefb3;
|
||||
border: 1px solid;
|
||||
border-radius: 5px;
|
||||
color: #9f6000;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
#main ul {
|
||||
margin: 10px 0;
|
||||
padding: 0 30px;
|
||||
}
|
||||
|
||||
#main li {
|
||||
margin: 5px 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<h1>Welcome To Laravel</h1>
|
||||
|
||||
<h2>A Framework For Web Artisans</h2>
|
||||
|
||||
<p>
|
||||
You have successfully installed the Laravel framework. Laravel is a simple framework
|
||||
that helps web artisans create beautiful, creative applications using elegant, expressive
|
||||
syntax. You'll love using it.
|
||||
</p>
|
||||
|
||||
<h3>Learn the terrain.</h3>
|
||||
|
||||
<p>
|
||||
You've landed yourself on our default home page. The route that
|
||||
is generating this page lives at:
|
||||
</p>
|
||||
|
||||
<pre><code>APP_PATH/routes.php</code></pre>
|
||||
|
||||
<p>And the view sitting before you can be found at:</p>
|
||||
|
||||
<pre><code>APP_PATH/views/home/index.php</code></pre>
|
||||
|
||||
<h3>Create something beautiful.</h3>
|
||||
|
||||
<p>
|
||||
Now that you're up and running, it's time to start creating!
|
||||
Here are some links to help you get started:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="http://laravel.com">Official Website</a></li>
|
||||
<li><a href="http://forums.laravel.com">Laravel Forums</a></li>
|
||||
<li><a href="http://github.com/laravel/laravel">GitHub Repository</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
2
artisan
2
artisan
|
@ -3,7 +3,7 @@
|
|||
* Laravel - A PHP Framework For Web Artisans
|
||||
*
|
||||
* @package Laravel
|
||||
* @version 3.1.4
|
||||
* @version 3.1.5
|
||||
* @author Taylor Otwell <taylorotwell@gmail.com>
|
||||
* @link http://laravel.com
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,38 +1,85 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Load the Markdown library.
|
||||
*/
|
||||
require_once __DIR__.'/libraries/markdown.php';
|
||||
|
||||
/**
|
||||
* Get the root path for the documentation Markdown.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function doc_root()
|
||||
{
|
||||
return path('sys').'documentation/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parsed Markdown contents of a given page.
|
||||
*
|
||||
* @param string $page
|
||||
* @return string
|
||||
*/
|
||||
function document($page)
|
||||
{
|
||||
return Markdown(file_get_contents(doc_root().$page.'.md'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a documentation page exists.
|
||||
*
|
||||
* @param string $page
|
||||
* @return bool
|
||||
*/
|
||||
function document_exists($page)
|
||||
{
|
||||
return file_exists(doc_root().$page.'.md');
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach the sidebar to the documentatoin template.
|
||||
*/
|
||||
View::composer('docs::template', function($view)
|
||||
{
|
||||
Asset::add('stylesheet', 'laravel/css/style.css');
|
||||
Asset::add('modernizr', 'laravel/js/modernizr-2.5.3.min.js');
|
||||
Asset::container('footer')->add('prettify', 'laravel/js/prettify.js');
|
||||
$view->with('sidebar', Markdown(file_get_contents(path('storage').'documentation/contents.md')));
|
||||
$view->with('sidebar', document('contents'));
|
||||
});
|
||||
|
||||
/**
|
||||
* Handle the documentation homepage.
|
||||
*
|
||||
* This page contains the "introduction" to Laravel.
|
||||
*/
|
||||
Route::get('(:bundle)', function()
|
||||
{
|
||||
return View::make('docs::home');
|
||||
return View::make('docs::page')->with('content', document('home'));
|
||||
});
|
||||
|
||||
Route::get('docs/(:any)/(:any?)', function($section, $page = null)
|
||||
/**
|
||||
* Handle documentation routes for sections and pages.
|
||||
*
|
||||
* @param string $section
|
||||
* @param string $page
|
||||
* @return mixed
|
||||
*/
|
||||
Route::get('(:bundle)/(:any)/(:any?)', function($section, $page = null)
|
||||
{
|
||||
$root = path('storage').'documentation/';
|
||||
$file = rtrim(implode('/', func_get_args()), '/');
|
||||
|
||||
$file = rtrim(implode('/', array($section, $page)), '/').'.md';
|
||||
|
||||
if (file_exists($path = $root.$file))
|
||||
// If no page was specified, but a "home" page exists for the section,
|
||||
// we'll set the file to the home page so that the proper page is
|
||||
// display back out to the client for the requested doc page.
|
||||
if (is_null($page) and document_exists($file.'/home'))
|
||||
{
|
||||
$content = Markdown(file_get_contents($path));
|
||||
$file .= '/home';
|
||||
}
|
||||
elseif (file_exists($path = $root.$section.'/home.md'))
|
||||
|
||||
if (document_exists($file))
|
||||
{
|
||||
$content = Markdown(file_get_contents($path));
|
||||
return View::make('docs::page')->with('content', document($file));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Response::error('404');
|
||||
}
|
||||
|
||||
return View::make('docs::page')->with('content', $content);
|
||||
});
|
|
@ -1,37 +0,0 @@
|
|||
@layout('docs::template')
|
||||
|
||||
@section('content')
|
||||
<h1>Learn the terrain.</h1>
|
||||
|
||||
<p>
|
||||
You've landed yourself on our default home page. The route that
|
||||
is generating this page lives in the main routes file. You can
|
||||
find it here:
|
||||
</p>
|
||||
|
||||
<pre>APP_PATH/routes.php</pre>
|
||||
|
||||
<!--
|
||||
<pre class="prettyprint lang-php linenums">
|
||||
return array(
|
||||
'welcome' => 'Welcome to our website!',
|
||||
);
|
||||
</pre>
|
||||
-->
|
||||
<p>And the view sitting before you can be found at:</p>
|
||||
|
||||
<pre>APP_PATH/views/home/index.php</pre>
|
||||
|
||||
<h1>Create something beautiful.</h1>
|
||||
|
||||
<p>
|
||||
Now that you're up and running, it's time to start creating!
|
||||
Here are some links to help you get started:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="http://laravel.com">Official Website</a></li>
|
||||
<li><a href="http://forums.laravel.com">Laravel Forums</a></li>
|
||||
<li><a href="http://github.com/laravel/laravel">GitHub Repository</a></li>
|
||||
</ul>
|
||||
@endsection
|
|
@ -1,27 +0,0 @@
|
|||
<h2>Documentation</h2>
|
||||
<ul>
|
||||
<li><a href="#">Menu Item</a></li>
|
||||
<li><a href="#">Menu Item</a></li>
|
||||
<li><a href="#">Menu Item</a>
|
||||
<ul>
|
||||
<li><a href="#">Sub Menu Item</a></li>
|
||||
<li><a href="#">Sub Menu Item</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#">Menu Item</a></li>
|
||||
<li><a href="#">Menu Item</a></li>
|
||||
<li><a href="#">Menu Item</a>
|
||||
<ul>
|
||||
<li><a href="#">Sub Menu Item</a></li>
|
||||
<li><a href="#">Sub Menu Item</a></li>
|
||||
<li><a href="#">Sub Menu Item</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#">Menu Item</a></li>
|
||||
<li><a href="#">Menu Item</a></li>
|
||||
<li><a href="#">Menu Item</a></li>
|
||||
<li><a href="#">Menu Item</a></li>
|
||||
<li><a href="#">Menu Item</a></li>
|
||||
<li><a href="#">Menu Item</a></li>
|
||||
<li><a href="#">Menu Item</a></li>
|
||||
</ul>
|
|
@ -5,8 +5,9 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Laravel: A Framework For Web Artisans</title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
{{ Asset::styles(); }}
|
||||
{{ Asset::scripts(); }}
|
||||
|
||||
{{ HTML::style('laravel/css/style.css') }}
|
||||
{{ HTML::style('laravel/js/modernizr-2.5.3.min.js') }}
|
||||
</head>
|
||||
<body onload="prettyPrint()">
|
||||
<div class="wrapper">
|
||||
|
@ -14,10 +15,7 @@
|
|||
<h1>Laravel</h1>
|
||||
<h2>A Framework For Web Artisans</h2>
|
||||
|
||||
<p class="intro-text">
|
||||
You have successfully installed the Laravel framework. Laravel is a simple framework
|
||||
that helps web artisans create beautiful, creative applications using elegant, expressive
|
||||
syntax. You'll love using it.
|
||||
<p class="intro-text" style="margin-top: 45px;">
|
||||
</p>
|
||||
</header>
|
||||
<div role="main" class="main">
|
||||
|
@ -29,6 +27,8 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ Asset::container('footer')->scripts(); }}
|
||||
{{ HTML::script('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js') }}
|
||||
{{ HTML::script('laravel/js/prettify.js') }}
|
||||
{{ HTML::script('laravel/js/scroll.js') }}
|
||||
</body>
|
||||
</html>
|
|
@ -264,7 +264,7 @@ protected static function compile_includes($value)
|
|||
{
|
||||
$pattern = static::matcher('include');
|
||||
|
||||
return preg_replace($pattern, '$1<?php echo view$2->with(get_defined_vars()); ?>', $value);
|
||||
return preg_replace($pattern, '$1<?php echo view$2->with(get_defined_vars())->render(); ?>', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,54 @@ public function results()
|
|||
return parent::get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync the association table with an array of models.
|
||||
*
|
||||
* @param mixed $models
|
||||
* @return bool
|
||||
*/
|
||||
public function save($models)
|
||||
{
|
||||
// If the given "models" are not an array, we'll force them into an array so
|
||||
// we can conveniently loop through them and insert all of them into the
|
||||
// related database table assigned to the associated model instance.
|
||||
if ( ! is_array($models)) $models = array($models);
|
||||
|
||||
$current = $this->table->lists($this->model->key());
|
||||
|
||||
foreach ($models as $attributes)
|
||||
{
|
||||
$attributes[$this->foreign_key()] = $this->base->get_key();
|
||||
|
||||
$class = get_class($this->model);
|
||||
|
||||
// If the "attributes" are actually an array of the related model we'll
|
||||
// just use the existing instance instead of creating a fresh model
|
||||
// instance for the attributes. This allows for validation.
|
||||
if ($attributes instanceof $class)
|
||||
{
|
||||
$model = $attributes;
|
||||
}
|
||||
else
|
||||
{
|
||||
$model = $this->fresh_model($attributes);
|
||||
}
|
||||
|
||||
$id = $model->get_key();
|
||||
|
||||
$model->exists = ( ! is_null($id) and in_array($id, $current));
|
||||
|
||||
// Before saving we'll force the entire model to be "dirty" so all of
|
||||
// the attributes are saved. It shouldn't affect the updates as
|
||||
// saving all the attributes shouldn't hurt anything.
|
||||
$model->original = array();
|
||||
|
||||
$model->save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a relationship on an array of parent models.
|
||||
*
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
## Laravel Change Log
|
||||
# Laravel Change Log
|
||||
|
||||
## Contents
|
||||
|
||||
- [Laravel 3.2](#3.2)
|
||||
- [Upgrading From 3.1](#upgrade-3.2)
|
||||
- [Laravel 3.1.5](#3.1.5)
|
||||
- [Upgrading From 3.1.4](#upgrade-3.1.5)
|
||||
- [Laravel 3.1.4](#3.1.4)
|
||||
- [Upgrading From 3.1.3](#upgrade-3.1.4)
|
||||
- [Laravel 3.1.3](#3.1.3)
|
||||
|
@ -18,11 +20,12 @@ ## Contents
|
|||
<a name="3.2"></a>
|
||||
## Laravel 3.2
|
||||
|
||||
- [Added `to_array` method to the base Eloquent model](/docs/database/eloquent#to-array).
|
||||
- [Added `$hidden` static variable to the base Eloquent model](/docs/database/eloquent#to-array).
|
||||
- [Added `sync` method to has\_many\_and\_belongs\_to Eloquent relationship](/docs/database/eloquent#sync-method).
|
||||
- [Added `save` method to has\_many Eloquent relationship](/docs/database/eloquent#has-many-save).
|
||||
- Fixed the passing of strings into the Input::except method.
|
||||
- Fixed replacement of optional parameters in URL::transpose method.
|
||||
- Added "to_array" method to the base Eloquent model.
|
||||
- Added "$hidden" static variable to the base Eloquent model.
|
||||
- Added "sync" method to has_many_and_belongs_to Eloquent relationship.
|
||||
- Improved View performance by only loading contents from file once.
|
||||
- Fix handling of URLs beginning with has in URL::to.
|
||||
|
||||
|
@ -32,6 +35,16 @@ ## Upgrading From 3.1
|
|||
- Replace the **laravel** folder.
|
||||
- Add new **vendors** folder.
|
||||
|
||||
<a name="3.1.5"></a>
|
||||
## Laravel 3.1.5
|
||||
|
||||
- Fixes bug that could allow secure cookies to be sent over HTTP.
|
||||
|
||||
<a name="upgrade-3.1.5"></a>
|
||||
## Upgrading From 3.1.4
|
||||
|
||||
- Replace the **laravel** folder.
|
||||
|
||||
<a name="3.1.4"></a>
|
||||
## Laravel 3.1.4
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
### General
|
||||
- [Laravel Overview](/docs/home)
|
||||
- [Change Log](/docs/changes)
|
||||
- [Installation & Setup](/docs/install)
|
||||
- [Requirements](/docs/install#requirements)
|
||||
- [Installation](/docs/install#installation)
|
|
@ -14,6 +14,7 @@ ## Contents
|
|||
- [Constraining Eager Loads](#constraining-eager-loads)
|
||||
- [Setter & Getter Methods](#getter-and-setter-methods)
|
||||
- [Mass-Assignment](#mass-assignment)
|
||||
- [Converting Models To Arrays](#to-array)
|
||||
|
||||
<a name="the-basics"></a>
|
||||
## The Basics
|
||||
|
@ -289,6 +290,20 @@ ## Inserting Related Models
|
|||
|
||||
When inserting related models through their parent model, the foreign key will automatically be set. So, in this case, the "post_id" was automatically set to "1" on the newly inserted comment.
|
||||
|
||||
<a name="has-many-save"></a>
|
||||
When working with `has_many` relationships, you may use the `save` method to insert / update related models:
|
||||
|
||||
$comments = array(
|
||||
array('message' => 'A new comment.'),
|
||||
array('message' => 'A second comment.'),
|
||||
);
|
||||
|
||||
$post = Post::find(1);
|
||||
|
||||
$post->comments()->save($comments);
|
||||
|
||||
### Inserting Related Models (Many-To-Many)
|
||||
|
||||
This is even more helpful when working with many-to-many relationships. For example, consider a **User** model that has many roles. Likewise, the **Role** model may have many users. So, the intermediate table for this relationship has "user_id" and "role_id" columns. Now, let's insert a new Role for a User:
|
||||
|
||||
$role = new Role(array('title' => 'Admin'));
|
||||
|
@ -303,6 +318,11 @@ ## Inserting Related Models
|
|||
|
||||
$user->roles()->attach($role_id);
|
||||
|
||||
<a name="sync-method"></a>
|
||||
Alternatively, you can use the `sync` method, which accepts an array of IDs to "sync" with the intermediate table. After this operation is complete, only the IDs in the array will be on the intermediate table.
|
||||
|
||||
$user->roles()->sync(array(1, 2, 3));
|
||||
|
||||
<a name="intermediate-tables"></a>
|
||||
## Working With Intermediate Tables
|
||||
|
||||
|
@ -458,3 +478,24 @@ ## Mass-Assignment
|
|||
User::accessible(array('email', 'password', 'name'));
|
||||
|
||||
> **Note:** Utmost caution should be taken when mass-assigning using user-input. Technical oversights could cause serious security vulnerabilities.
|
||||
|
||||
<a name="to-array"></a>
|
||||
## Converting Models To Arrays
|
||||
|
||||
When building JSON APIs, you will often need to convert your models to array so they can be easily serialized. It's really simple.
|
||||
|
||||
#### Convert a model to an array:
|
||||
|
||||
return json_encode($user->to_array());
|
||||
|
||||
The `to_array` method will automatically grab all of the attributes on your model, as well as any loaded relationships.
|
||||
|
||||
Sometimes you may wish to limit the attributes that are included in your model's array, such as passwords. To do this, add a `hidden` attribute definition to your model:
|
||||
|
||||
#### Excluding attributes from the array:
|
||||
|
||||
class User extends Eloquent {
|
||||
|
||||
public static $hidden = array('password');
|
||||
|
||||
}
|
|
@ -195,4 +195,4 @@
|
|||
|
|
||||
*/
|
||||
|
||||
Event::fire('laravel.done');
|
||||
Event::fire('laravel.done', array($response));
|
||||
|
|
|
@ -0,0 +1,200 @@
|
|||
.anbu
|
||||
{
|
||||
font-family:Helvetica, "Helvetica Neue", Arial, sans-serif !important;
|
||||
font-size:14px !important;
|
||||
background-color:#222 !important;
|
||||
position:fixed !important;
|
||||
bottom:0 !important;
|
||||
right:0 !important;
|
||||
width:100%;
|
||||
z-index: 9999 !important;
|
||||
}
|
||||
|
||||
.anbu-tabs
|
||||
{
|
||||
margin:0 !important;
|
||||
padding:0 !important;
|
||||
overflow:hidden !important;
|
||||
}
|
||||
|
||||
.anbu-tabs li
|
||||
{
|
||||
display:inline;
|
||||
}
|
||||
|
||||
.anbu-tabs a, .anbu-tabs a:visited
|
||||
{
|
||||
color:#aaa !important;
|
||||
text-transform:uppercase !important;
|
||||
font-weight:bold !important;
|
||||
display:inline-block;
|
||||
text-decoration:none !important;
|
||||
font-size:0.8em !important;
|
||||
padding: 0.8em 2em 0.7em 2em !important;
|
||||
-webkit-transition-property:color, background-color;
|
||||
-webkit-transition-duration: 0.7s, 0.2s;
|
||||
-webkit-transition-timing-function: ease-in, ease-in;
|
||||
-moz-transition-property:color, background-color;
|
||||
-moz-transition-duration: 0.7s, 0.2s;
|
||||
-moz-transition-timing-function: ease-in, ease-in;
|
||||
-ms-transition-property:color, background-color;
|
||||
-ms-transition-duration: 0.7s, 0.2s;
|
||||
-ms-transition-timing-function: ease-in, ease-in;
|
||||
-o-transition-property:color, background-color;
|
||||
-o-transition-duration: 0.7s, 0.2s;
|
||||
-o-transition-timing-function: ease-in, ease-in;
|
||||
transition-property:color, background-color;
|
||||
transition-duration: 0.7s, 0.2s;
|
||||
transition-timing-function: ease-in, ease-in;
|
||||
}
|
||||
|
||||
#anbu-closed-tabs a, #anbu-closed-tabs a:visited
|
||||
{
|
||||
padding: 0.85em 1.2em 0.85em 1.2em !important;
|
||||
}
|
||||
|
||||
.anbu-tabs a:hover
|
||||
{
|
||||
background-color:#333 !important;
|
||||
color:#fff !important;
|
||||
}
|
||||
|
||||
.anbu-tabs a.anbu-active-tab
|
||||
{
|
||||
color:#fff !important;
|
||||
background-color:#333 !important;
|
||||
}
|
||||
|
||||
.anbu a:focus
|
||||
{
|
||||
outline:none !important;
|
||||
}
|
||||
|
||||
.anbu-tabs a:active
|
||||
{
|
||||
background-color:#111 !important;
|
||||
}
|
||||
|
||||
.anbu-tabs li.anbu-tab-right
|
||||
{
|
||||
float:right !important;
|
||||
}
|
||||
|
||||
.anbu-tabs li.anbu-tab-right a, .anbu-tabs li.anbu-tab-right a:visited
|
||||
{
|
||||
padding: 0.86em 2em 0.7em 2em !important;
|
||||
}
|
||||
|
||||
#anbu-closed-tabs
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
|
||||
|
||||
.anbu-window
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
|
||||
.anbu-content-area
|
||||
{
|
||||
background-color: #fff !important;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#eeeeee), to(#ffffff));
|
||||
background-image: -webkit-linear-gradient(top, #eeeeee, #ffffff);
|
||||
background-image: -moz-linear-gradient(top, #eeeeee, #ffffff);
|
||||
background-image: -ms-linear-gradient(top, #eeeeee, #ffffff);
|
||||
background-image: -o-linear-gradient(top, #eeeeee, #ffffff);
|
||||
background-image: linear-gradient(to bottom, #eeeeee, #ffffff);
|
||||
height:14em;
|
||||
margin-top:6px !important;
|
||||
overflow-x:hidden !important;
|
||||
overflow-y:auto !important;
|
||||
}
|
||||
|
||||
.anbu-table table
|
||||
{
|
||||
margin:0 !important;
|
||||
padding:0 !important;
|
||||
font-size:0.9em !important;
|
||||
border:0 !important;
|
||||
border-collapse:collapse !important;
|
||||
width:100% !important;
|
||||
background-color:#fff !important;
|
||||
}
|
||||
|
||||
.anbu-table pre
|
||||
{
|
||||
margin:0 !important;
|
||||
}
|
||||
|
||||
.anbu-table tr
|
||||
{
|
||||
border-bottom:1px solid #ccc !important;
|
||||
}
|
||||
|
||||
.anbu-table tr:first-child
|
||||
{
|
||||
border:0 !important;
|
||||
}
|
||||
|
||||
.anbu-table th
|
||||
{
|
||||
background-color:#555 !important;
|
||||
color:#fff !important;
|
||||
text-transform:uppercase !important;
|
||||
}
|
||||
|
||||
.anbu-table th, .anbu-table td
|
||||
{
|
||||
text-align:left !important;
|
||||
padding:0.4em 1em !important;
|
||||
margin:0 !important;
|
||||
}
|
||||
|
||||
.anbu-table td
|
||||
{
|
||||
vertical-align:top !important;
|
||||
}
|
||||
|
||||
.anbu-table-first
|
||||
{
|
||||
background-color:#eee !important;
|
||||
border-right:1px solid #ccc !important;
|
||||
width:10% !important;
|
||||
}
|
||||
|
||||
span.anbu-count
|
||||
{
|
||||
margin-left:0.5em !important;
|
||||
background-color:#555 !important;
|
||||
display:inline-block !important;
|
||||
padding:0.1em 0.5em 0.2em 0.5em !important;
|
||||
color:#eee !important;
|
||||
text-shadow:0 0 4px #000 !important;
|
||||
-webkit-border-radius: 1px;
|
||||
-moz-border-radius: 1px;
|
||||
border-radius: 1px;
|
||||
-moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box;
|
||||
|
||||
}
|
||||
|
||||
.anbu-empty
|
||||
{
|
||||
display:block !important;
|
||||
padding:1em !important;
|
||||
text-align:center !important;
|
||||
font-style:italic !important;
|
||||
color:#ccc !important;
|
||||
margin:1em !important;
|
||||
text-shadow:0 1px 0px #fff !important;
|
||||
}
|
||||
|
||||
.anbu pre
|
||||
{
|
||||
overflow-x: auto;
|
||||
white-space: pre-wrap;
|
||||
white-space: -moz-pre-wrap !important;
|
||||
white-space: -pre-wrap;
|
||||
white-space: -o-pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
var anbu = {
|
||||
|
||||
// BOUND ELEMENTS
|
||||
// -------------------------------------------------------------
|
||||
// Binding these elements early, stops jQuery from "querying"
|
||||
// the DOM every time they are used.
|
||||
|
||||
el : {
|
||||
main : $('.anbu'),
|
||||
close : $('#anbu-close'),
|
||||
zoom : $('#anbu-zoom'),
|
||||
hide : $('#anbu-hide'),
|
||||
show : $('#anbu-show'),
|
||||
tab_pane : $('.anbu-tab-pane'),
|
||||
hidden_tab_pane : $('.anbu-tab-pane:visible'),
|
||||
tab : $('.anbu-tab'),
|
||||
tabs : $('.anbu-tabs'),
|
||||
tab_links : $('.anbu-tabs a'),
|
||||
window : $('.anbu-window'),
|
||||
closed_tabs : $('#anbu-closed-tabs'),
|
||||
open_tabs : $('#anbu-open-tabs'),
|
||||
content_area : $('.anbu-content-area')
|
||||
},
|
||||
|
||||
// CLASS ATTRIBUTES
|
||||
// -------------------------------------------------------------
|
||||
// Useful variable for Anbu.
|
||||
|
||||
isZoomed : false, // is anbu in full screen mode
|
||||
small_height : $('.anbu-content-area').height(), // initial height of content area
|
||||
active_tab : 'anbu-active-tab', // the name of the active tab css
|
||||
tab_data : 'data-anbu-tab', // the data attribute of the tab link
|
||||
mini_button_width : '2.6em', // size of anbu when compact
|
||||
window_open : false, // is the top window open?
|
||||
active_pane : '', // current active pane
|
||||
|
||||
// START()
|
||||
// -------------------------------------------------------------
|
||||
// Sets up all the binds for Anbu!
|
||||
|
||||
start : function ()
|
||||
{
|
||||
// hide initial elements
|
||||
|
||||
anbu.el.close.hide();
|
||||
anbu.el.zoom.hide();
|
||||
anbu.el.tab_pane.hide();
|
||||
|
||||
// bind all click events
|
||||
anbu.el.close.click( function () { anbu.close_window(); });
|
||||
anbu.el.hide.click( function () { anbu.hide(); });
|
||||
anbu.el.show.click( function () { anbu.show(); });
|
||||
anbu.el.zoom.click( function () { anbu.zoom(); });
|
||||
anbu.el.tab.click( function () { anbu.clicked_tab($(this)); });
|
||||
},
|
||||
|
||||
// CLICKED_TAB()
|
||||
// -------------------------------------------------------------
|
||||
// A tab has been clicked, decide what to do.
|
||||
|
||||
clicked_tab : function (tab)
|
||||
{
|
||||
// if the tab is closed
|
||||
if(anbu.window_open && anbu.active_pane == tab.attr(anbu.tab_data))
|
||||
{
|
||||
anbu.close_window();
|
||||
}
|
||||
else
|
||||
{
|
||||
anbu.open_window(tab);
|
||||
}
|
||||
},
|
||||
|
||||
// OPEN_WINDOW()
|
||||
// -------------------------------------------------------------
|
||||
// Animate open the top window to the appropriate tab.
|
||||
|
||||
open_window : function (tab)
|
||||
{
|
||||
// can't directly assign this line, but it works
|
||||
$('.anbu-tab-pane:visible').fadeOut(200);
|
||||
$('.' + tab.attr(anbu.tab_data)).delay(220).fadeIn(300);
|
||||
anbu.el.tab_links.removeClass(anbu.active_tab);
|
||||
tab.addClass(anbu.active_tab);
|
||||
anbu.el.window.slideDown(300);
|
||||
anbu.el.close.fadeIn(300);
|
||||
anbu.el.zoom.fadeIn(300);
|
||||
anbu.active_pane = tab.attr(anbu.tab_data);
|
||||
anbu.window_open = true;
|
||||
},
|
||||
|
||||
|
||||
// CLOSE_WINDOW()
|
||||
// -------------------------------------------------------------
|
||||
// Animate closed the top window hiding all tabs.
|
||||
|
||||
close_window : function()
|
||||
{
|
||||
anbu.el.tab_pane.fadeOut(100);
|
||||
anbu.el.window.slideUp(300);
|
||||
anbu.el.close.fadeOut(300);
|
||||
anbu.el.zoom.fadeOut(300);
|
||||
anbu.el.tab_links.removeClass(anbu.active_tab);
|
||||
anbu.active_pane = '';
|
||||
anbu.window_open = false;
|
||||
},
|
||||
|
||||
|
||||
// SHOW()
|
||||
// -------------------------------------------------------------
|
||||
// Show the Anbu toolbar when it has been compacted.
|
||||
|
||||
show : function ()
|
||||
{
|
||||
anbu.el.closed_tabs.fadeOut(600, function () {
|
||||
anbu.el.open_tabs.fadeIn(200);
|
||||
})
|
||||
anbu.el.main.animate({width: '100%'}, 700);
|
||||
},
|
||||
|
||||
// HIDE()
|
||||
// -------------------------------------------------------------
|
||||
// Hide the anbu toolbar, show a tiny re-open button.
|
||||
|
||||
hide : function ()
|
||||
{
|
||||
anbu.close_window();
|
||||
anbu.el.window.slideUp(400, function () {
|
||||
anbu.close_window();
|
||||
anbu.el.open_tabs.fadeOut(200, function () {
|
||||
anbu.el.closed_tabs.fadeIn(200);
|
||||
})
|
||||
anbu.el.main.animate({width: anbu.mini_button_width}, 700);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
// TOGGLEZOOM()
|
||||
// -------------------------------------------------------------
|
||||
// Toggle the zoomed mode of the top window.
|
||||
|
||||
zoom : function ()
|
||||
{
|
||||
if(anbu.isZoomed)
|
||||
{
|
||||
height = anbu.small_height;
|
||||
anbu.isZoomed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the 6px is padding on the top of the window
|
||||
height = ($(window).height() - anbu.el.tabs.height() - 6) + 'px';
|
||||
anbu.isZoomed = true;
|
||||
}
|
||||
|
||||
anbu.el.content_area.animate({height: height}, 700);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
jQuery(document).ready(function () {
|
||||
// launch anbu
|
||||
anbu.start();
|
||||
});
|
|
@ -0,0 +1,105 @@
|
|||
<?php namespace Laravel\Profiling;
|
||||
|
||||
use Laravel\View;
|
||||
use Laravel\File;
|
||||
use Laravel\Event;
|
||||
use Laravel\Config;
|
||||
use Laravel\Request;
|
||||
|
||||
class Profiler {
|
||||
|
||||
/**
|
||||
* An array of the recorded Profiler data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $data = array('queries' => array(), 'logs' => array());
|
||||
|
||||
/**
|
||||
* Get the rendered contents of the Profiler.
|
||||
*
|
||||
* @param Response $response
|
||||
* @return string
|
||||
*/
|
||||
public static function render($response)
|
||||
{
|
||||
// We only want to send the profiler toolbar if the request is not an AJAX
|
||||
// request, as sending it on AJAX requests could mess up JSON driven API
|
||||
// type applications, so we will not send anything in those scenarios.
|
||||
if ( ! Request::ajax())
|
||||
{
|
||||
return render('path: '.__DIR__.'/template'.BLADE_EXT, static::$data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a log entry to the log entries array.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function log($type, $message)
|
||||
{
|
||||
static::$data['logs'][] = array($type, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a performed SQL query to the Profiler.
|
||||
*
|
||||
* @param string $sql
|
||||
* @param array $bindings
|
||||
* @param float $time
|
||||
* @return void
|
||||
*/
|
||||
public static function query($sql, $bindings, $time)
|
||||
{
|
||||
foreach ($bindings as $binding)
|
||||
{
|
||||
$sql = preg_replace('/\?/', $binding, $sql, 1);
|
||||
}
|
||||
|
||||
static::$data['queries'][] = array($sql, $time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given response includes jQuery.
|
||||
*
|
||||
* @param Response $response
|
||||
* @return bool
|
||||
*/
|
||||
protected static function has_jquery($response)
|
||||
{
|
||||
$pattern = '/\<head>(.*)\<script(.+)jquery(.*)\>\<\/script\>(.*)\<\/head\>/';
|
||||
|
||||
return preg_match($pattern, $response->content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach the Profiler's event listeners.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function attach()
|
||||
{
|
||||
// First we'll attach to the query and log events. These allow us to catch
|
||||
// all of the SQL queries and log messages that come through Laravel,
|
||||
// and we will pass them onto the Profiler for simple storage.
|
||||
Event::listen('laravel.log', function($type, $message)
|
||||
{
|
||||
Profiler::log($type, $message);
|
||||
});
|
||||
|
||||
Event::listen('laravel.query', function($sql, $bindings, $time)
|
||||
{
|
||||
Profiler::query($sql, $bindings, $time);
|
||||
});
|
||||
|
||||
// We'll attach the profiler to the "done" event so that we can easily
|
||||
// attach the profiler output to the end of the output sent to the
|
||||
// browser. This will display the profiler's nice toolbar.
|
||||
Event::listen('laravel.done', function($response)
|
||||
{
|
||||
echo Profiler::render($response);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
<!-- ANBU - LARAVEL PROFILER -->
|
||||
<style type="text/css">{{ file_get_contents(path('sys').'profiling/profiler.css') }}</style>
|
||||
<div class="anbu">
|
||||
<div class="anbu-window">
|
||||
<div class="anbu-content-area">
|
||||
<div class="anbu-tab-pane anbu-table anbu-log">
|
||||
@if (count($logs) > 0)
|
||||
<table>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Message</th>
|
||||
</tr>
|
||||
@foreach ($logs as $log)
|
||||
<tr>
|
||||
<td class="anbu-table-first">
|
||||
{{ $log[0] }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $log[1] }}
|
||||
</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
</table>
|
||||
@else
|
||||
<span class="anbu-empty">There are no log entries.</span>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="anbu-tab-pane anbu-table anbu-sql">
|
||||
@if (count($queries) > 0)
|
||||
<table>
|
||||
<tr>
|
||||
<th>Time</th>
|
||||
<th>Query</th>
|
||||
</tr>
|
||||
@foreach ($queries as $query)
|
||||
<tr>
|
||||
<td class="anbu-table-first">
|
||||
{{ $query[1] }}ms
|
||||
</td>
|
||||
<td>
|
||||
<pre>{{ $query[0] }}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
@else
|
||||
<span class="anbu-empty">There have been no SQL queries executed.</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul id="anbu-open-tabs" class="anbu-tabs">
|
||||
<li><a data-anbu-tab="anbu-log" class="anbu-tab" href="#">Log <span class="anbu-count">{{ count($logs) }}</span></a></li>
|
||||
<li><a data-anbu-tab="anbu-sql" class="anbu-tab" href="#">SQL <span class="anbu-count">{{ count($queries) }}</span></a></li>
|
||||
<li class="anbu-tab-right"><a id="anbu-hide" href="#">↦</a></li>
|
||||
<li class="anbu-tab-right"><a id="anbu-close" href="#">×</a></li>
|
||||
<li class="anbu-tab-right"><a id="anbu-zoom" href="#">⇅</a></li>
|
||||
</ul>
|
||||
|
||||
<ul id="anbu-closed-tabs" class="anbu-tabs">
|
||||
<li><a id="anbu-show" href="#">↤</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
|
||||
<script>{{ file_get_contents(path('sys').'profiling/profiler.js') }}</script>
|
||||
<!-- /ANBU - LARAVEL PROFILER -->
|
10
paths.php
10
paths.php
|
@ -3,7 +3,7 @@
|
|||
* Laravel - A PHP Framework For Web Artisans
|
||||
*
|
||||
* @package Laravel
|
||||
* @version 3.1.4
|
||||
* @version 3.1.5
|
||||
* @author Taylor Otwell <taylorotwell@gmail.com>
|
||||
* @link http://laravel.com
|
||||
*/
|
||||
|
@ -13,6 +13,14 @@
|
|||
// --------------------------------------------------------------
|
||||
if ( ! isset($web)) $web = false;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Change to the current directory if not from the web.
|
||||
// --------------------------------------------------------------
|
||||
if ( ! $web)
|
||||
{
|
||||
chdir(__DIR__);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Define the directory separator for the environment.
|
||||
// --------------------------------------------------------------
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Laravel - A PHP Framework For Web Artisans
|
||||
*
|
||||
* @package Laravel
|
||||
* @version 3.1.4
|
||||
* @version 3.1.5
|
||||
* @author Taylor Otwell <taylorotwell@gmail.com>
|
||||
* @link http://laravel.com
|
||||
*/
|
||||
|
|
|
@ -141,6 +141,14 @@ .content>h2 {
|
|||
margin-top:2.2em;
|
||||
}
|
||||
|
||||
div.home>h2:not(:first-child) {
|
||||
margin-top:2.2em;
|
||||
}
|
||||
|
||||
div.home>h2 {
|
||||
font-size: 14pt;
|
||||
}
|
||||
|
||||
.content>h3 {
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
@ -153,6 +161,33 @@ .content>h1:not(:first-child) {
|
|||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.content table
|
||||
{
|
||||
border-collapse:collapse
|
||||
border:1px solid #eee;
|
||||
width:100%;
|
||||
line-height:1.5em;
|
||||
}
|
||||
|
||||
.content table code
|
||||
{
|
||||
background-color:transparent;
|
||||
font-size:0.9em;
|
||||
}
|
||||
|
||||
.content table td, .content table th
|
||||
{
|
||||
border:1px solid #eee;
|
||||
padding:0.5em 0.7em;
|
||||
vertical-align:middle;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
.content table th
|
||||
{
|
||||
background-color:#f5f5f5;
|
||||
}
|
||||
|
||||
.content li
|
||||
{
|
||||
line-height:1.5em;
|
||||
|
@ -218,7 +253,12 @@ pre
|
|||
font-size:0.8em;
|
||||
background-color:#f5f5f5;
|
||||
text-shadow:1px 1px 0 #fff;
|
||||
line-height:1.7em;
|
||||
line-height:1.5em;
|
||||
}
|
||||
|
||||
.content pre li
|
||||
{
|
||||
margin:0.2em 0;
|
||||
}
|
||||
|
||||
code
|
||||
|
@ -230,6 +270,45 @@ code
|
|||
text-shadow:1px 1px 0 #fff;
|
||||
}
|
||||
|
||||
.out-links
|
||||
{
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
.out-links li
|
||||
{
|
||||
display:inline-block;
|
||||
}
|
||||
|
||||
.out-links li:not(:first-child):before
|
||||
{
|
||||
content:"/";
|
||||
padding:0 1em;
|
||||
color:#888;
|
||||
}
|
||||
|
||||
#toTop
|
||||
{
|
||||
display:none;
|
||||
padding:0.2em 1em 0.05em 1em;
|
||||
position:fixed;
|
||||
top:1.2em;
|
||||
right:1.2em;
|
||||
background-color:#777;
|
||||
text-align:center;
|
||||
color:#fff;
|
||||
text-decoration:none;
|
||||
text-transform:uppercase;
|
||||
font-size:0.9em;
|
||||
border-radius:3px;
|
||||
}
|
||||
|
||||
#toTop:hover
|
||||
{
|
||||
background-color:#E3591E;
|
||||
}
|
||||
|
||||
|
||||
/* Prettify Styles -------------- */
|
||||
|
||||
|
|
|
@ -0,0 +1,236 @@
|
|||
|
||||
/*
|
||||
* jQuery EasIng v1.1.2 - http://gsgd.co.uk/sandbox/jquery.easIng.php
|
||||
*
|
||||
* Uses the built In easIng capabilities added In jQuery 1.1
|
||||
* to offer multiple easIng options
|
||||
*
|
||||
* Copyright (c) 2007 George Smith
|
||||
* Licensed under the MIT License:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
// t: current time, b: begInnIng value, c: change In value, d: duration
|
||||
|
||||
jQuery.extend( jQuery.easing,
|
||||
{
|
||||
easeInQuad: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t + b;
|
||||
},
|
||||
easeOutQuad: function (x, t, b, c, d) {
|
||||
return -c *(t/=d)*(t-2) + b;
|
||||
},
|
||||
easeInOutQuad: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t + b;
|
||||
return -c/2 * ((--t)*(t-2) - 1) + b;
|
||||
},
|
||||
easeInCubic: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t*t + b;
|
||||
},
|
||||
easeOutCubic: function (x, t, b, c, d) {
|
||||
return c*((t=t/d-1)*t*t + 1) + b;
|
||||
},
|
||||
easeInOutCubic: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
||||
return c/2*((t-=2)*t*t + 2) + b;
|
||||
},
|
||||
easeInQuart: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t*t*t + b;
|
||||
},
|
||||
easeOutQuart: function (x, t, b, c, d) {
|
||||
return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
||||
},
|
||||
easeInOutQuart: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
||||
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
||||
},
|
||||
easeInQuint: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t*t*t*t + b;
|
||||
},
|
||||
easeOutQuint: function (x, t, b, c, d) {
|
||||
return c*((t=t/d-1)*t*t*t*t + 1) + b;
|
||||
},
|
||||
easeInOutQuint: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
||||
return c/2*((t-=2)*t*t*t*t + 2) + b;
|
||||
},
|
||||
easeInSine: function (x, t, b, c, d) {
|
||||
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
|
||||
},
|
||||
easeOutSine: function (x, t, b, c, d) {
|
||||
return c * Math.sin(t/d * (Math.PI/2)) + b;
|
||||
},
|
||||
easeInOutSine: function (x, t, b, c, d) {
|
||||
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
|
||||
},
|
||||
easeInExpo: function (x, t, b, c, d) {
|
||||
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
|
||||
},
|
||||
easeOutExpo: function (x, t, b, c, d) {
|
||||
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
|
||||
},
|
||||
easeInOutExpo: function (x, t, b, c, d) {
|
||||
if (t==0) return b;
|
||||
if (t==d) return b+c;
|
||||
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
||||
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
||||
},
|
||||
easeInCirc: function (x, t, b, c, d) {
|
||||
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
|
||||
},
|
||||
easeOutCirc: function (x, t, b, c, d) {
|
||||
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
|
||||
},
|
||||
easeInOutCirc: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
||||
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
||||
},
|
||||
easeInElastic: function (x, t, b, c, d) {
|
||||
var s=1.70158;var p=0;var a=c;
|
||||
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
||||
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
||||
},
|
||||
easeOutElastic: function (x, t, b, c, d) {
|
||||
var s=1.70158;var p=0;var a=c;
|
||||
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
||||
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
||||
},
|
||||
easeInOutElastic: function (x, t, b, c, d) {
|
||||
var s=1.70158;var p=0;var a=c;
|
||||
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
||||
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
||||
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
||||
},
|
||||
easeInBack: function (x, t, b, c, d, s) {
|
||||
if (s == undefined) s = 1.70158;
|
||||
return c*(t/=d)*t*((s+1)*t - s) + b;
|
||||
},
|
||||
easeOutBack: function (x, t, b, c, d, s) {
|
||||
if (s == undefined) s = 1.70158;
|
||||
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
||||
},
|
||||
easeInOutBack: function (x, t, b, c, d, s) {
|
||||
if (s == undefined) s = 1.70158;
|
||||
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
||||
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
||||
},
|
||||
easeInBounce: function (x, t, b, c, d) {
|
||||
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
|
||||
},
|
||||
easeOutBounce: function (x, t, b, c, d) {
|
||||
if ((t/=d) < (1/2.75)) {
|
||||
return c*(7.5625*t*t) + b;
|
||||
} else if (t < (2/2.75)) {
|
||||
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
|
||||
} else if (t < (2.5/2.75)) {
|
||||
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
|
||||
} else {
|
||||
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
|
||||
}
|
||||
},
|
||||
easeInOutBounce: function (x, t, b, c, d) {
|
||||
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
||||
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| UItoTop jQuery Plugin 1.1
|
||||
| http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
(function($){
|
||||
$.fn.UItoTop = function(options) {
|
||||
|
||||
var defaults = {
|
||||
text: 'To Top',
|
||||
min: 200,
|
||||
inDelay:600,
|
||||
outDelay:400,
|
||||
containerID: 'toTop',
|
||||
containerHoverID: 'toTopHover',
|
||||
scrollSpeed: 1200,
|
||||
easingType: 'linear'
|
||||
};
|
||||
|
||||
var settings = $.extend(defaults, options);
|
||||
var containerIDhash = '#' + settings.containerID;
|
||||
var containerHoverIDHash = '#'+settings.containerHoverID;
|
||||
|
||||
$('body').append('<a href="#" id="'+settings.containerID+'">'+settings.text+'</a>');
|
||||
$(containerIDhash).hide().click(function(){
|
||||
$('html, body').animate({scrollTop:0}, settings.scrollSpeed, settings.easingType);
|
||||
$('#'+settings.containerHoverID, this).stop().animate({'opacity': 0 }, settings.inDelay, settings.easingType);
|
||||
return false;
|
||||
})
|
||||
.prepend('<span id="'+settings.containerHoverID+'"></span>')
|
||||
.hover(function() {
|
||||
$(containerHoverIDHash, this).stop().animate({
|
||||
'opacity': 1
|
||||
}, 600, 'linear');
|
||||
}, function() {
|
||||
$(containerHoverIDHash, this).stop().animate({
|
||||
'opacity': 0
|
||||
}, 700, 'linear');
|
||||
});
|
||||
|
||||
$(window).scroll(function() {
|
||||
var sd = $(window).scrollTop();
|
||||
if(typeof document.body.style.maxHeight === "undefined") {
|
||||
$(containerIDhash).css({
|
||||
'position': 'absolute',
|
||||
'top': $(window).scrollTop() + $(window).height() - 50
|
||||
});
|
||||
}
|
||||
if ( sd > settings.min )
|
||||
$(containerIDhash).fadeIn(settings.inDelay);
|
||||
else
|
||||
$(containerIDhash).fadeOut(settings.Outdelay);
|
||||
});
|
||||
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
$().UItoTop({ easingType: 'easeOutQuart' });
|
||||
if ($('#docs-sidebar').length ) {
|
||||
$.get('/docs/sidebar', function(data) {
|
||||
$('.sidebar ul.toc').before(data);
|
||||
$('.sidebar ul.toc').hide();
|
||||
var url = document.location.href;
|
||||
// console.log(url);
|
||||
var parent_folder = url.substr(0, url.lastIndexOf('/'));
|
||||
var active = url.substr(0, url.length-document.location.hash.length);
|
||||
|
||||
$('.docs.sidebar ul ul').hide();
|
||||
$('.docs.sidebar ul ul').each(function() {
|
||||
$(this).parent('li').addClass('nav-close');
|
||||
var anchor = $(this).prev('a').attr('href');
|
||||
if (anchor == active.replace('http://laravel.com', '')) {
|
||||
$(this).prev('a').addClass('active');
|
||||
$(this).parent('li').addClass('nav-open').removeClass('nav-close');
|
||||
$(this).show();
|
||||
} else if (anchor == parent_folder.replace('http://laravel.com', '')) {
|
||||
$(this).prev('a').addClass('active');
|
||||
$(this).parent('li').addClass('nav-open').removeClass('nav-close');
|
||||
$(this).show();
|
||||
}
|
||||
//console.log(anchor+' == '+parent_folder);
|
||||
$(this).prev('a').bind('click', function(e) {
|
||||
$(this).parent('li').toggleClass('nav-open').toggleClass('nav-close');
|
||||
$(this).next('ul').animate({opacity: 'toggle', height: 'toggle'}, "slow");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
});
|
||||
} // end if
|
||||
});
|
Loading…
Reference in New Issue