您的位置:首页 > 编程语言 > PHP开发

laravel陌生知识点快速学习(四)

2015-07-30 11:23 591 查看

Laravel陌生知识点快速学习(四)

Eloquent增删查改

增(方法一)

$user = new User;

$user->name = 'John';

$user->save();

// 从request中获取数据并存储

$article_type = new ArticleType();
$article_type->name = $request->name;
$article_type->save();


增(方法二)

$user = User::create(['name' => 'John']);


删(方法一)

$user = User::find(1);

$user->delete();

$affectedRows = User::where('votes', '>', 100)->delete();


删(方法二)

User::destroy(1);

User::destroy([1, 2, 3]);

User::destroy(1, 2, 3);




$user = User::find(1);




$user = User::find(1);

$user->email = 'john@foo.com';

$user->save();


Form text textarea select 的使用

嵌套在Form open与close中,是表单的一部分

是laravel表单的一种复用,代替了div的使用

{!! Form::select('parent_id', $catArr , null , ['class' => 'form-control']) !!}

{!! Form::text('cate_name', '', ['class' => 'form-control','placeholder'=>'category_name']) !!}

{!! Form::textarea('seo_desc', '', ['class' => 'form-control']) !!}

{!! Form::model($article_type, ['route' => ['console.article_type.update', $article_type->id], 'method' => 'put','class'=>'form-horizontal']) !!}

{!! Form::open(['route' => 'console.article_type.store', 'method' => 'post','class'=>'form-horizontal']) !!}

{!! Form::file('pic') !!}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: