GithubHelp home page GithubHelp logo

phpback's Introduction

Laravel&VueJs 开发移动与桌面平台项目

通过这个项目来学习Laravel&Vue的开发过程

##开发环境

###开发技术栈 laravel+mysql+php+bootstrap+require.js+axios+vuejs+vuex...

ideHelper

是一个帮助提高laravel代码提示功能的插件

###主要知识点

 一、利用Resouce资源控制器路由
    1.利用命令行在Article文件夹目录下创建一个名为ArticleController的资源控制器
    php artisan make:controller Article/ArticleController --resource
    #普通注册
    Route::resource('article', 'ArticleController');
    #限制指定路由
    Route::resource('article', 'ArticleController', ['only' => [
        'index', 'show', 'store', 'update', 'destroy']
    
  
二、 解决ajax跨域访问
默认情况下前台发送Ajax是允许跨域请求的。我们可以在后台进行相关设置然后允许前台跨域请求。

允许单个域名访问
header('Access-Control-Allow-Origin:http://www.***.com');

允许多个域名
$origin = isset($_SERVER['HTTP_ORIGIN'])? $_SERVER['HTTP_ORIGIN'] : '';

$allow_origin = array(
	'http://www.***.com',
	'http://www.***.com'
);
if(in_array($origin, $allow_origin)){
	header('Access-Control-Allow-Origin:'.$origin);
}

允许所有域名请求
header('Access-Control-Allow-Origin:*');
三创建多对多的关联表
    1.创建一个Model
    php artisan make:model Model/tagLesson -m 
    2.去到database/migrations/ _create_tag_table.php创建表必要字段
        $table->integer('tag_id');
        $table->integer('lesson_id');
    3.生成数据表
    php artisan migrate

phpback's People

Contributors

lchgl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.