-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: seed and migrations examples and some optimizations
- Loading branch information
Argenis Chavarria
authored and
Argenis Chavarria
committed
Sep 22, 2024
1 parent
6685dc0
commit ca44ee4
Showing
13 changed files
with
347 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Default Field Type Settings | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you can set default field group and field type configuration that | ||
| is then merged with your field groups when they are composed. | ||
| | ||
| This allows you to avoid the repetitive process of setting common field | ||
| configuration such as `ui` on every `trueFalse` field or your | ||
| preferred `instruction_placement` on every `fieldGroup`. | ||
| | ||
*/ | ||
|
||
'defaults' => [ | ||
// 'trueFalse' => ['ui' => 1], | ||
// 'select' => ['ui' => 1], | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Custom Field Types | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you can define custom field types that are not included with ACF | ||
| out of the box. This allows you to use the fluent builder pattern with | ||
| custom field types such as `addEditorPalette()`. | ||
| | ||
*/ | ||
|
||
'types' => [ | ||
// 'editorPalette' => 'editor_palette', | ||
// 'phoneNumber' => 'phone_number', | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Cache Manifest Path | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you can define the cache manifest path. Fields are typically cached | ||
| when running the `acf:cache` command. This will cache the built field | ||
| groups and potentially improve performance in complex applications. | ||
| | ||
*/ | ||
|
||
'manifest' => storage_path('framework/cache'), | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
// Schema::create('test_table', function (Blueprint $table) { | ||
// $table->increments('id'); | ||
// $table->string('name'); | ||
// $table->timestamps(); | ||
// }); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
// Schema::dropIfExists('test_table'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
|
||
class DatabaseSeeder extends Seeder | ||
{ | ||
/** | ||
* Seed the application's database. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
$this->call([ | ||
TermsPageSeeder::class, | ||
]); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class TermsPageSeeder extends Seeder | ||
{ | ||
/** | ||
* Seed the application's database. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
// CHECK IF THE PAGE 'TERMS' EXIST | ||
$existingPage = DB::table('posts') | ||
->where('post_type', 'page') | ||
->where(function ($query) { | ||
$query->where('post_title', 'Terms') | ||
->orWhere('post_name', 'terms'); | ||
}) | ||
->first(); | ||
|
||
if (!$existingPage) { | ||
// CREATE THE TERMS PAGE IN WORDPRESS | ||
$id = DB::table("posts")->insertGetId([ | ||
'post_author' => 1, | ||
'post_date' => now(), | ||
'post_date_gmt' => now(), | ||
'post_content' => '', | ||
'post_title' => 'Terms', | ||
'post_excerpt' => '', | ||
'post_status' => 'publish', | ||
'comment_status' => 'open', | ||
'ping_status' => 'open', | ||
'to_ping' => '', | ||
'pinged' => '', | ||
'post_content_filtered' => '', | ||
'post_name' => 'terms', | ||
'post_modified' => now(), | ||
'post_modified_gmt' => now(), | ||
'post_type' => 'page', | ||
]); | ||
|
||
// ASIGN THE TEMPLATE TO THE PAGE | ||
DB::table('postmeta')->insert([ | ||
'post_id' => $id, | ||
'meta_key' => '_wp_page_template', | ||
'meta_value' => 'template-custom.blade.php', | ||
]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Here you can write your custom scripts that will be loaded only on the front page. | ||
|
||
import ExampleAjax from '@scripts/exampleAjax'; | ||
|
||
console.log('Front page script is ready! 🎉'); | ||
|
||
(new ExampleAjax).hello(); // Example of how to use the ExampleAjax class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,5 +33,7 @@ | |
|
||
@php(do_action('get_footer')) | ||
@php(wp_footer()) | ||
@yield('footer_scripts') | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.